summaryrefslogtreecommitdiff
path: root/qmake
authorllornkcor <llornkcor>2003-07-10 02:40:10 (UTC)
committer llornkcor <llornkcor>2003-07-10 02:40:10 (UTC)
commit155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff)
treee6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake
parent86703e8a5527ef114facd02c005b6b3a7e62e263 (diff)
downloadopie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip
opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz
opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2
update qmake to 1.05a
Diffstat (limited to 'qmake') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/Makefile10
-rw-r--r--qmake/generators/makefile.cpp476
-rw-r--r--qmake/generators/makefile.h10
-rw-r--r--qmake/generators/projectgenerator.cpp64
-rw-r--r--qmake/generators/unix/unixmake.cpp168
-rw-r--r--qmake/generators/unix/unixmake.h1
-rw-r--r--qmake/generators/unix/unixmake2.cpp185
-rw-r--r--qmake/generators/win32/borland_bmake.cpp56
-rw-r--r--qmake/generators/win32/borland_bmake.h9
-rw-r--r--qmake/generators/win32/mingw_make.cpp524
-rw-r--r--qmake/generators/win32/mingw_make.h58
-rw-r--r--qmake/generators/win32/msvc_dsp.cpp171
-rw-r--r--qmake/generators/win32/msvc_dsp.h14
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp98
-rw-r--r--qmake/generators/win32/msvc_nmake.h8
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp243
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h100
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp412
-rw-r--r--qmake/generators/win32/msvc_vcproj.h30
-rw-r--r--qmake/generators/win32/winmakefile.cpp148
-rw-r--r--qmake/include/private/qapplication_p.h5
-rw-r--r--qmake/include/private/qcom_p.h6
-rw-r--r--qmake/include/private/qcomlibrary_p.h6
-rw-r--r--qmake/include/private/qcomplextext_p.h8
-rw-r--r--qmake/include/private/qcomponentfactory_p.h6
-rw-r--r--qmake/include/private/qcriticalsection_p.h4
-rw-r--r--qmake/include/private/qdir_p.h9
-rw-r--r--qmake/include/private/qeffects_p.h2
-rw-r--r--qmake/include/private/qeventloop_p.h70
-rw-r--r--qmake/include/private/qfontcodecs_p.h4
-rw-r--r--qmake/include/private/qfontdata_p.h3
-rw-r--r--qmake/include/private/qgfxdriverinterface_p.h18
-rw-r--r--qmake/include/private/qgpluginmanager_p.h8
-rw-r--r--qmake/include/private/qimageformatinterface_p.h8
-rw-r--r--qmake/include/private/qinputcontext_p.h5
-rw-r--r--qmake/include/private/qkbddriverinterface_p.h18
-rw-r--r--qmake/include/private/qlibrary_p.h5
-rw-r--r--qmake/include/private/qlock_p.h93
-rw-r--r--qmake/include/private/qmousedriverinterface_p.h18
-rw-r--r--qmake/include/private/qmutexpool_p.h44
-rw-r--r--qmake/include/private/qpluginmanager_p.h16
-rw-r--r--qmake/include/private/qpsprinter_p.h4
-rw-r--r--qmake/include/private/qrichtext_p.h59
-rw-r--r--qmake/include/private/qsettings_p.h2
-rw-r--r--qmake/include/private/qsharedmemory_p.h11
-rw-r--r--qmake/include/private/qsqldriverinterface_p.h17
-rw-r--r--qmake/include/private/qsqlextension_p.h41
-rw-r--r--qmake/include/private/qstyleinterface_p.h18
-rw-r--r--qmake/include/private/qsvgdevice_p.h8
-rw-r--r--qmake/include/private/qtextcodecinterface_p.h2
-rw-r--r--qmake/include/private/qtitlebar_p.h2
-rw-r--r--qmake/include/private/qucom_p.h76
-rw-r--r--qmake/include/private/qucomextra_p.h18
-rw-r--r--qmake/include/private/qwidgetinterface_p.h65
-rw-r--r--qmake/include/private/qwidgetresizehandler_p.h18
-rw-r--r--qmake/include/qasciidict.h4
-rw-r--r--qmake/include/qcstring.h7
-rw-r--r--qmake/include/qdict.h4
-rw-r--r--qmake/include/qdir.h3
-rw-r--r--qmake/include/qfeatures.h2
-rw-r--r--qmake/include/qgarray.h13
-rw-r--r--qmake/include/qglobal.h87
-rw-r--r--qmake/include/qintdict.h4
-rw-r--r--qmake/include/qmap.h4
-rw-r--r--qmake/include/qmemarray.h9
-rw-r--r--qmake/include/qptrlist.h6
-rw-r--r--qmake/include/qptrvector.h4
-rw-r--r--qmake/include/qregexp.h2
-rw-r--r--qmake/include/qstring.h91
-rw-r--r--qmake/include/qstrlist.h2
-rw-r--r--qmake/include/qtextcodec.h16
-rw-r--r--qmake/include/qtl.h1
-rw-r--r--qmake/include/quuid.h6
-rw-r--r--qmake/include/qvaluelist.h4
-rw-r--r--qmake/include/qvaluestack.h4
-rw-r--r--qmake/main.cpp9
-rw-r--r--qmake/option.cpp153
-rw-r--r--qmake/option.h5
-rw-r--r--qmake/project.cpp407
-rw-r--r--qmake/project.h20
-rw-r--r--qmake/tools/qbitarray.cpp3
-rw-r--r--qmake/tools/qbuffer.cpp4
-rw-r--r--qmake/tools/qcomlibrary.cpp43
-rw-r--r--qmake/tools/qconfig.cpp14
-rw-r--r--qmake/tools/qcriticalsection_p.cpp2
-rw-r--r--qmake/tools/qcstring.cpp107
-rw-r--r--qmake/tools/qdatastream.cpp24
-rw-r--r--qmake/tools/qdatetime.cpp70
-rw-r--r--qmake/tools/qdir.cpp94
-rw-r--r--qmake/tools/qdir_unix.cpp54
-rw-r--r--qmake/tools/qfile.cpp3
-rw-r--r--qmake/tools/qfile_unix.cpp13
-rw-r--r--qmake/tools/qfileinfo.cpp4
-rw-r--r--qmake/tools/qfileinfo_unix.cpp4
-rw-r--r--qmake/tools/qgarray.cpp97
-rw-r--r--qmake/tools/qgdict.cpp5
-rw-r--r--qmake/tools/qglist.cpp6
-rw-r--r--qmake/tools/qglobal.cpp45
-rw-r--r--qmake/tools/qgpluginmanager.cpp4
-rw-r--r--qmake/tools/qgvector.cpp9
-rw-r--r--qmake/tools/qlibrary.cpp13
-rw-r--r--qmake/tools/qlibrary_unix.cpp21
-rw-r--r--qmake/tools/qmutex_unix.cpp8
-rw-r--r--qmake/tools/qmutexpool.cpp78
-rw-r--r--qmake/tools/qregexp.cpp70
-rw-r--r--qmake/tools/qsemaphore_unix.cpp26
-rw-r--r--qmake/tools/qsettings.cpp387
-rw-r--r--qmake/tools/qstring.cpp434
-rw-r--r--qmake/tools/qtextstream.cpp2
-rw-r--r--qmake/tools/qucom.cpp136
-rw-r--r--qmake/tools/qwaitcondition_unix.cpp13
111 files changed, 4259 insertions, 1883 deletions
diff --git a/qmake/Makefile b/qmake/Makefile
index 90b0f07..01bb1a1 100644
--- a/qmake/Makefile
+++ b/qmake/Makefile
@@ -1,41 +1,41 @@
1QMAKESPECSDIR=$(OPIEDIR)/mkspecs 1QMAKESPECSDIR=$(OPIEDIR)/mkspecs
2 2
3######################################################################## 3########################################################################
4## This file was autogenerated by configure, all changes will be lost ## 4## This file was autogenerated by configure, all changes will be lost ##
5######################################################################## 5########################################################################
6 CC = gcc 6 CC = gcc
7 CXX = g++ 7 CXX = g++
8 8
9#qmake code 9#qmake code
10OBJS=project.o main.o makefile.o unixmake2.o unixmake.o borland_bmake.o \ 10OBJS=project.o main.o makefile.o unixmake2.o unixmake.o borland_bmake.o \
11 msvc_nmake.o msvc_dsp.o msvc_vcproj.o option.o winmakefile.o \ 11 mingw_make.o msvc_nmake.o msvc_dsp.o msvc_vcproj.o option.o winmakefile.o \
12 projectgenerator.o metrowerks_xml.o pbuilder_pbx.o msvc_objectmodel.o 12 projectgenerator.o metrowerks_xml.o pbuilder_pbx.o msvc_objectmodel.o
13 13
14#qt code 14#qt code
15QOBJS=qstring.o qtextstream.o qiodevice.o qglobal.o qgdict.o qcstring.o \ 15QOBJS=qstring.o qtextstream.o qiodevice.o qglobal.o qgdict.o qcstring.o \
16 qdatastream.o qgarray.o qbuffer.o qglist.o qptrcollection.o qfile.o \ 16 qdatastream.o qgarray.o qbuffer.o qglist.o qptrcollection.o qfile.o \
17 qfile_unix.o qregexp.o qgvector.o qgcache.o qbitarray.o qdir.o \ 17 qfile_unix.o qregexp.o qgvector.o qgcache.o qbitarray.o qdir.o quuid.o \
18 qfileinfo_unix.o qdir_unix.o qfileinfo.o qdatetime.o qstringlist.o qmap.o \ 18 qfileinfo_unix.o qdir_unix.o qfileinfo.o qdatetime.o qstringlist.o qmap.o \
19 qconfig.o 19 qconfig.o
20 20
21CFLAGS= \ 21CFLAGS= \
22 -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac \ 22 -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac \
23 -I$(OPIEDIR)/qmake/include -I$(OPIEDIR)/qmake/include/qmake -I$(QMAKESPECSDIR)/default \ 23 -I$(OPIEDIR)/qmake/include -I$(OPIEDIR)/qmake/include/qmake -I$(QMAKESPECSDIR)/default \
24 -I$(OPIEDIR)/qmake/include/private \ 24 -I$(OPIEDIR)/qmake/include/private \
25 -DQT_NO_TEXTCODEC -DQT_LITE_COMPONENT -DQT_NO_STL -DQT_NO_COMPRESS 25 -DQT_NO_TEXTCODEC -DQT_LITE_COMPONENT -DQT_NO_STL -DQT_NO_COMPRESS
26CXXFLAGS= $(CFLAGS) 26CXXFLAGS= $(CFLAGS)
27LFLAGS= 27LFLAGS=
28 28
29qmake: $(OBJS) $(QOBJS) 29qmake: $(OBJS) $(QOBJS)
30 $(CXX) -o $@ $(OBJS) $(QOBJS) $(LFLAGS) 30 $(CXX) -o $@ $(OBJS) $(QOBJS) $(LFLAGS)
31 $(if $(OPIEDIR),rm -f $(OPIEDIR)/bin/$@) 31 $(if $(OPIEDIR),rm -f $(OPIEDIR)/bin/$@)
32 $(if $(OPIEDIR),ln -s ../qmake/$@ $(OPIEDIR)/bin/$@) 32 $(if $(OPIEDIR),ln -s ../qmake/$@ $(OPIEDIR)/bin/$@)
33 33
34install: qmake 34install: qmake
35 [ -d $(INSTALL_ROOT)$(QTDIR)/bin ] || mkdir -p $(INSTALL_ROOT)$(QTDIR)/bin 35 [ -d $(INSTALL_ROOT)$(QTDIR)/bin ] || mkdir -p $(INSTALL_ROOT)$(QTDIR)/bin
36 -cp -f $(QTDIR)/bin/qmake $(INSTALL_ROOT)$(QTDIR)/bin 36 -cp -f $(QTDIR)/bin/qmake $(INSTALL_ROOT)$(QTDIR)/bin
37 [ -d $(INSTALL_ROOT)$(QTDIR) ] || mkdir -p $(INSTALL_ROOT)$(QTDIR) 37 [ -d $(INSTALL_ROOT)$(QTDIR) ] || mkdir -p $(INSTALL_ROOT)$(QTDIR)
38 -cp -r -f $(QMAKESPECSDIR) $(INSTALL_ROOT)$(QTDIR) 38 -cp -r -f $(QMAKESPECSDIR) $(INSTALL_ROOT)$(QTDIR)
39 39
40clean:: 40clean::
41 rm -f $(OBJS) $(QOBJS) 41 rm -f $(OBJS) $(QOBJS)
@@ -77,93 +77,99 @@ qglist.o: $(OPIEDIR)/qmake/tools/qglist.cpp
77qptrcollection.o: $(OPIEDIR)/qmake/tools/qptrcollection.cpp 77qptrcollection.o: $(OPIEDIR)/qmake/tools/qptrcollection.cpp
78 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qptrcollection.cpp 78 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qptrcollection.cpp
79 79
80qfile.o: $(OPIEDIR)/qmake/tools/qfile.cpp 80qfile.o: $(OPIEDIR)/qmake/tools/qfile.cpp
81 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfile.cpp 81 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfile.cpp
82 82
83qfile_unix.o: $(OPIEDIR)/qmake/tools/qfile_unix.cpp 83qfile_unix.o: $(OPIEDIR)/qmake/tools/qfile_unix.cpp
84 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfile_unix.cpp 84 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfile_unix.cpp
85 85
86qregexp.o: $(OPIEDIR)/qmake/tools/qregexp.cpp 86qregexp.o: $(OPIEDIR)/qmake/tools/qregexp.cpp
87 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qregexp.cpp 87 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qregexp.cpp
88 88
89qgvector.o: $(OPIEDIR)/qmake/tools/qgvector.cpp 89qgvector.o: $(OPIEDIR)/qmake/tools/qgvector.cpp
90 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qgvector.cpp 90 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qgvector.cpp
91 91
92qgcache.o: $(OPIEDIR)/qmake/tools/qgcache.cpp 92qgcache.o: $(OPIEDIR)/qmake/tools/qgcache.cpp
93 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qgcache.cpp 93 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qgcache.cpp
94 94
95qbitarray.o: $(OPIEDIR)/qmake/tools/qbitarray.cpp 95qbitarray.o: $(OPIEDIR)/qmake/tools/qbitarray.cpp
96 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qbitarray.cpp 96 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qbitarray.cpp
97 97
98qdir.o: $(OPIEDIR)/qmake/tools/qdir.cpp 98qdir.o: $(OPIEDIR)/qmake/tools/qdir.cpp
99 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdir.cpp 99 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdir.cpp
100 100
101quuid.o: $(OPIEDIR)/qmake/tools/quuid.cpp
102 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/quuid.cpp
103
101qfileinfo_unix.o: $(OPIEDIR)/qmake/tools/qfileinfo_unix.cpp 104qfileinfo_unix.o: $(OPIEDIR)/qmake/tools/qfileinfo_unix.cpp
102 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfileinfo_unix.cpp 105 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfileinfo_unix.cpp
103 106
104qdir_unix.o: $(OPIEDIR)/qmake/tools/qdir_unix.cpp 107qdir_unix.o: $(OPIEDIR)/qmake/tools/qdir_unix.cpp
105 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdir_unix.cpp 108 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdir_unix.cpp
106 109
107qfileinfo.o: $(OPIEDIR)/qmake/tools/qfileinfo.cpp 110qfileinfo.o: $(OPIEDIR)/qmake/tools/qfileinfo.cpp
108 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfileinfo.cpp 111 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qfileinfo.cpp
109 112
110qdatetime.o: $(OPIEDIR)/qmake/tools/qdatetime.cpp 113qdatetime.o: $(OPIEDIR)/qmake/tools/qdatetime.cpp
111 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdatetime.cpp 114 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qdatetime.cpp
112 115
113qstringlist.o: $(OPIEDIR)/qmake/tools/qstringlist.cpp 116qstringlist.o: $(OPIEDIR)/qmake/tools/qstringlist.cpp
114 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qstringlist.cpp 117 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qstringlist.cpp
115 118
116qmap.o: $(OPIEDIR)/qmake/tools/qmap.cpp 119qmap.o: $(OPIEDIR)/qmake/tools/qmap.cpp
117 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qmap.cpp 120 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qmap.cpp
118 121
119qconfig.o: $(OPIEDIR)/qmake/tools/qconfig.cpp 122qconfig.o: $(OPIEDIR)/qmake/tools/qconfig.cpp
120 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qconfig.cpp 123 $(CXX) -c -o $@ $(CXXFLAGS) $(OPIEDIR)/qmake/tools/qconfig.cpp
121 124
122winmakefile.o: generators/win32/winmakefile.cpp 125winmakefile.o: generators/win32/winmakefile.cpp
123 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/winmakefile.cpp 126 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/winmakefile.cpp
124 127
125project.o: project.cpp project.h option.h 128project.o: project.cpp project.h option.h
126 $(CXX) -c -o $@ $(CXXFLAGS) project.cpp 129 $(CXX) -c -o $@ $(CXXFLAGS) project.cpp
127 130
128main.o: main.cpp project.h 131main.o: main.cpp project.h
129 $(CXX) -c -o $@ $(CXXFLAGS) main.cpp 132 $(CXX) -c -o $@ $(CXXFLAGS) main.cpp
130 133
131option.o: option.cpp option.h 134option.o: option.cpp option.h
132 $(CXX) -c -o $@ $(CXXFLAGS) option.cpp 135 $(CXX) -c -o $@ $(CXXFLAGS) option.cpp
133 136
134makefile.o: generators/makefile.cpp 137makefile.o: generators/makefile.cpp
135 $(CXX) -c -o $@ $(CXXFLAGS) generators/makefile.cpp 138 $(CXX) -c -o $@ $(CXXFLAGS) generators/makefile.cpp
136 139
137unixmake.o: generators/unix/unixmake.cpp 140unixmake.o: generators/unix/unixmake.cpp
138 $(CXX) -c -o $@ $(CXXFLAGS) generators/unix/unixmake.cpp 141 $(CXX) -c -o $@ $(CXXFLAGS) generators/unix/unixmake.cpp
139 142
140unixmake2.o: generators/unix/unixmake2.cpp 143unixmake2.o: generators/unix/unixmake2.cpp
141 $(CXX) -c -o $@ $(CXXFLAGS) generators/unix/unixmake2.cpp 144 $(CXX) -c -o $@ $(CXXFLAGS) generators/unix/unixmake2.cpp
142 145
143borland_bmake.o: generators/win32/borland_bmake.cpp 146borland_bmake.o: generators/win32/borland_bmake.cpp
144 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/borland_bmake.cpp 147 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/borland_bmake.cpp
145 148
149mingw_make.o: generators/win32/mingw_make.cpp
150 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/mingw_make.cpp
151
146msvc_objectmodel.o: generators/win32/msvc_objectmodel.cpp 152msvc_objectmodel.o: generators/win32/msvc_objectmodel.cpp
147 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_objectmodel.cpp 153 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_objectmodel.cpp
148 154
149msvc_vcproj.o: generators/win32/msvc_vcproj.cpp 155msvc_vcproj.o: generators/win32/msvc_vcproj.cpp
150 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_vcproj.cpp 156 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_vcproj.cpp
151 157
152msvc_nmake.o: generators/win32/msvc_nmake.cpp 158msvc_nmake.o: generators/win32/msvc_nmake.cpp
153 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_nmake.cpp 159 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_nmake.cpp
154 160
155metrowerks_xml.o: generators/mac/metrowerks_xml.cpp 161metrowerks_xml.o: generators/mac/metrowerks_xml.cpp
156 $(CXX) -c -o $@ $(CXXFLAGS) generators/mac/metrowerks_xml.cpp 162 $(CXX) -c -o $@ $(CXXFLAGS) generators/mac/metrowerks_xml.cpp
157 163
158pbuilder_pbx.o: generators/mac/pbuilder_pbx.cpp 164pbuilder_pbx.o: generators/mac/pbuilder_pbx.cpp
159 $(CXX) -c -o $@ $(CXXFLAGS) generators/mac/pbuilder_pbx.cpp 165 $(CXX) -c -o $@ $(CXXFLAGS) generators/mac/pbuilder_pbx.cpp
160 166
161msvc_dsp.o: generators/win32/msvc_dsp.cpp 167msvc_dsp.o: generators/win32/msvc_dsp.cpp
162 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_dsp.cpp 168 $(CXX) -c -o $@ $(CXXFLAGS) generators/win32/msvc_dsp.cpp
163 169
164projectgenerator.o: generators/projectgenerator.cpp 170projectgenerator.o: generators/projectgenerator.cpp
165 $(CXX) -c -o $@ $(CXXFLAGS) generators/projectgenerator.cpp 171 $(CXX) -c -o $@ $(CXXFLAGS) generators/projectgenerator.cpp
166 172
167#default rules 173#default rules
168.c.o: 174.c.o:
169 $(CC) -c -o $@ $(CFLAGS) $< 175 $(CC) -c -o $@ $(CFLAGS) $<
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index f490313..c12375d 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1,32 +1,32 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
@@ -38,83 +38,97 @@
38#include "makefile.h" 38#include "makefile.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdict.h> 44#include <qdict.h>
45#if defined(Q_OS_UNIX) 45#if defined(Q_OS_UNIX)
46#include <unistd.h> 46#include <unistd.h>
47#else 47#else
48#include <io.h> 48#include <io.h>
49#endif 49#endif
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
52#include <time.h> 52#include <time.h>
53#include <fcntl.h> 53#include <fcntl.h>
54#include <sys/types.h> 54#include <sys/types.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56 56
57// Well, Windows doesn't have this, so here's the macro 57// Well, Windows doesn't have this, so here's the macro
58#ifndef S_ISDIR 58#ifndef S_ISDIR
59 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR) 59 #define S_ISDIR(m)(((m) & S_IFMT) == S_IFDIR)
60#endif 60#endif
61 61
62static QString mkdir_p_asstring(const QString &dir)
63{
64 QString ret = "@$(CHK_DIR_EXISTS) \"" + dir + "\" ";
65 if(Option::target_mode == Option::TARG_WIN_MODE)
66 ret += "$(MKDIR)";
67 else
68 ret += "|| $(MKDIR)";
69 ret += " \"" + dir + "\"";
70 return ret;
71}
72
62static bool createDir(const QString& fullPath) 73static bool createDir(const QString& fullPath)
63{ 74{
75 if(QFile::exists(fullPath))
76 return FALSE;
77
64 QDir dirTmp; 78 QDir dirTmp;
65 bool ret = TRUE; 79 bool ret = TRUE;
66 QString pathComponent, tmpPath; 80 QString pathComponent, tmpPath;
67 QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE); 81 QStringList hierarchy = QStringList::split(QString(Option::dir_sep), fullPath, TRUE);
68 for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) { 82 for(QStringList::Iterator it = hierarchy.begin(); it != hierarchy.end(); ++it) {
69 pathComponent = *it + QDir::separator(); 83 pathComponent = *it + QDir::separator();
70 tmpPath += pathComponent; 84 tmpPath += pathComponent;
71 if(!dirTmp.mkdir(tmpPath)) { 85 if(!dirTmp.mkdir(tmpPath)) {
72 ret = FALSE; 86 ret = FALSE;
73 // break; 87 // break;
74 } 88 }
75 } 89 }
76 return ret; 90 return ret;
77} 91}
78 92
79 93
80MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE), 94MakefileGenerator::MakefileGenerator(QMakeProject *p) : init_opath_already(FALSE),
81 init_already(FALSE), moc_aware(FALSE), 95 init_already(FALSE), moc_aware(FALSE),
82 no_io(FALSE), project(p) 96 no_io(FALSE), project(p)
83{ 97{
84} 98}
85 99
86static char *gimme_buffer(off_t s) 100static char *gimme_buffer(off_t s)
87{ 101{
88 static char *big_buffer = NULL; 102 static char *big_buffer = NULL;
89 static int big_buffer_size = 0; 103 static int big_buffer_size = 0;
90 if(!big_buffer || big_buffer_size < s) 104 if(!big_buffer || big_buffer_size < s)
91 big_buffer = (char *)realloc(big_buffer, s); 105 big_buffer = (char *)realloc(big_buffer, s);
92 return big_buffer; 106 return big_buffer;
93} 107}
94 108
95bool 109bool
96MakefileGenerator::generateMocList(QString fn_target) 110MakefileGenerator::generateMocList(const QString &fn_target)
97{ 111{
98 if(!findMocDestination(fn_target).isEmpty()) 112 if(!findMocDestination(fn_target).isEmpty())
99 return TRUE; 113 return TRUE;
100 114
101 QString fn_local = Option::fixPathToLocalOS(fileFixify(fn_target, QDir::currentDirPath(), Option::output_dir)); 115 QString fn_local = Option::fixPathToLocalOS(fileFixify(fn_target, QDir::currentDirPath(), Option::output_dir));
102 116
103 int file = open(fn_local.latin1(), O_RDONLY); 117 int file = open(fn_local.latin1(), O_RDONLY);
104 if(file == -1) 118 if(file == -1)
105 return FALSE; 119 return FALSE;
106 120
107 struct stat fst; 121 struct stat fst;
108 if(fstat(file, &fst) || S_ISDIR(fst.st_mode)) 122 if(fstat(file, &fst) || S_ISDIR(fst.st_mode))
109 return FALSE; //shouldn't happen 123 return FALSE; //shouldn't happen
110 char *big_buffer = gimme_buffer(fst.st_size); 124 char *big_buffer = gimme_buffer(fst.st_size);
111 125
112 int total_size_read; 126 int total_size_read;
113 for(int have_read = total_size_read = 0; 127 for(int have_read = total_size_read = 0;
114 (have_read = read(file, big_buffer + total_size_read, 128 (have_read = read(file, big_buffer + total_size_read,
115 fst.st_size - total_size_read)); 129 fst.st_size - total_size_read));
116 total_size_read += have_read); 130 total_size_read += have_read);
117 close(file); 131 close(file);
118 132
119 bool ignore_qobject = FALSE; 133 bool ignore_qobject = FALSE;
120 int line_count = 1; 134 int line_count = 1;
@@ -152,107 +166,108 @@ MakefileGenerator::generateMocList(QString fn_target)
152 } 166 }
153 } 167 }
154 } 168 }
155 } 169 }
156#define SYMBOL_CHAR(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || \ 170#define SYMBOL_CHAR(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || \
157 (x <= '0' && x >= '9') || x == '_') 171 (x <= '0' && x >= '9') || x == '_')
158 172
159 bool interesting = *(big_buffer+x) == 'Q' && (!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN) || 173 bool interesting = *(big_buffer+x) == 'Q' && (!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN) ||
160 !strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)); 174 !strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN));
161 if(interesting) { 175 if(interesting) {
162 int len = 0; 176 int len = 0;
163 if(!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN)) { 177 if(!strncmp(big_buffer+x, "Q_OBJECT", OBJ_LEN)) {
164 if(ignore_qobject) { 178 if(ignore_qobject) {
165 debug_msg(2, "Mocgen: %s:%d Ignoring Q_OBJECT", fn_target.latin1(), line_count); 179 debug_msg(2, "Mocgen: %s:%d Ignoring Q_OBJECT", fn_target.latin1(), line_count);
166 interesting = FALSE; 180 interesting = FALSE;
167 } 181 }
168 len=OBJ_LEN; 182 len=OBJ_LEN;
169 } else if(!strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)) { 183 } else if(!strncmp(big_buffer+x, "Q_DISPATCH", DIS_LEN)) {
170 len=DIS_LEN; 184 len=DIS_LEN;
171 } 185 }
172 if(SYMBOL_CHAR(*(big_buffer+x+len))) 186 if(SYMBOL_CHAR(*(big_buffer+x+len)))
173 interesting = FALSE; 187 interesting = FALSE;
174 if(interesting) { 188 if(interesting) {
175 *(big_buffer+x+len) = '\0'; 189 *(big_buffer+x+len) = '\0';
176 debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(), line_count, big_buffer+x); 190 debug_msg(2, "Mocgen: %s:%d Found MOC symbol %s", fn_target.latin1(),
191 line_count, big_buffer+x);
177 192
178 int ext_pos = fn_target.findRev('.'); 193 int ext_pos = fn_target.findRev('.');
179 int ext_len = fn_target.length() - ext_pos; 194 int ext_len = fn_target.length() - ext_pos;
180 int dir_pos = fn_target.findRev(Option::dir_sep, ext_pos); 195 int dir_pos = fn_target.findRev(Option::dir_sep, ext_pos);
181 QString mocFile; 196 QString mocFile;
182 if(!project->isEmpty("MOC_DIR")) 197 if(!project->isEmpty("MOC_DIR"))
183 mocFile = project->first("MOC_DIR"); 198 mocFile = project->first("MOC_DIR");
184 else if(dir_pos != -1) 199 else if(dir_pos != -1)
185 mocFile = fn_target.left(dir_pos+1); 200 mocFile = fn_target.left(dir_pos+1);
186 201
187 bool cpp_ext = FALSE; 202 bool cpp_ext = FALSE;
188 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { 203 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
204 cppit != Option::cpp_ext.end(); ++cppit) {
189 if((cpp_ext = (fn_target.right(ext_len) == (*cppit)))) 205 if((cpp_ext = (fn_target.right(ext_len) == (*cppit))))
190 break; 206 break;
191 } 207 }
192 if(cpp_ext) { 208 if(cpp_ext) {
193 mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext; 209 mocFile += fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + Option::moc_ext;
194 findDependencies(fn_target).append(mocFile);
195 project->variables()["_SRCMOC"].append(mocFile); 210 project->variables()["_SRCMOC"].append(mocFile);
196 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) { 211 } else if(project->variables()["HEADERS"].findIndex(fn_target) != -1) {
197 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { 212 for(QStringList::Iterator hit = Option::h_ext.begin();
213 hit != Option::h_ext.end(); ++hit) {
198 if((fn_target.right(ext_len) == (*hit))) { 214 if((fn_target.right(ext_len) == (*hit))) {
199 mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) + 215 mocFile += Option::moc_mod + fn_target.mid(dir_pos+1, ext_pos - dir_pos-1) +
200 Option::cpp_ext.first(); 216 Option::cpp_ext.first();
201 logicWarn(mocFile, "SOURCES"); 217 logicWarn(mocFile, "SOURCES");
202 project->variables()["_HDRMOC"].append(mocFile); 218 project->variables()["_HDRMOC"].append(mocFile);
203 break; 219 break;
204 } 220 }
205 } 221 }
206 } 222 }
207 223
208 if(!mocFile.isEmpty()) { 224 if(!mocFile.isEmpty()) {
209 mocFile = Option::fixPathToTargetOS(mocFile); 225 mocFile = Option::fixPathToTargetOS(mocFile);
210 mocablesToMOC[cleanFilePath(fn_target)] = mocFile; 226 mocablesToMOC[cleanFilePath(fn_target)] = mocFile;
211 mocablesFromMOC[cleanFilePath(mocFile)] = fn_target; 227 mocablesFromMOC[cleanFilePath(mocFile)] = fn_target;
212 } 228 }
213 break; 229 break;
214 } 230 }
215 } 231 }
216 232
217 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x))) 233 while(x < total_size_read && SYMBOL_CHAR(*(big_buffer+x)))
218 x++; 234 x++;
219 if(*(big_buffer+x) == '\n') 235 if(*(big_buffer+x) == '\n')
220 line_count++; 236 line_count++;
221 } 237 }
222#undef OBJ_LEN 238#undef OBJ_LEN
223#undef DIS_LEN 239#undef DIS_LEN
224 return TRUE; 240 return TRUE;
225} 241}
226 242
227bool 243bool
228MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QString fn, bool recurse) 244MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &f, bool recurse)
229{ 245{
230 fn = fileFixify(fn); 246 QStringList &fndeps = findDependencies(f);
231 QStringList &fndeps = findDependencies(fn);
232 if(!fndeps.isEmpty()) 247 if(!fndeps.isEmpty())
233 return TRUE; 248 return TRUE;
234 249 QString fn = fileFixify(f, QDir::currentDirPath(), Option::output_dir);
235 fn = Option::fixPathToLocalOS(fn, FALSE); 250 fn = Option::fixPathToLocalOS(fn, FALSE);
236 QString fix_env_fn = Option::fixPathToLocalOS(fn); 251 QString fix_env_fn = Option::fixPathToLocalOS(fn);
237 int file = open(fix_env_fn.latin1(), O_RDONLY); 252 int file = open(fix_env_fn.latin1(), O_RDONLY);
238 if(file == -1) 253 if(file == -1)
239 return FALSE; 254 return FALSE;
240 struct stat fst; 255 struct stat fst;
241 if(fstat(file, &fst) || S_ISDIR(fst.st_mode)) 256 if(fstat(file, &fst) || S_ISDIR(fst.st_mode))
242 return FALSE; //shouldn't happen 257 return FALSE; //shouldn't happen
243 258
244 QString fndir, fix_env_fndir; 259 QString fndir, fix_env_fndir;
245 int dl = fn.findRev(Option::dir_sep); 260 int dl = fn.findRev(Option::dir_sep);
246 if(dl != -1) 261 if(dl != -1)
247 fndir = fn.left(dl+1); 262 fndir = fn.left(dl+1);
248 dl = fix_env_fn.findRev(Option::dir_sep); 263 dl = fix_env_fn.findRev(Option::dir_sep);
249 if(dl != -1) 264 if(dl != -1)
250 fix_env_fndir = fix_env_fn.left(dl + 1); 265 fix_env_fndir = fix_env_fn.left(dl + 1);
251 266
252 int line_count = 1; 267 int line_count = 1;
253 char *big_buffer = gimme_buffer(fst.st_size); 268 char *big_buffer = gimme_buffer(fst.st_size);
254 269
255 int total_size_read; 270 int total_size_read;
256 for(int have_read = total_size_read = 0; 271 for(int have_read = total_size_read = 0;
257 (have_read = read(file, big_buffer + total_size_read, 272 (have_read = read(file, big_buffer + total_size_read,
258 fst.st_size - total_size_read)); 273 fst.st_size - total_size_read));
@@ -267,258 +282,314 @@ MakefileGenerator::generateDependencies(QPtrList<MakefileDependDir> &dirs, QStri
267 if(*(big_buffer + x) == '/') { 282 if(*(big_buffer + x) == '/') {
268 x++; 283 x++;
269 if(total_size_read >= x) { 284 if(total_size_read >= x) {
270 if(*(big_buffer + x) == '/') { //c++ style comment 285 if(*(big_buffer + x) == '/') { //c++ style comment
271 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++); 286 for( ; x < total_size_read && *(big_buffer + x) != '\n'; x++);
272 } else if(*(big_buffer + x) == '*') { //c style comment 287 } else if(*(big_buffer + x) == '*') { //c style comment
273 for( ; x < total_size_read; x++) { 288 for( ; x < total_size_read; x++) {
274 if(*(big_buffer + x) == '*') { 289 if(*(big_buffer + x) == '*') {
275 if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') { 290 if(total_size_read >= (x+1) && *(big_buffer + (x+1)) == '/') {
276 x += 2; 291 x += 2;
277 break; 292 break;
278 } 293 }
279 } else if(*(big_buffer + x) == '\n') { 294 } else if(*(big_buffer + x) == '\n') {
280 line_count++; 295 line_count++;
281 } 296 }
282 } 297 }
283 } 298 }
284 } 299 }
285 } 300 }
286 if(*(big_buffer + x) == '#') { 301 if(*(big_buffer + x) == '#') {
287 x++; 302 x++;
288 while(x < total_size_read && //Skip spaces after hash 303 while(x < total_size_read && //Skip spaces after hash
289 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) 304 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
290 x++; 305 x++;
291 if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include ", 8)) { 306 if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
292 for(x+=8; //skip spaces after keyword 307 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '\t' ||
308 *(big_buffer + x + 7) == '<' || *(big_buffer + x + 7) == '"')) {
309 for(x+=7; //skip spaces after keyword
293 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); 310 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
294 x++); 311 x++);
295 char term = *(big_buffer + x); 312 char term = *(big_buffer + x);
296 if(term == '"'); 313 if(term == '"');
297 else if(term == '<') 314 else if(term == '<')
298 term = '>'; 315 term = '>';
299 else 316 else
300 continue; //wtf? 317 continue; //wtf?
301 x++; 318 x++;
302 319
303 int inc_len; 320 int inc_len;
304 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++); 321 for(inc_len = 0; *(big_buffer + x + inc_len) != term; inc_len++);
305 *(big_buffer + x + inc_len) = '\0'; 322 *(big_buffer + x + inc_len) = '\0';
306 inc = big_buffer + x; 323 inc = big_buffer + x;
307 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) { 324 } else if(total_size_read >= x + 14 && !strncmp(big_buffer + x, "qmake_warning ", 14)) {
308 for(x+=14; //skip spaces after keyword 325 for(x+=14; //skip spaces after keyword
309 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'); 326 x < total_size_read && (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t');
310 x++); 327 x++);
311 char term = '\n'; 328 char term = '\n';
312 if(*(big_buffer + x) == '"') 329 if(*(big_buffer + x) == '"')
313 term = '"'; 330 term = '"';
314 if(*(big_buffer + x) == '\'') 331 if(*(big_buffer + x) == '\'')
315 term = '\''; 332 term = '\'';
316 if(term != '\n') 333 if(term != '\n')
317 x++; 334 x++;
318 335
319 int msg_len; 336 int msg_len;
320 for(msg_len = 0; *(big_buffer + x + msg_len) != term; msg_len++); 337 for(msg_len = 0; *(big_buffer + x + msg_len) != term; msg_len++);
321 *(big_buffer + x + msg_len) = '\0'; 338 *(big_buffer + x + msg_len) = '\0';
322 QString msg = big_buffer + x; 339 QString msg = big_buffer + x;
323 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(), 340 debug_msg(0, "%s:%d qmake_warning -- %s", fix_env_fn.latin1(),
324 line_count, msg.latin1()); 341 line_count, msg.latin1());
325 *(big_buffer + x + msg_len) = term; //put it back 342 *(big_buffer + x + msg_len) = term; //put it back
326 } 343 }
327 } 344 }
328 } else if(ui_file) { 345 } else if(ui_file) {
329 // skip whitespaces 346 // skip whitespaces
330 while(x < total_size_read && 347 while(x < total_size_read &&
331 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t')) 348 (*(big_buffer+x) == ' ' || *(big_buffer+x) == '\t'))
332 x++; 349 x++;
333 if(*(big_buffer + x) == '<') { 350 if(*(big_buffer + x) == '<') {
334 x++; 351 x++;
335 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) && 352 if(total_size_read >= x + 12 && !strncmp(big_buffer + x, "includehint", 11) &&
336 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) { 353 (*(big_buffer + x + 11) == ' ' || *(big_buffer + x + 11) == '>')) {
337 for(x += 12; *(big_buffer + x) != '>'; x++); 354 for(x += 12; *(big_buffer + x) != '>'; x++);
338 int inc_len = 0; 355 int inc_len = 0;
339 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); 356 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
340 *(big_buffer + x + inc_len) = '\0'; 357 *(big_buffer + x + inc_len) = '\0';
341 inc = big_buffer + x; 358 inc = big_buffer + x;
342 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) && 359 } else if(total_size_read >= x + 8 && !strncmp(big_buffer + x, "include", 7) &&
343 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) { 360 (*(big_buffer + x + 7) == ' ' || *(big_buffer + x + 7) == '>')) {
344 for(x += 8; *(big_buffer + x) != '>'; x++) { 361 for(x += 8; *(big_buffer + x) != '>'; x++) {
345 if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' && 362 if(total_size_read >= x + 9 && *(big_buffer + x) == 'i' &&
346 !strncmp(big_buffer + x, "impldecl", 8)) { 363 !strncmp(big_buffer + x, "impldecl", 8)) {
347 for(x += 8; *(big_buffer + x) != '='; x++); 364 for(x += 8; *(big_buffer + x) != '='; x++);
348 if(*(big_buffer + x) != '=') 365 if(*(big_buffer + x) != '=')
349 continue; 366 continue;
350 for(x++; *(big_buffer+x) == '\t' || *(big_buffer+x) == ' '; x++); 367 for(x++; *(big_buffer+x) == '\t' || *(big_buffer+x) == ' '; x++);
351 char quote = 0; 368 char quote = 0;
352 if(*(big_buffer+x) == '\'' || *(big_buffer+x) == '"') { 369 if(*(big_buffer+x) == '\'' || *(big_buffer+x) == '"') {
353 quote = *(big_buffer + x); 370 quote = *(big_buffer + x);
354 x++; 371 x++;
355 } 372 }
356 int val_len; 373 int val_len;
357 for(val_len = 0; TRUE; val_len++) { 374 for(val_len = 0; TRUE; val_len++) {
358 if(quote) { 375 if(quote) {
359 if(*(big_buffer+x+val_len) == quote) 376 if(*(big_buffer+x+val_len) == quote)
360 break; 377 break;
361 } else if(*(big_buffer + x + val_len) == '>' || 378 } else if(*(big_buffer + x + val_len) == '>' ||
362 *(big_buffer + x + val_len) == ' ') { 379 *(big_buffer + x + val_len) == ' ') {
363 break; 380 break;
364 } 381 }
365 } 382 }
366 char saved = *(big_buffer + x + val_len); 383 char saved = *(big_buffer + x + val_len);
367 *(big_buffer + x + val_len) = '\0'; 384 *(big_buffer + x + val_len) = '\0';
368 QString where = big_buffer + x; 385 QString where = big_buffer + x;
369 *(big_buffer + x + val_len) = saved; 386 *(big_buffer + x + val_len) = saved;
370 if(where == "in implementation") { 387 if(where == "in implementation") {
371 QString cpp = fn.left(fn.length() - Option::ui_ext.length()) + 388 QString cpp = fn.left(fn.length() - Option::ui_ext.length()) +
372 Option::cpp_ext.first(); 389 Option::cpp_ext.first();
373 outdeps = &findDependencies(cpp); 390 outdeps = &findDependencies(cpp);
374 } 391 }
375 } 392 }
376 } 393 }
377 int inc_len = 0; 394 int inc_len = 0;
378 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++); 395 for(x += 1 ; *(big_buffer + x + inc_len) != '<'; inc_len++);
379 *(big_buffer + x + inc_len) = '\0'; 396 *(big_buffer + x + inc_len) = '\0';
380 inc = big_buffer + x; 397 inc = big_buffer + x;
381 } 398 }
382 } 399 }
383 } 400 }
384 401
385 if(!inc.isEmpty()) { 402 if(!inc.isEmpty()) {
403 bool from_source_dir = TRUE;
386 debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(), 404 debug_msg(5, "%s:%d Found dependency to %s", fix_env_fn.latin1(),
387 line_count, inc.latin1()); 405 line_count, inc.latin1());
388 if(!project->isEmpty("SKIP_DEPENDS")) { 406 if(!project->isEmpty("SKIP_DEPENDS")) {
389 bool found = FALSE; 407 bool found = FALSE;
390 QStringList &nodeplist = project->values("SKIP_DEPENDS"); 408 QStringList &nodeplist = project->values("SKIP_DEPENDS");
391 for(QStringList::Iterator it = nodeplist.begin(); 409 for(QStringList::Iterator it = nodeplist.begin();
392 it != nodeplist.end(); ++it) { 410 it != nodeplist.end(); ++it) {
393 QRegExp regx((*it)); 411 QRegExp regx((*it));
394 if(regx.search(inc) != -1) { 412 if(regx.search(inc) != -1) {
395 found = TRUE; 413 found = TRUE;
396 break; 414 break;
397 } 415 }
398 } 416 }
399 if(found) 417 if(found)
400 continue; 418 continue;
401 } 419 }
402 420
403 QString fqn; 421 QString fqn;
404 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") && 422 if(project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH") &&
405 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) { 423 !stat(fix_env_fndir + inc, &fst) && !S_ISDIR(fst.st_mode)) {
406 fqn = fndir + inc; 424 fqn = fndir + inc;
425 goto handle_fqn;
407 } else { 426 } else {
408 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) || 427 if((Option::target_mode == Option::TARG_MAC9_MODE && inc.find(':')) ||
409 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') || 428 (Option::target_mode == Option::TARG_WIN_MODE && inc[1] != ':') ||
410 ((Option::target_mode == Option::TARG_UNIX_MODE || 429 ((Option::target_mode == Option::TARG_UNIX_MODE ||
411 Option::target_mode == Option::TARG_QNX6_MODE || 430 Option::target_mode == Option::TARG_QNX6_MODE ||
412 Option::target_mode == Option::TARG_MACX_MODE) && 431 Option::target_mode == Option::TARG_MACX_MODE) &&
413 inc[0] != '/')) { 432 inc[0] != '/')) {
414 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { 433 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
415 if(!stat(mdd->local_dir + QDir::separator() + inc, &fst) && 434 if(!stat(mdd->local_dir + QDir::separator() + inc, &fst) &&
416 !S_ISDIR(fst.st_mode)) { 435 !S_ISDIR(fst.st_mode)) {
417 fqn = mdd->real_dir + QDir::separator() + inc; 436 fqn = mdd->real_dir + QDir::separator() + inc;
418 break; 437 goto handle_fqn;
419 } 438 }
420 } 439 }
421 } 440 }
422 } 441 }
423 if(fqn.isEmpty()) { 442 if(fqn.isEmpty() && Option::mkfile::do_dep_heuristics) {
424 //these are some hacky heuristics it will try to do on an include 443 //these are some hacky heuristics it will try to do on an include
425 //however these can be turned off at runtime, I'm not sure how 444 //however these can be turned off at runtime, I'm not sure how
426 //reliable these will be, most likely when problems arise turn it off 445 //reliable these will be, most likely when problems arise turn it off
427 //and see if they go away.. 446 //and see if they go away..
428 if(Option::mkfile::do_dep_heuristics && depHeuristics.contains(inc)) { 447 if(depHeuristics.contains(inc)) {
429 fqn = depHeuristics[inc]; 448 fqn = depHeuristics[inc];
430 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics.. 449 } else if(Option::mkfile::do_dep_heuristics) { //some heuristics..
431 //is it a file from a .ui? 450 //is it a file from a .ui?
432 QString inc_file = inc.section(Option::dir_sep, -1); 451 QString inc_file = inc.section(Option::dir_sep, -1);
433 int extn = inc_file.findRev('.'); 452 int extn = inc_file.findRev('.');
434 if(extn != -1 && 453 if(extn != -1 &&
435 (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() || 454 (inc_file.right(inc_file.length()-extn) == Option::cpp_ext.first() ||
436 inc_file.right(inc_file.length()-extn) == Option::h_ext.first())) { 455 inc_file.right(inc_file.length()-extn) == Option::h_ext.first())) {
437 QString uip = inc_file.left(extn) + Option::ui_ext; 456 QString uip = inc_file.left(extn) + Option::ui_ext;
438 QStringList uil = project->variables()["FORMS"]; 457 QStringList uil = project->variables()["FORMS"];
439 for(QStringList::Iterator it = uil.begin(); it != uil.end(); ++it) { 458 for(QStringList::Iterator it = uil.begin(); it != uil.end(); ++it) {
440 if((*it).section(Option::dir_sep, -1) == uip) { 459 if((*it).section(Option::dir_sep, -1) == uip) {
441 if(!project->isEmpty("UI_DIR")) 460 if(!project->isEmpty("UI_DIR"))
442 fqn = project->first("UI_DIR"); 461 fqn = project->first("UI_DIR");
443 else if(!project->isEmpty("UI_HEADERS_DIR")) 462 else if(!project->isEmpty("UI_HEADERS_DIR"))
444 fqn = project->first("UI_HEADERS_DIR"); 463 fqn = project->first("UI_HEADERS_DIR");
445 else 464 else
446 fqn = (*it).section(Option::dir_sep, 0, -2); 465 fqn = (*it).section(Option::dir_sep, 0, -2);
447 if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep)) 466 if(!fqn.isEmpty() && !fqn.endsWith(Option::dir_sep))
448 fqn += Option::dir_sep; 467 fqn += Option::dir_sep;
449 fqn += inc_file; 468 fqn += inc_file;
450 break; 469 from_source_dir = FALSE; //uics go in the output_dir (so don't fix them)
470 fqn = fileFixify(fqn, QDir::currentDirPath(), Option::output_dir);
471 goto handle_fqn;
472 }
473 }
474 }
475 if(project->isActiveConfig("lex_included")) { //is this the lex file?
476 QString rhs = Option::lex_mod + Option::cpp_ext.first();
477 if(inc.endsWith(rhs)) {
478 QString lhs = inc.left(inc.length() - rhs.length()) + Option::lex_ext;
479 QStringList ll = project->variables()["LEXSOURCES"];
480 for(QStringList::Iterator it = ll.begin(); it != ll.end(); ++it) {
481 QString s = (*it), d;
482 int slsh = s.findRev(Option::dir_sep);
483 if(slsh != -1) {
484 d = s.left(slsh + 1);
485 s = s.right(s.length() - slsh - 1);
486 }
487 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
488 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
489 if(s == lhs) {
490 fqn = d + inc;
491 goto handle_fqn;
492 }
451 } 493 }
452 } 494 }
453 } 495 }
454 if(fqn.isEmpty()) { //is it from a .y? 496 { //is it from a .y?
455 QString rhs = Option::yacc_mod + Option::h_ext.first(); 497 QString rhs = Option::yacc_mod + Option::h_ext.first();
456 if(inc.endsWith(rhs)) { 498 if(inc.endsWith(rhs)) {
457 QString lhs = inc.left(inc.length() - rhs.length()) + Option::yacc_ext; 499 QString lhs = inc.left(inc.length() - rhs.length()) + Option::yacc_ext;
458 QStringList yl = project->variables()["YACCSOURCES"]; 500 QStringList yl = project->variables()["YACCSOURCES"];
459 for(QStringList::Iterator it = yl.begin(); it != yl.end(); ++it) { 501 for(QStringList::Iterator it = yl.begin(); it != yl.end(); ++it) {
460 QString s = (*it), d; 502 QString s = (*it), d;
461 int slsh = s.findRev(Option::dir_sep); 503 int slsh = s.findRev(Option::dir_sep);
462 if(slsh != -1) { 504 if(slsh != -1) {
463 d = s.left(slsh + 1); 505 d = s.left(slsh + 1);
464 s = s.right(s.length() - slsh - 1); 506 s = s.right(s.length() - slsh - 1);
465 } 507 }
466 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 508 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
467 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH"); 509 d = project->first("QMAKE_ABSOLUTE_SOURCE_PATH");
468 if(s == lhs) { 510 if(s == lhs) {
469 fqn = d + inc; 511 fqn = d + inc;
470 break; 512 goto handle_fqn;
513 }
514 }
515 }
516 }
517 if(mocAware() && //is it a moc file?
518 (inc.endsWith(Option::cpp_ext.first()) || inc.endsWith(Option::moc_ext))) {
519 QString mocs[] = { QString("_HDRMOC"), QString("_SRCMOC"), QString::null };
520 for(int moc = 0; !mocs[moc].isNull(); moc++) {
521 QStringList &l = project->variables()[mocs[moc]];
522 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
523 QString file = Option::fixPathToTargetOS((*it));
524 if(file.section(Option::dir_sep, -(inc.contains('/')+1)) == inc) {
525 fqn = (*it);
526 if(mocs[moc] == "_HDRMOC") {
527 //Since it is include, no need to link it in as well
528 project->variables()["_SRCMOC"].append((*it));
529 l.remove(it);
530 } else if(!findMocSource(fqn).endsWith(fn)) {
531 /* Not really a very good test, but this will at least avoid
532 confusion if it really does happen (since tmake/qmake
533 previously didn't even allow this the test is mostly accurate) */
534 warn_msg(WarnLogic,
535 "Found potential multiple MOC include %s (%s) in '%s'",
536 inc.latin1(), fqn.latin1(), fix_env_fn.latin1());
537 }
538 from_source_dir = FALSE; //mocs go in the output_dir (so don't fix them)
539 goto handle_fqn;
471 } 540 }
472 } 541 }
473 } 542 }
474 } 543 }
475 depHeuristics.insert(inc, fqn); 544 depHeuristics.insert(inc, fqn);
476 } 545 }
477 if(!Option::mkfile::do_dep_heuristics || fqn.isEmpty()) //I give up
478 continue;
479 } 546 }
480 547 handle_fqn:
481 fqn = fileFixify(Option::fixPathToTargetOS(fqn, FALSE)); 548 if(fqn.isEmpty()) //I give up
482 debug_msg(4, "Resolved dependancy of %s to %s", inc.latin1(), fqn.latin1()); 549 continue;
550 fqn = Option::fixPathToTargetOS(fqn, FALSE);
551 if(from_source_dir)
552 fqn = fileFixify(fqn);
553 debug_msg(4, "Resolved dependency of %s to %s", inc.latin1(), fqn.latin1());
483 if(outdeps && outdeps->findIndex(fqn) == -1) 554 if(outdeps && outdeps->findIndex(fqn) == -1)
484 outdeps->append(fqn); 555 outdeps->append(fqn);
485 } 556 }
486 //read past new line now.. 557 //read past new line now..
487 for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++); 558 for( ; x < total_size_read && (*(big_buffer + x) != '\n'); x++);
488 line_count++; 559 line_count++;
489 } 560 }
490 561
491 if(recurse) { 562 if(recurse) {
492 for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) { 563 for(QStringList::Iterator fnit = fndeps.begin(); fnit != fndeps.end(); ++fnit) {
493 generateDependencies(dirs, (*fnit), recurse); 564 generateDependencies(dirs, (*fnit), recurse);
494 QStringList &deplist = findDependencies((*fnit)); 565 QStringList &deplist = findDependencies((*fnit));
495 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it) 566 for(QStringList::Iterator it = deplist.begin(); it != deplist.end(); ++it)
496 if(fndeps.findIndex((*it)) == -1) 567 if(fndeps.findIndex((*it)) == -1)
497 fndeps.append((*it)); 568 fndeps.append((*it));
498 } 569 }
499 } 570 }
500 debug_msg(2, "Dependancies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1()); 571 debug_msg(2, "Dependencies: %s -> %s", fn.latin1(), fndeps.join(" :: ").latin1());
501 return TRUE; 572 return TRUE;
502} 573}
503 574
504void 575void
505MakefileGenerator::initOutPaths() 576MakefileGenerator::initOutPaths()
506{ 577{
507 if(init_opath_already) 578 if(init_opath_already)
508 return; 579 return;
509 init_opath_already = TRUE; 580 init_opath_already = TRUE;
510 QMap<QString, QStringList> &v = project->variables(); 581 QMap<QString, QStringList> &v = project->variables();
511 if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) { 582 if(!v.contains("QMAKE_ABSOLUTE_SOURCE_PATH")) {
512 if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() && 583 if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty() &&
513 v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) { 584 v.contains("QMAKE_ABSOLUTE_SOURCE_ROOT")) {
514 QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first(); 585 QString root = v["QMAKE_ABSOLUTE_SOURCE_ROOT"].first();
515 root = Option::fixPathToTargetOS( root ); 586 root = Option::fixPathToTargetOS( root );
516 if(!root.isEmpty()) { 587 if(!root.isEmpty()) {
517 QFileInfo fi(Option::mkfile::cachefile); 588 QFileInfo fi(Option::mkfile::cachefile);
518 if(!fi.convertToAbs()) { 589 if(!fi.convertToAbs()) {
519 QString cache_r = fi.dirPath(), pwd = Option::output_dir; 590 QString cache_r = fi.dirPath(), pwd = Option::output_dir;
520 if ( pwd.startsWith(cache_r) && !pwd.startsWith(root) ) { 591 if ( pwd.startsWith(cache_r) && !pwd.startsWith(root) ) {
521 pwd = Option::fixPathToTargetOS(root + pwd.mid(cache_r.length())); 592 pwd = Option::fixPathToTargetOS(root + pwd.mid(cache_r.length()));
522 if(QFile::exists(pwd)) 593 if(QFile::exists(pwd))
523 v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", pwd); 594 v.insert("QMAKE_ABSOLUTE_SOURCE_PATH", pwd);
524 } 595 }
@@ -592,64 +663,68 @@ MakefileGenerator::initOutPaths()
592 } 663 }
593 QDir::current().cd( currentDir ); 664 QDir::current().cd( currentDir );
594} 665}
595 666
596void 667void
597MakefileGenerator::init() 668MakefileGenerator::init()
598{ 669{
599 initOutPaths(); 670 initOutPaths();
600 if(init_already) 671 if(init_already)
601 return; 672 return;
602 init_already = TRUE; 673 init_already = TRUE;
603 674
604 QMap<QString, QStringList> &v = project->variables(); 675 QMap<QString, QStringList> &v = project->variables();
605 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"), 676 QString paths[] = { QString("SOURCES"), QString("FORMS"), QString("YACCSOURCES"), QString("INCLUDEPATH"),
606 QString("HEADERS"), QString("HEADERS_ORIG"), 677 QString("HEADERS"), QString("HEADERS_ORIG"),
607 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null }; 678 QString("LEXSOURCES"), QString("QMAKE_INTERNAL_INCLUDED_FILES"), QString::null };
608 for(int y = 0; paths[y] != QString::null; y++) { 679 for(int y = 0; paths[y] != QString::null; y++) {
609 QStringList &l = v[paths[y]]; 680 QStringList &l = v[paths[y]];
610 if(!l.isEmpty()) 681 if(!l.isEmpty())
611 l = fileFixify(l); 682 l = fileFixify(l);
612 } 683 }
613 684
614 /* get deps and mocables */ 685 /* get deps and mocables */
615 QDict<void> cache_found_files; 686 QDict<void> cache_found_files;
616 QString cache_file(Option::output_dir + QDir::separator() + ".qmake.internal.cache"); 687 QString cache_file(".qmake.internal.cache");
688 if(!project->isEmpty("QMAKE_INTERNAL_CACHE_FILE"))
689 cache_file = Option::fixPathToLocalOS(project->first("QMAKE_INTERNAL_CACHE_FILE"));
690 if(cache_file.find(QDir::separator()) == -1) //guess they know what they are doing..
691 cache_file.prepend(Option::output_dir + QDir::separator());
617 if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || 692 if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
618 Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) { 693 Option::mkfile::do_deps || Option::mkfile::do_mocs) && !noIO()) {
619 QPtrList<MakefileDependDir> deplist; 694 QPtrList<MakefileDependDir> deplist;
620 deplist.setAutoDelete(TRUE); 695 deplist.setAutoDelete(TRUE);
621 if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || Option::mkfile::do_deps) && 696 if((Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT || Option::mkfile::do_deps) &&
622 doDepends()) { 697 doDepends()) {
623 QStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"]; 698 QStringList incDirs = v["DEPENDPATH"] + v["QMAKE_ABSOLUTE_SOURCE_PATH"];
624 if(project->isActiveConfig("depend_includepath")) 699 if(project->isActiveConfig("depend_includepath"))
625 incDirs += v["INCLUDEPATH"]; 700 incDirs += v["INCLUDEPATH"];
626 for(QStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) { 701 for(QStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it) {
627 QString r = (*it), l = Option::fixPathToLocalOS((*it)); 702 QString r = (*it), l = Option::fixPathToLocalOS((*it));
628 deplist.append(new MakefileDependDir(r.replace("\"",""), 703 deplist.append(new MakefileDependDir(r.replace("\"",""),
629 l.replace("\"",""))); 704 l.replace("\"","")));
630 } 705 }
631 debug_msg(1, "Dependancy Directories: %s", incDirs.join(" :: ").latin1()); 706 debug_msg(1, "Dependency Directories: %s", incDirs.join(" :: ").latin1());
632 if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) { 707 if(Option::output.name() != "-" && project->isActiveConfig("qmake_cache")) {
633 QFile cachef(cache_file); 708 QFile cachef(cache_file);
634 if(cachef.open(IO_ReadOnly | IO_Translate)) { 709 if(cachef.open(IO_ReadOnly | IO_Translate)) {
635 QFileInfo cachefi(cache_file); 710 QFileInfo cachefi(cache_file);
636 debug_msg(2, "Trying internal cache information: %s", cache_file.latin1()); 711 debug_msg(2, "Trying internal cache information: %s", cache_file.latin1());
637 QTextStream cachet(&cachef); 712 QTextStream cachet(&cachef);
638 QString line, file; 713 QString line, file;
639 enum { CacheInfo, CacheDepend, CacheMoc } state = CacheInfo; 714 enum { CacheInfo, CacheDepend, CacheMoc } state = CacheInfo;
640 while (!cachet.eof()) { 715 while (!cachet.eof()) {
641 line = cachet.readLine().stripWhiteSpace(); 716 line = cachet.readLine().stripWhiteSpace();
642 int sep = line.find('='); 717 int sep = line.find('=');
643 if(line == "[depend]") { 718 if(line == "[depend]") {
644 state = CacheDepend; 719 state = CacheDepend;
645 } else if(line == "[mocable]") { 720 } else if(line == "[mocable]") {
646 state = CacheMoc; 721 state = CacheMoc;
647 } else if(line == "[check]") { 722 } else if(line == "[check]") {
648 state = CacheInfo; 723 state = CacheInfo;
649 } else if(!line.isEmpty() && sep != -1) { 724 } else if(!line.isEmpty() && sep != -1) {
650 file = line.left(sep).stripWhiteSpace(); 725 file = line.left(sep).stripWhiteSpace();
651 line = line.right(line.length() - sep - 1).stripWhiteSpace(); 726 line = line.right(line.length() - sep - 1).stripWhiteSpace();
652 if(state == CacheInfo) { 727 if(state == CacheInfo) {
653 if(file == "QMAKE_CACHE_VERSION") { 728 if(file == "QMAKE_CACHE_VERSION") {
654 if(line != qmake_version()) 729 if(line != qmake_version())
655 break; 730 break;
@@ -662,49 +737,49 @@ MakefileGenerator::init()
662 bool found = (bool)cache_found_files[file]; 737 bool found = (bool)cache_found_files[file];
663 QStringList files = QStringList::split(" ", line); 738 QStringList files = QStringList::split(" ", line);
664 if(!found) { 739 if(!found) {
665 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir)); 740 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
666 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) { 741 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
667 cache_found_files.insert(file, (void *)1); 742 cache_found_files.insert(file, (void *)1);
668 found = TRUE; 743 found = TRUE;
669 } 744 }
670 } 745 }
671 if(found) { 746 if(found) {
672 for(QStringList::Iterator dep_it = files.begin(); 747 for(QStringList::Iterator dep_it = files.begin();
673 dep_it != files.end(); ++dep_it) { 748 dep_it != files.end(); ++dep_it) {
674 if(!cache_found_files[(*dep_it)]) { 749 if(!cache_found_files[(*dep_it)]) {
675 QFileInfo fi(fileFixify((*dep_it), QDir::currentDirPath(), Option::output_dir)); 750 QFileInfo fi(fileFixify((*dep_it), QDir::currentDirPath(), Option::output_dir));
676 if(fi.exists() && 751 if(fi.exists() &&
677 fi.lastModified() < cachefi.lastModified()) { 752 fi.lastModified() < cachefi.lastModified()) {
678 cache_found_files.insert((*dep_it), (void *)1); 753 cache_found_files.insert((*dep_it), (void *)1);
679 } else { 754 } else {
680 found = FALSE; 755 found = FALSE;
681 break; 756 break;
682 } 757 }
683 } 758 }
684 } 759 }
685 if(found) { 760 if(found) {
686 debug_msg(2, "Dependancies (cached): %s -> %s", file.latin1(), 761 debug_msg(2, "Dependencies (cached): %s -> %s", file.latin1(),
687 files.join(" :: ").latin1()); 762 files.join(" :: ").latin1());
688 findDependencies(file) = files; 763 findDependencies(file) = files;
689 } 764 }
690 } 765 }
691 } else { 766 } else {
692 void *found = cache_found_files[file]; 767 void *found = cache_found_files[file];
693 if(found != (void *)2) { 768 if(found != (void *)2) {
694 if(found) { 769 if(found) {
695 cache_found_files.replace(file, (void *)2); 770 cache_found_files.replace(file, (void *)2);
696 } else { 771 } else {
697 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir)); 772 QFileInfo fi(fileFixify(file, QDir::currentDirPath(), Option::output_dir));
698 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) { 773 if(fi.exists() && fi.lastModified() < cachefi.lastModified()) {
699 cache_found_files.insert(file, (void *)2); 774 cache_found_files.insert(file, (void *)2);
700 found = (void*)1; 775 found = (void*)1;
701 } 776 }
702 } 777 }
703 } 778 }
704 if(found && line != "*qmake_ignore*") { 779 if(found && line != "*qmake_ignore*") {
705 int ext_len = file.length() - file.findRev('.'); 780 int ext_len = file.length() - file.findRev('.');
706 bool cpp_ext = FALSE; 781 bool cpp_ext = FALSE;
707 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 782 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
708 cppit != Option::cpp_ext.end(); ++cppit) { 783 cppit != Option::cpp_ext.end(); ++cppit) {
709 if((cpp_ext = (file.right(ext_len) == (*cppit)))) 784 if((cpp_ext = (file.right(ext_len) == (*cppit))))
710 break; 785 break;
@@ -722,163 +797,174 @@ MakefileGenerator::init()
722 } 797 }
723 debug_msg(2, "Mocgen (cached): %s -> %s", file.latin1(), 798 debug_msg(2, "Mocgen (cached): %s -> %s", file.latin1(),
724 line.latin1()); 799 line.latin1());
725 mocablesToMOC[file] = line; 800 mocablesToMOC[file] = line;
726 mocablesFromMOC[line] = file; 801 mocablesFromMOC[line] = file;
727 } 802 }
728 } 803 }
729 } 804 }
730 } 805 }
731 cachef.close(); 806 cachef.close();
732 } 807 }
733 } 808 }
734 } 809 }
735 if(!noIO()) { 810 if(!noIO()) {
736 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"), 811 QString sources[] = { QString("OBJECTS"), QString("LEXSOURCES"), QString("YACCSOURCES"),
737 QString("HEADERS"), QString("SOURCES"), QString("FORMS"), 812 QString("HEADERS"), QString("SOURCES"), QString("FORMS"),
738 QString::null }; 813 QString::null };
739 depHeuristics.clear(); 814 depHeuristics.clear();
740 bool write_cache = FALSE, read_cache = QFile::exists(cache_file); 815 bool write_cache = FALSE, read_cache = QFile::exists(cache_file);
741 for(int x = 0; sources[x] != QString::null; x++) { 816 for(int x = 0; sources[x] != QString::null; x++) {
742 QStringList vpath, &l = v[sources[x]]; 817 QStringList vpath, &l = v[sources[x]];
743 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 818 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
744 if(!(*val_it).isEmpty()) { 819 if(!(*val_it).isEmpty()) {
745 QString file = Option::fixPathToLocalOS((*val_it)); 820 QString file = Option::fixPathToLocalOS((*val_it));
821 QStringList file_list(file);
746 if(!QFile::exists(file)) { 822 if(!QFile::exists(file)) {
747 bool found = FALSE; 823 bool found = FALSE;
748 if(QDir::isRelativePath(file)) { 824 if(QDir::isRelativePath(file)) {
749 if(vpath.isEmpty()) 825 if(vpath.isEmpty())
750 vpath = v["VPATH_" + sources[x]] + v["VPATH"] + 826 vpath = v["VPATH_" + sources[x]] + v["VPATH"] +
751 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"]; 827 v["QMAKE_ABSOLUTE_SOURCE_PATH"] + v["DEPENDPATH"];
752 828
753 for(QStringList::Iterator vpath_it = vpath.begin(); 829 for(QStringList::Iterator vpath_it = vpath.begin();
754 vpath_it != vpath.end(); ++vpath_it) { 830 vpath_it != vpath.end(); ++vpath_it) {
755 QString real_dir = Option::fixPathToLocalOS((*vpath_it)); 831 QString real_dir = Option::fixPathToLocalOS((*vpath_it));
756 if(QFile::exists(real_dir + QDir::separator() + (*val_it))) { 832 if(QFile::exists(real_dir + QDir::separator() + (*val_it))) {
757 QString dir = (*vpath_it); 833 QString dir = (*vpath_it);
758 if(dir.right(Option::dir_sep.length()) != Option::dir_sep) 834 if(dir.right(Option::dir_sep.length()) != Option::dir_sep)
759 dir += Option::dir_sep; 835 dir += Option::dir_sep;
760 (*val_it) = fileFixify(dir + (*val_it)); 836 (*val_it) = fileFixify(dir + (*val_it));
761 found = TRUE; 837 found = TRUE;
762 debug_msg(1, "Found file through vpath %s -> %s", 838 debug_msg(1, "Found file through vpath %s -> %s",
763 file.latin1(), (*val_it).latin1()); 839 file.latin1(), (*val_it).latin1());
764 break; 840 break;
765 } 841 }
766 } 842 }
767 } 843 }
768 if(!found) { 844 if(!found) {
769 QString dir, regex = (*val_it), real_dir; 845 QString dir, regex = (*val_it), real_dir;
770 if(regex.findRev(Option::dir_sep) != -1) { 846 if(regex.findRev(Option::dir_sep) != -1) {
771 dir = regex.left(regex.findRev(Option::dir_sep) + 1); 847 dir = regex.left(regex.findRev(Option::dir_sep) + 1);
772 real_dir = fileFixify(Option::fixPathToLocalOS(dir), 848 real_dir = fileFixify(Option::fixPathToLocalOS(dir),
773 QDir::currentDirPath(), Option::output_dir); 849 QDir::currentDirPath(), Option::output_dir);
774 regex = regex.right(regex.length() - dir.length()); 850 regex = regex.right(regex.length() - dir.length());
775 } 851 }
776 if(real_dir.isEmpty() || QFile::exists(real_dir)) { 852 if(real_dir.isEmpty() || QFile::exists(real_dir)) {
777 QDir d(real_dir, regex); 853 QDir d(real_dir, regex);
778 if(!d.count()) { 854 if(!d.count()) {
779 debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", 855 debug_msg(1, "%s:%d Failure to find %s in vpath (%s)",
780 __FILE__, __LINE__, 856 __FILE__, __LINE__,
781 (*val_it).latin1(), vpath.join("::").latin1()); 857 (*val_it).latin1(), vpath.join("::").latin1());
782 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); 858 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
783 continue; 859 continue;
784 } else { 860 } else {
785 (*val_it) = dir + d[0]; 861 file_list.clear();
786 for(int i = 1; i < (int)d.count(); i++) 862 for(int i = 0; i < (int)d.count(); i++) {
787 l.insert(val_it, dir + d[i]); 863 file_list.append(dir + d[i]);
864 if(i == (int)d.count() - 1)
865 (*val_it) = dir + d[i];
866 else
867 l.insert(val_it, dir + d[i]);
868 }
788 } 869 }
789 } else { 870 } else {
790 debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.", 871 debug_msg(1, "%s:%d Cannot match %s%c%s, as %s does not exist.",
791 __FILE__, __LINE__, 872 __FILE__, __LINE__,
792 real_dir.latin1(), QDir::separator(), regex.latin1(), 873 real_dir.latin1(), QDir::separator(), regex.latin1(),
793 real_dir.latin1()); 874 real_dir.latin1());
794 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1()); 875 warn_msg(WarnLogic, "Failure to find: %s", (*val_it).latin1());
795 } 876 }
796 } 877 }
797 } 878 }
798 879 for(QStringList::Iterator file_it = file_list.begin();
799 QString val_file = fileFixify((*val_it)); 880 file_it != file_list.end(); ++file_it) {
800 bool found_cache_moc = FALSE, found_cache_dep = FALSE; 881 QString file_list_file = fileFixify((*file_it));
801 if(read_cache && Option::output.name() != "-" && 882 bool found_cache_moc = FALSE, found_cache_dep = FALSE;
802 project->isActiveConfig("qmake_cache")) { 883 if(read_cache && Option::output.name() != "-" &&
803 if(!findDependencies(val_file).isEmpty()) 884 project->isActiveConfig("qmake_cache")) {
804 found_cache_dep = TRUE; 885 if(!findDependencies(file_list_file).isEmpty())
805 if(cache_found_files[(*val_it)] == (void *)2) 886 found_cache_dep = TRUE;
806 found_cache_moc = TRUE; 887 if(cache_found_files[(*file_it)] == (void *)2)
807 if(!found_cache_moc || !found_cache_dep) 888 found_cache_moc = TRUE;
808 write_cache = TRUE; 889 if(!found_cache_moc || !found_cache_dep)
809 } 890 write_cache = TRUE;
810 if(!found_cache_dep && sources[x] != "OBJECTS") { 891 }
811 debug_msg(5, "Looking for dependancies for %s", (*val_it).latin1()); 892 /* Do moc before dependency checking since some includes can come from
812 generateDependencies(deplist, (*val_it), doDepends()); 893 moc_*.cpp files */
813 } 894 if(found_cache_moc) {
814 if(found_cache_moc) { 895 QString moc = findMocDestination(file_list_file);
815 QString moc = findMocDestination(val_file); 896 if(!moc.isEmpty()) {
816 if(!moc.isEmpty()) { 897 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
817 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 898 cppit != Option::cpp_ext.end(); ++cppit) {
818 cppit != Option::cpp_ext.end(); ++cppit) { 899 if(file_list_file.endsWith((*cppit))) {
819 if(val_file.endsWith((*cppit))) { 900 QStringList &deps = findDependencies(file_list_file);
820 QStringList &deps = findDependencies(val_file); 901 if(!deps.contains(moc))
821 if(!deps.contains(moc)) 902 deps.append(moc);
822 deps.append(moc); 903 break;
823 break; 904 }
824 } 905 }
825 } 906 }
907 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
908 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
909 Option::mkfile::do_mocs)) {
910 generateMocList((*file_it));
911 }
912 if(!found_cache_dep && sources[x] != "OBJECTS") {
913 debug_msg(5, "Looking for dependencies for %s", (*file_it).latin1());
914 generateDependencies(deplist, (*file_it), doDepends());
826 } 915 }
827 } else if(mocAware() && (sources[x] == "SOURCES" || sources[x] == "HEADERS") &&
828 (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT ||
829 Option::mkfile::do_mocs)) {
830 generateMocList((*val_it));
831 } 916 }
832 } 917 }
833 } 918 }
834 } 919 }
835 if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) { 920 if(project->isActiveConfig("qmake_cache") && (write_cache || !read_cache)) {
836 QFile cachef(cache_file); 921 QFile cachef(cache_file);
837 if(cachef.open(IO_WriteOnly | IO_Translate)) { 922 if(cachef.open(IO_WriteOnly | IO_Translate)) {
838 debug_msg(2, "Writing internal cache information: %s", cache_file.latin1()); 923 debug_msg(2, "Writing internal cache information: %s", cache_file.latin1());
839 QTextStream cachet(&cachef); 924 QTextStream cachet(&cachef);
840 cachet << "[check]" << "\n" 925 cachet << "[check]" << "\n"
841 << "QMAKE_CACHE_VERSION = " << qmake_version() << "\n" 926 << "QMAKE_CACHE_VERSION = " << qmake_version() << "\n"
842 << "QMAKE_ABSOLUTE_SOURCE_PATH = " << var("QMAKE_ABSOLUTE_SOURCE_PATH") << "\n" 927 << "QMAKE_ABSOLUTE_SOURCE_PATH = " << var("QMAKE_ABSOLUTE_SOURCE_PATH") << "\n"
843 << "MOC_DIR = " << var("MOC_DIR") << "\n" 928 << "MOC_DIR = " << var("MOC_DIR") << "\n"
844 << "UI_DIR = " << var("UI_DIR") << "\n" 929 << "UI_DIR = " << var("UI_DIR") << "\n"
845 << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n" 930 << "UI_HEADERS_DIR = " << var("UI_HEADERS_DIR") << "\n"
846 << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n"; 931 << "UI_SOURCES_DIR = " << var("UI_SOURCES_DIR") << "\n";
847 cachet << "[depend]" << endl; 932 cachet << "[depend]" << endl;
848 for(QMap<QString, QStringList>::Iterator it = depends.begin(); 933 for(QMap<QString, QStringList>::Iterator it = depends.begin();
849 it != depends.end(); ++it) 934 it != depends.end(); ++it)
850 cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl; 935 cachet << depKeyMap[it.key()] << " = " << it.data().join(" ") << endl;
851 cachet << "[mocable]" << endl; 936 cachet << "[mocable]" << endl;
852 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null }; 937 QString mc, moc_sources[] = { QString("HEADERS"), QString("SOURCES"), QString::null };
853 for(int x = 0; moc_sources[x] != QString::null; x++) { 938 for(int x = 0; moc_sources[x] != QString::null; x++) {
854 QStringList &l = v[moc_sources[x]]; 939 QStringList &l = v[moc_sources[x]];
855 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 940 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
856 if(!(*val_it).isEmpty()) { 941 QString f = fileFixify((*val_it));
857 mc = mocablesToMOC[(*val_it)]; 942 if(!f.isEmpty()) {
943 mc = mocablesToMOC[f];
858 if(mc.isEmpty()) 944 if(mc.isEmpty())
859 mc = "*qmake_ignore*"; 945 mc = "*qmake_ignore*";
860 cachet << (*val_it) << " = " << mc << endl; 946 cachet << f << " = " << mc << endl;
861 } 947 }
862 } 948 }
863 } 949 }
864 cachef.close(); 950 cachef.close();
865 } 951 }
866 } 952 }
867 } 953 }
868 } 954 }
869 v["OBJECTS"] = createObjectList("SOURCES") + v["OBJECTS"]; // init variables 955 v["OBJECTS"] = createObjectList("SOURCES") + v["OBJECTS"]; // init variables
870 956
871 //lex files 957 //lex files
872 { 958 {
873 QStringList &impls = v["LEXIMPLS"]; 959 QStringList &impls = v["LEXIMPLS"];
874 QStringList &l = v["LEXSOURCES"]; 960 QStringList &l = v["LEXSOURCES"];
875 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 961 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
876 QString dir; 962 QString dir;
877 QFileInfo fi((*it)); 963 QFileInfo fi((*it));
878 if(fi.dirPath() != ".") 964 if(fi.dirPath() != ".")
879 dir = fi.dirPath() + Option::dir_sep; 965 dir = fi.dirPath() + Option::dir_sep;
880 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); 966 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
881 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 967 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
882 dir += Option::dir_sep; 968 dir += Option::dir_sep;
883 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 969 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
884 logicWarn(impl, "SOURCES"); 970 logicWarn(impl, "SOURCES");
@@ -925,207 +1011,223 @@ MakefileGenerator::init()
925 QStringList &yaccdeps = findDependencies((*it)); 1011 QStringList &yaccdeps = findDependencies((*it));
926 for(QStringList::ConstIterator d = yaccdeps.begin(); d != yaccdeps.end(); ++d) { 1012 for(QStringList::ConstIterator d = yaccdeps.begin(); d != yaccdeps.end(); ++d) {
927 if(!impldeps.contains(*d)) 1013 if(!impldeps.contains(*d))
928 impldeps.append(*d); 1014 impldeps.append(*d);
929 } 1015 }
930 if( project->isActiveConfig("lex_included")) { 1016 if( project->isActiveConfig("lex_included")) {
931 // is there a matching lex file ? Transfer its dependencies. 1017 // is there a matching lex file ? Transfer its dependencies.
932 QString lexsrc = fi.baseName(TRUE) + Option::lex_ext; 1018 QString lexsrc = fi.baseName(TRUE) + Option::lex_ext;
933 if(fi.dirPath() != ".") 1019 if(fi.dirPath() != ".")
934 lexsrc.prepend(fi.dirPath() + Option::dir_sep); 1020 lexsrc.prepend(fi.dirPath() + Option::dir_sep);
935 if(v["LEXSOURCES"].findIndex(lexsrc) != -1) { 1021 if(v["LEXSOURCES"].findIndex(lexsrc) != -1) {
936 QString trg = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 1022 QString trg = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
937 impldeps.append(trg); 1023 impldeps.append(trg);
938 impldeps += findDependencies(lexsrc); 1024 impldeps += findDependencies(lexsrc);
939 depends[lexsrc].clear(); 1025 depends[lexsrc].clear();
940 } 1026 }
941 } 1027 }
942 yaccdeps.clear(); 1028 yaccdeps.clear();
943 } 1029 }
944 v["OBJECTS"] += (v["YACCOBJECTS"] = createObjectList("YACCIMPLS")); 1030 v["OBJECTS"] += (v["YACCOBJECTS"] = createObjectList("YACCIMPLS"));
945 } 1031 }
946 1032
947 //UI files 1033 //UI files
948 { 1034 {
1035 QStringList &includepath = project->variables()["INCLUDEPATH"];
949 if(!project->isEmpty("UI_DIR")) 1036 if(!project->isEmpty("UI_DIR"))
950 project->variables()["INCLUDEPATH"].append(project->first("UI_DIR")); 1037 includepath.append(project->first("UI_DIR"));
951 else if(!project->isEmpty("UI_HEADERS_DIR")) 1038 else if(!project->isEmpty("UI_HEADERS_DIR"))
952 project->variables()["INCLUDEPATH"].append(project->first("UI_HEADERS_DIR")); 1039 includepath.append(project->first("UI_HEADERS_DIR"));
953 QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"]; 1040 QStringList &decls = v["UICDECLS"], &impls = v["UICIMPLS"];
954 QStringList &l = v["FORMS"]; 1041 QStringList &l = v["FORMS"];
955 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1042 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
956 QString impl, decl; 1043 QString impl, decl;
957 QFileInfo fi(Option::fixPathToLocalOS((*it))); 1044 QFileInfo fi(Option::fixPathToLocalOS((*it)));
958 if ( !project->isEmpty("UI_DIR") ) { 1045 if ( !project->isEmpty("UI_DIR") ) {
959 impl = decl = project->first("UI_DIR"); 1046 impl = decl = project->first("UI_DIR");
960 QString d = fi.dirPath(); 1047 QString d = fi.dirPath();
961 if( d == ".") 1048 if( d == ".")
962 d = QDir::currentDirPath(); 1049 d = QDir::currentDirPath();
963 d = fileFixify(d); 1050 d = fileFixify(d, QDir::currentDirPath(), Option::output_dir);
964 if( !project->variables()["INCLUDEPATH"].contains(d)) 1051 if(!includepath.contains(d))
965 project->variables()["INCLUDEPATH"].append(d); 1052 includepath.append(d);
966 } else { 1053 } else {
967 if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR")) 1054 if(decl.isEmpty() && !project->isEmpty("UI_HEADERS_DIR"))
968 decl = project->first("UI_HEADERS_DIR"); 1055 decl = project->first("UI_HEADERS_DIR");
969 if ( !decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") && !project->isEmpty("UI_SOURCES_DIR")) ) { 1056 if(!decl.isEmpty() || (project->isEmpty("UI_HEADERS_DIR") &&
1057 !project->isEmpty("UI_SOURCES_DIR")) ) {
970 QString d = fi.dirPath(); 1058 QString d = fi.dirPath();
971 if( d == ".") 1059 if( d == ".")
972 d = QDir::currentDirPath(); 1060 d = QDir::currentDirPath();
973 d = fileFixify(d); 1061 d = fileFixify(d, QDir::currentDirPath(), Option::output_dir);
974 if( !project->variables()["INCLUDEPATH"].contains(d)) 1062 if(includepath.contains(d))
975 project->variables()["INCLUDEPATH"].append(d); 1063 includepath.append(d);
976 } 1064 }
977 if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR")) 1065 if(impl.isEmpty() && !project->isEmpty("UI_SOURCES_DIR"))
978 impl = project->first("UI_SOURCES_DIR"); 1066 impl = project->first("UI_SOURCES_DIR");
979 if(fi.dirPath() != ".") { 1067 if(fi.dirPath() != ".") {
980 if(impl.isEmpty()) 1068 if(impl.isEmpty())
981 impl = fi.dirPath() + Option::dir_sep; 1069 impl = fi.dirPath() + Option::dir_sep;
982 if(decl.isEmpty()) 1070 if(decl.isEmpty())
983 decl = fi.dirPath() + Option::dir_sep; 1071 decl = fi.dirPath() + Option::dir_sep;
984 } 1072 }
985 } 1073 }
986 impl += fi.baseName(TRUE) + Option::cpp_ext.first(), 1074 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1075 if(!impl.isEmpty())
1076 impl += Option::dir_sep;
1077 impl += fi.baseName(TRUE) + Option::cpp_ext.first();
1078 if(Option::output_dir != QDir::currentDirPath() &&
1079 project->isEmpty("UI_DIR") && project->isEmpty("UI_HEADERS_DIR")) {
1080 QString decl_fixed = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1081 if(!includepath.contains(decl_fixed))
1082 includepath.append(decl_fixed);
1083 if(!includepath.contains(decl))
1084 project->variables()["INCLUDEPATH"].append(decl);
1085 }
1086 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1087 if(!decl.isEmpty())
1088 decl += Option::dir_sep;
987 decl += fi.baseName(TRUE) + Option::h_ext.first(); 1089 decl += fi.baseName(TRUE) + Option::h_ext.first();
988 logicWarn(impl, "SOURCES"); 1090 logicWarn(impl, "SOURCES");
989 logicWarn(decl, "HEADERS"); 1091 logicWarn(decl, "HEADERS");
990 decls.append(decl); 1092 decls.append(decl);
991 impls.append(impl); 1093 impls.append(impl);
992 findDependencies(impl).append(decl); 1094 findDependencies(impl).append(decl);
993 1095
994 QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first(); 1096 QString mocable = Option::moc_mod + fi.baseName(TRUE) + Option::cpp_ext.first();
995 if(!v["MOC_DIR"].isEmpty()) 1097 if(!v["MOC_DIR"].isEmpty())
996 mocable.prepend(v["MOC_DIR"].first()); 1098 mocable.prepend(v["MOC_DIR"].first());
997 else if(fi.dirPath() != ".") 1099 else if(fi.dirPath() != ".")
998 mocable.prepend(fi.dirPath() + Option::dir_sep); 1100 mocable.prepend(fi.dirPath() + Option::dir_sep);
999 logicWarn(mocable, "SOURCES"); 1101 logicWarn(mocable, "SOURCES");
1000 mocablesToMOC[cleanFilePath(decl)] = mocable; 1102 mocablesToMOC[cleanFilePath(decl)] = mocable;
1001 mocablesFromMOC[cleanFilePath(mocable)] = decl; 1103 mocablesFromMOC[cleanFilePath(mocable)] = decl;
1002 v["_UIMOC"].append(mocable); 1104 v["_UIMOC"].append(mocable);
1003 } 1105 }
1004 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS")); 1106 v["OBJECTS"] += (v["UICOBJECTS"] = createObjectList("UICDECLS"));
1005 } 1107 }
1006 1108
1007 //Image files 1109 //Image files
1008 if(!project->isEmpty("IMAGES")) { 1110 if(!project->isEmpty("IMAGES")) {
1009 if(project->isEmpty("QMAKE_IMAGE_COLLECTION")) 1111 if(project->isEmpty("QMAKE_IMAGE_COLLECTION"))
1010 v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first()); 1112 v["QMAKE_IMAGE_COLLECTION"].append("qmake_image_collection" + Option::cpp_ext.first());
1011 QString imgfile = project->first("QMAKE_IMAGE_COLLECTION"); 1113 QString imgfile = project->first("QMAKE_IMAGE_COLLECTION");
1012 Option::fixPathToTargetOS(imgfile); 1114 Option::fixPathToTargetOS(imgfile);
1013 if(!project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) { 1115 if(!project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) {
1014 if(imgfile.find(Option::dir_sep) != -1) 1116 if(imgfile.find(Option::dir_sep) != -1)
1015 imgfile = imgfile.right(imgfile.findRev(Option::dir_sep) + 1); 1117 imgfile = imgfile.right(imgfile.findRev(Option::dir_sep) + 1);
1016 imgfile.prepend( (project->isEmpty("UI_DIR") ? project->first("UI_SOURCES_DIR") : 1118 imgfile.prepend( (project->isEmpty("UI_DIR") ? project->first("UI_SOURCES_DIR") :
1017 project->first("UI_DIR")) ); 1119 project->first("UI_DIR")) );
1018 v["QMAKE_IMAGE_COLLECTION"] = QStringList(imgfile); 1120 v["QMAKE_IMAGE_COLLECTION"] = QStringList(imgfile);
1019 } 1121 }
1020 logicWarn(imgfile, "SOURCES"); 1122 logicWarn(imgfile, "SOURCES");
1021 if(!noIO()) { 1123 if(!noIO()) {
1022 QStringList &l = v["IMAGES"]; 1124 QStringList &l = v["IMAGES"];
1023 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1125 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1024 if(!QFile::exists((*it))) { 1126 if(!QFile::exists((*it))) {
1025 warn_msg(WarnLogic, "Failure to open: %s", (*it).latin1()); 1127 warn_msg(WarnLogic, "Failure to open: %s", (*it).latin1());
1026 continue; 1128 continue;
1027 } 1129 }
1028 findDependencies(imgfile).append(fileFixify((*it))); 1130 findDependencies(imgfile).append(fileFixify((*it)));
1029 } 1131 }
1030 } 1132 }
1031 v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION")); 1133 v["OBJECTS"] += (v["IMAGEOBJECTS"] = createObjectList("QMAKE_IMAGE_COLLECTION"));
1032 } 1134 }
1033 1135 if(Option::output_dir != QDir::currentDirPath())
1034 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 1136 project->variables()["INCLUDEPATH"].append(fileFixify(Option::output_dir, Option::output_dir,
1035 project->variables()["INCLUDEPATH"].append(Option::output_dir); 1137 Option::output_dir));
1036 1138
1037 //moc files 1139 //moc files
1038 if ( mocAware() ) { 1140 if ( mocAware() ) {
1039 if(!project->isEmpty("MOC_DIR")) 1141 if(!project->isEmpty("MOC_DIR"))
1040 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR")); 1142 project->variables()["INCLUDEPATH"].append(project->first("MOC_DIR"));
1041 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC"); 1143 v["OBJMOC"] = createObjectList("_HDRMOC") + createObjectList("_UIMOC");
1042 1144
1043 QStringList &l = v["SRCMOC"]; 1145 QStringList &l = v["SRCMOC"];
1044 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"]; 1146 l = v["_HDRMOC"] + v["_UIMOC"] + v["_SRCMOC"];
1045 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 1147 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1046 if(!(*val_it).isEmpty()) 1148 if(!(*val_it).isEmpty())
1047 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE); 1149 (*val_it) = Option::fixPathToTargetOS((*val_it), FALSE);
1048 } 1150 }
1049 } 1151 }
1050} 1152}
1051 1153
1052bool 1154bool
1053MakefileGenerator::processPrlFile(QString &file) 1155MakefileGenerator::processPrlFile(QString &file)
1054{ 1156{
1055 bool ret = FALSE, try_replace_file=FALSE; 1157 bool ret = FALSE, try_replace_file=FALSE;
1056 QString prl_file; 1158 QString prl_file;
1057 if(file.endsWith(Option::prl_ext)) { 1159 if(file.endsWith(Option::prl_ext)) {
1058 try_replace_file = TRUE; 1160 try_replace_file = TRUE;
1059 prl_file = file; 1161 prl_file = file;
1060 file = ""; 1162 file = "";
1061 } else { 1163 } else {
1062 QString tmp = file; 1164 QString tmp = file;
1063 int ext = tmp.findRev('.'); 1165 int ext = tmp.findRev('.');
1064 if(ext != -1) 1166 if(ext != -1)
1065 tmp = tmp.left(ext); 1167 tmp = tmp.left(ext);
1066 prl_file = tmp + Option::prl_ext; 1168 prl_file = tmp + Option::prl_ext;
1067 } 1169 }
1068 prl_file = fileFixify(prl_file); 1170 prl_file = fileFixify(prl_file);
1069 if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) && 1171 if(!QFile::exists(fileFixify(prl_file, QDir::currentDirPath(), Option::output_dir)) &&
1070 project->isActiveConfig("qt")) { 1172 project->isActiveConfig("qt")) {
1071 QString stem = prl_file, dir, extn; 1173 QString stem = prl_file, dir, extn;
1072 int slsh = stem.findRev('/'), hadlib = 0; 1174 int slsh = stem.findRev('/'), hadlib = 0;
1073 if(slsh != -1) { 1175 if(slsh != -1) {
1074 dir = stem.left(slsh + 1); 1176 dir = stem.left(slsh + 1);
1075 stem = stem.right(stem.length() - slsh - 1); 1177 stem = stem.right(stem.length() - slsh - 1);
1076 } 1178 }
1077 if(stem.startsWith("lib")) { 1179 if(stem.startsWith("lib")) {
1078 hadlib = 1; 1180 hadlib = 1;
1079 stem = stem.right(stem.length() - 3); 1181 stem = stem.right(stem.length() - 3);
1080 } 1182 }
1081 int dot = stem.find('.'); 1183 int dot = stem.find('.');
1082 if(dot != -1) { 1184 if(dot != -1) {
1083 extn = stem.right(stem.length() - dot); 1185 extn = stem.right(stem.length() - dot);
1084 stem = stem.left(dot); 1186 stem = stem.left(dot);
1085 } 1187 }
1086 if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") { 1188 if(stem == "qt" || stem == "qte" || stem == "qte-mt" || stem == "qt-mt") {
1087 if(stem.endsWith("-mt")) 1189 if(stem.endsWith("-mt"))
1088 stem = stem.left(stem.length() - 3); //lose the -mt 1190 stem = stem.left(stem.length() - 3); //lose the -mt
1089 else 1191 else
1090 stem += "-mt"; //try the thread case 1192 stem += "-mt"; //try the thread case
1091 prl_file = dir; 1193 prl_file = dir;
1092 if(hadlib) 1194 if(hadlib)
1093 prl_file += "lib"; 1195 prl_file += "lib";
1094 prl_file += stem + extn; 1196 prl_file += stem + extn;
1095 try_replace_file = TRUE; 1197 try_replace_file = TRUE;
1096 } 1198 }
1097 } 1199 }
1098 QString real_prl_file = Option::fixPathToLocalOS(prl_file); 1200 QString real_prl_file = Option::fixPathToLocalOS(prl_file);
1099 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) { 1201 if(project->variables()["QMAKE_PRL_INTERNAL_FILES"].findIndex(prl_file) != -1) {
1100 ret = TRUE; 1202 ret = TRUE;
1101 } else if(!real_prl_file.isEmpty() && 1203 } else if(!real_prl_file.isEmpty() &&
1102 QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) { 1204 QFile::exists(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir))) {
1103 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file); 1205 project->variables()["QMAKE_PRL_INTERNAL_FILES"].append(prl_file);
1104 QMakeProject proj; 1206 QMakeProject proj;
1105 debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1()); 1207 debug_msg(1, "Processing PRL file: %s", real_prl_file.latin1());
1106 if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir), 1208 if(!proj.read(fileFixify(real_prl_file, QDir::currentDirPath(), Option::output_dir),
1107 QDir::currentDirPath())) { 1209 QDir::currentDirPath(), TRUE)) {
1108 fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1()); 1210 fprintf(stderr, "Error processing prl file: %s\n", real_prl_file.latin1());
1109 } else { 1211 } else {
1110 ret = TRUE; 1212 ret = TRUE;
1111 QMap<QString, QStringList> &vars = proj.variables(); 1213 QMap<QString, QStringList> &vars = proj.variables();
1112 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) 1214 for( QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it)
1113 processPrlVariable(it.key(), it.data()); 1215 processPrlVariable(it.key(), it.data());
1114 if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) { 1216 if(try_replace_file && !proj.isEmpty("QMAKE_PRL_TARGET")) {
1115 QString dir; 1217 QString dir;
1116 int slsh = real_prl_file.findRev(Option::dir_sep); 1218 int slsh = real_prl_file.findRev(Option::dir_sep);
1117 if(slsh != -1) 1219 if(slsh != -1)
1118 dir = real_prl_file.left(slsh+1); 1220 dir = real_prl_file.left(slsh+1);
1119 file = dir + proj.first("QMAKE_PRL_TARGET"); 1221 file = dir + proj.first("QMAKE_PRL_TARGET");
1120 } 1222 }
1121 } 1223 }
1122 if(ret) 1224 if(ret)
1123 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file); 1225 project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].append(prl_file);
1124 } 1226 }
1125 return ret; 1227 return ret;
1126} 1228}
1127 1229
1128void 1230void
1129MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 1231MakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
1130{ 1232{
1131 if(var == "QMAKE_PRL_LIBS") { 1233 if(var == "QMAKE_PRL_LIBS") {
@@ -1175,93 +1277,94 @@ MakefileGenerator::processPrlFiles()
1175} 1277}
1176 1278
1177void 1279void
1178MakefileGenerator::writePrlFile(QTextStream &t) 1280MakefileGenerator::writePrlFile(QTextStream &t)
1179{ 1281{
1180 QString target = project->first("TARGET"); 1282 QString target = project->first("TARGET");
1181 int slsh = target.findRev(Option::dir_sep); 1283 int slsh = target.findRev(Option::dir_sep);
1182 if(slsh != -1) 1284 if(slsh != -1)
1183 target = target.right(target.length() - slsh - 1); 1285 target = target.right(target.length() - slsh - 1);
1184 QString bdir = Option::output_dir; 1286 QString bdir = Option::output_dir;
1185 if(bdir.isEmpty()) 1287 if(bdir.isEmpty())
1186 bdir = QDir::currentDirPath(); 1288 bdir = QDir::currentDirPath();
1187 t << "QMAKE_PRL_BUILD_DIR = " << bdir << endl; 1289 t << "QMAKE_PRL_BUILD_DIR = " << bdir << endl;
1188 1290
1189 if(!project->projectFile().isEmpty() && project->projectFile() != "-") 1291 if(!project->projectFile().isEmpty() && project->projectFile() != "-")
1190 t << "QMAKE_PRO_INPUT = " << project->projectFile().section('/', -1) << endl; 1292 t << "QMAKE_PRO_INPUT = " << project->projectFile().section('/', -1) << endl;
1191 1293
1192 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 1294 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
1193 t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl; 1295 t << "QMAKE_PRL_SOURCE_DIR = " << project->first("QMAKE_ABSOLUTE_SOURCE_PATH") << endl;
1194 t << "QMAKE_PRL_TARGET = " << target << endl; 1296 t << "QMAKE_PRL_TARGET = " << target << endl;
1195 if(!project->isEmpty("PRL_EXPORT_DEFINES")) 1297 if(!project->isEmpty("PRL_EXPORT_DEFINES"))
1196 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl; 1298 t << "QMAKE_PRL_DEFINES = " << project->variables()["PRL_EXPORT_DEFINES"].join(" ") << endl;
1197 if(!project->isEmpty("CONFIG")) 1299 if(!project->isEmpty("CONFIG"))
1198 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl; 1300 t << "QMAKE_PRL_CONFIG = " << project->variables()["CONFIG"].join(" ") << endl;
1301 if(!project->isEmpty("VERSION"))
1302 t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl;
1199 if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { 1303 if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) {
1200 QStringList libs; 1304 QStringList libs;
1201 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 1305 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
1202 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"]; 1306 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
1203 else 1307 else
1204 libs << "QMAKE_LIBS"; //obvious one 1308 libs << "QMAKE_LIBS"; //obvious one
1205 t << "QMAKE_PRL_LIBS = "; 1309 t << "QMAKE_PRL_LIBS = ";
1206 for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) 1310 for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it)
1207 t << project->variables()[(*it)].join(" ") << " "; 1311 t << project->variables()[(*it)].join(" ") << " ";
1208 t << endl; 1312 t << endl;
1209 } 1313 }
1210} 1314}
1211 1315
1212bool 1316bool
1213MakefileGenerator::write() 1317MakefileGenerator::write()
1214{ 1318{
1215 init(); 1319 init();
1216 findLibraries(); 1320 findLibraries();
1217 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl 1321 if((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || //write prl
1218 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) && 1322 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) &&
1219 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" && 1323 project->isActiveConfig("create_prl") && project->first("TEMPLATE") == "lib" &&
1220 !project->isActiveConfig("plugin")) { 1324 !project->isActiveConfig("plugin")) {
1221 QString prl = var("TARGET"); 1325 QString prl = var("TARGET");
1222 int slsh = prl.findRev(Option::dir_sep); 1326 int slsh = prl.findRev(Option::dir_sep);
1223 if(slsh != -1) 1327 if(slsh != -1)
1224 prl = prl.right(prl.length() - slsh); 1328 prl = prl.right(prl.length() - slsh);
1225 int dot = prl.find('.'); 1329 int dot = prl.find('.');
1226 if(dot != -1) 1330 if(dot != -1)
1227 prl = prl.left(dot); 1331 prl = prl.left(dot);
1228 prl += Option::prl_ext; 1332 prl += Option::prl_ext;
1229 if(!project->isEmpty("DESTDIR")) 1333 if(!project->isEmpty("DESTDIR"))
1230 prl.prepend(var("DESTDIR")); 1334 prl.prepend(var("DESTDIR"));
1231 QString local_prl = fileFixify(prl, QDir::currentDirPath(), Option::output_dir); 1335 QString local_prl = Option::fixPathToLocalOS(fileFixify(prl, QDir::currentDirPath(), Option::output_dir));
1232 fixEnvVariables(local_prl);
1233 QFile ft(local_prl); 1336 QFile ft(local_prl);
1234 if(ft.open(IO_WriteOnly)) { 1337 if(ft.open(IO_WriteOnly)) {
1235 project->variables()["ALL_DEPS"].append(prl); 1338 project->variables()["ALL_DEPS"].append(prl);
1236 project->variables()["QMAKE_INTERNAL_PRL_FILE"].append(prl); 1339 project->variables()["QMAKE_INTERNAL_PRL_FILE"].append(prl);
1237 QTextStream t(&ft); 1340 QTextStream t(&ft);
1238 writePrlFile(t); 1341 writePrlFile(t);
1239 ft.close(); 1342 ft.close();
1240 } 1343 }
1241 } 1344 }
1242 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE && 1345 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE &&
1243 project->isActiveConfig("link_prl")) //load up prl's 1346 project->isActiveConfig("link_prl")) //load up prl's'
1244 processPrlFiles(); 1347 processPrlFiles();
1245 1348
1246 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 1349 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
1247 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { 1350 Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
1248 QTextStream t(&Option::output); 1351 QTextStream t(&Option::output);
1249 writeMakefile(t); 1352 writeMakefile(t);
1250 } 1353 }
1251 return TRUE; 1354 return TRUE;
1252} 1355}
1253 1356
1254void 1357void
1255MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src) 1358MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &src)
1256{ 1359{
1257 QStringList &objl = project->variables()[obj]; 1360 QStringList &objl = project->variables()[obj];
1258 QStringList &srcl = project->variables()[src]; 1361 QStringList &srcl = project->variables()[src];
1259 1362
1260 QStringList::Iterator oit = objl.begin(); 1363 QStringList::Iterator oit = objl.begin();
1261 QStringList::Iterator sit = srcl.begin(); 1364 QStringList::Iterator sit = srcl.begin();
1262 QString stringSrc("$src"); 1365 QString stringSrc("$src");
1263 QString stringObj("$obj"); 1366 QString stringObj("$obj");
1264 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1367 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1265 if((*sit).isEmpty()) 1368 if((*sit).isEmpty())
1266 continue; 1369 continue;
1267 1370
@@ -1281,357 +1384,409 @@ MakefileGenerator::writeObj(QTextStream &t, const QString &obj, const QString &s
1281 } 1384 }
1282 1385
1283 QString comp, cimp; 1386 QString comp, cimp;
1284 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { 1387 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
1285 if((*sit).endsWith((*cppit))) { 1388 if((*sit).endsWith((*cppit))) {
1286 comp = "QMAKE_RUN_CXX"; 1389 comp = "QMAKE_RUN_CXX";
1287 cimp = "QMAKE_RUN_CXX_IMP"; 1390 cimp = "QMAKE_RUN_CXX_IMP";
1288 break; 1391 break;
1289 } 1392 }
1290 } 1393 }
1291 if(comp.isEmpty()) { 1394 if(comp.isEmpty()) {
1292 comp = "QMAKE_RUN_CC"; 1395 comp = "QMAKE_RUN_CC";
1293 cimp = "QMAKE_RUN_CC_IMP"; 1396 cimp = "QMAKE_RUN_CC_IMP";
1294 } 1397 }
1295 bool use_implicit_rule = !project->isEmpty(cimp); 1398 bool use_implicit_rule = !project->isEmpty(cimp);
1296 if(use_implicit_rule) { 1399 if(use_implicit_rule) {
1297 if(!project->isEmpty("OBJECTS_DIR")) { 1400 if(!project->isEmpty("OBJECTS_DIR")) {
1298 use_implicit_rule = FALSE; 1401 use_implicit_rule = FALSE;
1299 } else { 1402 } else {
1300 int dot = (*sit).findRev('.'); 1403 int dot = (*sit).findRev('.');
1301 if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) 1404 if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit)))
1302 use_implicit_rule = FALSE; 1405 use_implicit_rule = FALSE;
1303 } 1406 }
1304 } 1407 }
1305 if (!use_implicit_rule) { 1408 if (!use_implicit_rule && !project->isEmpty(comp)) {
1306 QString p = var(comp); 1409 QString p = var(comp);
1307 p.replace(stringSrc, (*sit)); 1410 p.replace(stringSrc, (*sit));
1308 p.replace(stringObj, (*oit)); 1411 p.replace(stringObj, (*oit));
1309 t << "\n\t" << p; 1412 t << "\n\t" << p;
1310 } 1413 }
1311 t << endl << endl; 1414 t << endl << endl;
1312 } 1415 }
1313} 1416}
1314 1417
1315 1418
1316void 1419void
1317MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui) 1420MakefileGenerator::writeUicSrc(QTextStream &t, const QString &ui)
1318{ 1421{
1319 QStringList &uil = project->variables()[ui]; 1422 QStringList &uil = project->variables()[ui];
1320 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) { 1423 for(QStringList::Iterator it = uil.begin(); it != uil.end(); it++) {
1321 QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl; 1424 QString deps = findDependencies((*it)).join(" \\\n\t\t"), decl, impl;
1322 { 1425 {
1323 QString tmp = (*it); 1426 QString tmp = (*it), impl_dir, decl_dir;
1324 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first()); 1427 decl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::h_ext.first());
1428 decl = fileFixify(decl, QDir::currentDirPath(), Option::output_dir);
1429 int dlen = decl.findRev(Option::dir_sep) + 1;
1325 tmp = (*it); 1430 tmp = (*it);
1326 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first()); 1431 impl = tmp.replace(QRegExp("\\" + Option::ui_ext + "$"), Option::cpp_ext.first());
1327 int dlen = (*it).findRev(Option::dir_sep) + 1; 1432 impl = fileFixify(impl, QDir::currentDirPath(), Option::output_dir);
1433 int ilen = decl.findRev(Option::dir_sep) + 1;
1328 if(!project->isEmpty("UI_DIR")) { 1434 if(!project->isEmpty("UI_DIR")) {
1435 impl_dir = project->first("UI_DIR");
1329 decl = project->first("UI_DIR") + decl.right(decl.length() - dlen); 1436 decl = project->first("UI_DIR") + decl.right(decl.length() - dlen);
1330 impl = project->first("UI_DIR") + impl.right(impl.length() - dlen); 1437 impl = project->first("UI_DIR") + impl.right(impl.length() - ilen);
1331 } else { 1438 } else {
1332 if(!project->isEmpty("UI_HEADERS_DIR")) 1439 if(!project->isEmpty("UI_HEADERS_DIR")) {
1440 decl_dir = project->first("UI_HEADERS_DIR");
1333 decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen); 1441 decl = project->first("UI_HEADERS_DIR") + decl.right(decl.length() - dlen);
1334 if(!project->isEmpty("UI_SOURCES_DIR")) 1442 }
1335 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - dlen); 1443 if(!project->isEmpty("UI_SOURCES_DIR")) {
1336 } 1444 impl_dir = project->first("UI_SOURCES_DIR");
1445 impl = project->first("UI_SOURCES_DIR") + impl.right(impl.length() - ilen);
1446 }
1447 }
1448 if(decl_dir.isEmpty())
1449 decl_dir = decl.left(dlen);
1450 if(impl_dir.isEmpty())
1451 impl_dir = impl.left(ilen);
1452 if(!impl_dir.isEmpty())
1453 createDir(Option::output_dir + Option::dir_sep + impl_dir);
1454 if(!decl_dir.isEmpty() && decl_dir != impl_dir)
1455 createDir(Option::output_dir + Option::dir_sep + decl_dir);
1337 } 1456 }
1338 t << decl << ": " << (*it) << " " << deps << "\n\t" 1457 t << decl << ": " << (*it) << " " << deps << "\n\t"
1339 << "$(UIC) " << (*it) << " -o " << decl << endl << endl; 1458 << "$(UIC) " << (*it) << " -o " << decl << endl << endl;
1340 1459
1341 QString mildDecl = decl; 1460 QString mildDecl = decl;
1342 int k = mildDecl.findRev( Option::dir_sep ); 1461 int k = mildDecl.findRev( Option::dir_sep );
1343 if ( k != -1 ) 1462 if ( k != -1 )
1344 mildDecl = mildDecl.mid( k + 1 ); 1463 mildDecl = mildDecl.mid( k + 1 );
1345 1464
1346 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t" 1465 t << impl << ": " << decl << " " << (*it) << " " << deps << "\n\t"
1347 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; 1466 << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl;
1348 } 1467 }
1349} 1468}
1350 1469
1351 1470
1352void 1471void
1353MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src) 1472MakefileGenerator::writeMocObj(QTextStream &t, const QString &obj, const QString &src)
1354{ 1473{
1355 QStringList &objl = project->variables()[obj], 1474 QStringList &objl = project->variables()[obj],
1356 &srcl = project->variables()[src]; 1475 &srcl = project->variables()[src];
1357 QStringList::Iterator oit = objl.begin(), sit = srcl.begin(); 1476 QStringList::Iterator oit = objl.begin(), sit = srcl.begin();
1358 QString stringSrc("$src"), stringObj("$obj"); 1477 QString stringSrc("$src"), stringObj("$obj");
1359 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) { 1478 for( ;sit != srcl.end() && oit != objl.end(); oit++, sit++) {
1360 QString hdr = findMocSource((*sit)); 1479 QString hdr = findMocSource((*sit));
1361 t << (*oit) << ": " << (*sit) << " " 1480 t << (*oit) << ": " << (*sit) << " "
1362 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t"); 1481 << hdr << " " << findDependencies(hdr).join(" \\\n\t\t");
1363 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1482 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1364 if(use_implicit_rule) { 1483 if(use_implicit_rule) {
1365 if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) { 1484 if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("MOC_DIR")) {
1366 use_implicit_rule = FALSE; 1485 use_implicit_rule = FALSE;
1367 } else { 1486 } else {
1368 int dot = (*sit).findRev('.'); 1487 int dot = (*sit).findRev('.');
1369 if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit))) 1488 if(dot == -1 || ((*sit).left(dot) + Option::obj_ext != (*oit)))
1370 use_implicit_rule = FALSE; 1489 use_implicit_rule = FALSE;
1371 } 1490 }
1372 } 1491 }
1373 if (!use_implicit_rule) { 1492 if (!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1374 QString p = var("QMAKE_RUN_CXX"); 1493 QString p = var("QMAKE_RUN_CXX");
1375 p.replace(stringSrc, (*sit)); 1494 p.replace(stringSrc, (*sit));
1376 p.replace(stringObj, (*oit)); 1495 p.replace(stringObj, (*oit));
1377 t << "\n\t" << p; 1496 t << "\n\t" << p;
1378 } 1497 }
1379 t << endl << endl; 1498 t << endl << endl;
1380 } 1499 }
1381} 1500}
1382 1501
1383 1502
1384void 1503void
1385MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src) 1504MakefileGenerator::writeMocSrc(QTextStream &t, const QString &src)
1386{ 1505{
1387 QStringList &l = project->variables()[src]; 1506 QStringList &l = project->variables()[src];
1388 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1507 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1389 QString m = Option::fixPathToTargetOS(findMocDestination(*it)); 1508 QString m = Option::fixPathToTargetOS(findMocDestination(*it));
1390 if ( !m.isEmpty()) { 1509 if ( !m.isEmpty()) {
1391 QString deps; 1510 QString deps;
1392 if(!project->isActiveConfig("no_mocdepend")) 1511 if(!project->isActiveConfig("no_mocdepend"))
1393 deps += "$(MOC) "; 1512 deps += "$(MOC) ";
1394 deps += (*it); 1513 deps += (*it);
1395 t << m << ": " << deps << "\n\t" 1514 t << m << ": " << deps << "\n\t"
1396 << "$(MOC) " << (*it) << " -o " << m << endl << endl; 1515 << "$(MOC) " << (*it) << " -o " << m << endl << endl;
1397 } 1516 }
1398 } 1517 }
1399} 1518}
1400 1519
1401void 1520void
1402MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src) 1521MakefileGenerator::writeYaccSrc(QTextStream &t, const QString &src)
1403{ 1522{
1404 QStringList &l = project->variables()[src]; 1523 QStringList &l = project->variables()[src];
1405 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1) 1524 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
1406 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected." 1525 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected."
1407 "This can lead to link problems.\n"); 1526 "This can lead to link problems.\n");
1408 QString default_out_h = "y.tab.h", default_out_c = "y.tab.c"; 1527 QString default_out_h = "y.tab.h", default_out_c = "y.tab.c";
1409 if(!project->isEmpty("QMAKE_YACC_HEADER")) 1528 if(!project->isEmpty("QMAKE_YACC_HEADER"))
1410 default_out_h = project->first("QMAKE_YACC_HEADER"); 1529 default_out_h = project->first("QMAKE_YACC_HEADER");
1411 if(!project->isEmpty("QMAKE_YACC_SOURCE")) 1530 if(!project->isEmpty("QMAKE_YACC_SOURCE"))
1412 default_out_c = project->first("QMAKE_YACC_SOURCE"); 1531 default_out_c = project->first("QMAKE_YACC_SOURCE");
1413 QString stringBase("$base"); 1532 QString stringBase("$base");
1414 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1533 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1415 QFileInfo fi((*it)); 1534 QFileInfo fi((*it));
1416 QString dir = fileFixify(Option::output_dir); 1535 QString dir;
1536 if(fi.dirPath() != ".")
1537 dir = fi.dirPath() + Option::dir_sep;
1538 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
1417 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 1539 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
1418 dir += Option::dir_sep; 1540 dir += Option::dir_sep;
1541
1419 QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); 1542 QString impl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
1420 QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); 1543 QString decl = dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
1421 1544
1422 QString yaccflags = "$(YACCFLAGS)", mangle = "y"; 1545 QString yaccflags = "$(YACCFLAGS)", mangle = "y";
1423 if(!project->isActiveConfig("yacc_no_name_mangle")) { 1546 if(!project->isActiveConfig("yacc_no_name_mangle")) {
1424 mangle = fi.baseName(TRUE); 1547 mangle = fi.baseName(TRUE);
1425 yaccflags += " -p " + mangle; 1548 yaccflags += " -p " + mangle;
1426 } 1549 }
1427 QString out_h = default_out_h, out_c = default_out_c; 1550 QString out_h = default_out_h, out_c = default_out_c;
1428 if(!mangle.isEmpty()) { 1551 if(!mangle.isEmpty()) {
1429 out_h.replace(stringBase, mangle); 1552 out_h.replace(stringBase, mangle);
1430 out_c.replace(stringBase, mangle); 1553 out_c.replace(stringBase, mangle);
1431 } 1554 }
1432 1555
1433 t << impl << ": " << (*it) << "\n\t" 1556 t << impl << ": " << (*it) << "\n\t"
1434 << "$(YACC) " << yaccflags << " " << (*it) << "\n\t" 1557 << "$(YACC) " << yaccflags << " " << (*it) << "\n\t"
1435 << "-$(DEL_FILE) " << impl << " " << decl << "\n\t" 1558 << "-$(DEL_FILE) " << impl << " " << decl << "\n\t"
1436 << "-$(MOVE) " << out_h << " " << decl << "\n\t" 1559 << "-$(MOVE) " << out_h << " " << decl << "\n\t"
1437 << "-$(MOVE) " << out_c << " " << impl << endl << endl; 1560 << "-$(MOVE) " << out_c << " " << impl << endl << endl;
1438 t << decl << ": " << impl << endl << endl; 1561 t << decl << ": " << impl << endl << endl;
1439 } 1562 }
1440} 1563}
1441 1564
1442void 1565void
1443MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src) 1566MakefileGenerator::writeLexSrc(QTextStream &t, const QString &src)
1444{ 1567{
1445 QStringList &l = project->variables()[src]; 1568 QStringList &l = project->variables()[src];
1446 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1) 1569 if(project->isActiveConfig("yacc_no_name_mangle") && l.count() > 1)
1447 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected.\n" 1570 warn_msg(WarnLogic, "yacc_no_name_mangle specified, but multiple parsers expected.\n"
1448 "This can lead to link problems.\n"); 1571 "This can lead to link problems.\n");
1449 QString default_out_c = "lex.$base.c"; 1572 QString default_out_c = "lex.$base.c";
1450 if(!project->isEmpty("QMAKE_LEX_SOURCE")) 1573 if(!project->isEmpty("QMAKE_LEX_SOURCE"))
1451 default_out_c = project->first("QMAKE_LEX_SOURCE"); 1574 default_out_c = project->first("QMAKE_LEX_SOURCE");
1452 QString stringBase("$base"); 1575 QString stringBase("$base");
1453 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1576 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1454 QFileInfo fi((*it)); 1577 QFileInfo fi((*it));
1455 QString dir = fileFixify(Option::output_dir); 1578 QString dir;
1579 if(fi.dirPath() != ".")
1580 dir = fi.dirPath() + Option::dir_sep;
1581 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
1456 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 1582 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
1457 dir += Option::dir_sep; 1583 dir += Option::dir_sep;
1458 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 1584 QString impl = dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
1459 1585
1460 QString lexflags = "$(LEXFLAGS)", stub="yy"; 1586 QString lexflags = "$(LEXFLAGS)", stub="yy";
1461 if(!project->isActiveConfig("yacc_no_name_mangle")) { 1587 if(!project->isActiveConfig("yacc_no_name_mangle")) {
1462 stub = fi.baseName(TRUE); 1588 stub = fi.baseName(TRUE);
1463 lexflags += " -P" + stub; 1589 lexflags += " -P" + stub;
1464 } 1590 }
1465 QString out_c = default_out_c; 1591 QString out_c = default_out_c;
1466 if(!stub.isEmpty()) 1592 if(!stub.isEmpty())
1467 out_c.replace(stringBase, stub); 1593 out_c.replace(stringBase, stub);
1468 1594
1469 t << impl << ": " << (*it) << " " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1595 t << impl << ": " << (*it) << " " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1470 << ( "$(LEX) " + lexflags + " " ) << (*it) << "\n\t" 1596 << ( "$(LEX) " + lexflags + " " ) << (*it) << "\n\t"
1471 << "-$(DEL_FILE) " << impl << " " << "\n\t" 1597 << "-$(DEL_FILE) " << impl << " " << "\n\t"
1472 << "-$(MOVE) " << out_c << " " << impl << endl << endl; 1598 << "-$(MOVE) " << out_c << " " << impl << endl << endl;
1473 } 1599 }
1474} 1600}
1475 1601
1476void 1602void
1477MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj) 1603MakefileGenerator::writeImageObj(QTextStream &t, const QString &obj)
1478{ 1604{
1479 QStringList &objl = project->variables()[obj]; 1605 QStringList &objl = project->variables()[obj];
1480 QString stringSrc("$src"); 1606 QString stringSrc("$src");
1481 QString stringObj("$obj"); 1607 QString stringObj("$obj");
1482 1608
1483 QString uidir; 1609 QString uidir;
1484 for(QStringList::Iterator oit = objl.begin(); oit != objl.end(); oit++) { 1610 for(QStringList::Iterator oit = objl.begin(); oit != objl.end(); oit++) {
1485 QString src(project->first("QMAKE_IMAGE_COLLECTION")); 1611 QString src(project->first("QMAKE_IMAGE_COLLECTION"));
1486 t << (*oit) << ": " << src; 1612 t << (*oit) << ": " << src;
1487 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP"); 1613 bool use_implicit_rule = !project->isEmpty("QMAKE_RUN_CXX_IMP");
1488 if(use_implicit_rule) { 1614 if(use_implicit_rule) {
1489 if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) { 1615 if(!project->isEmpty("OBJECTS_DIR") || !project->isEmpty("UI_DIR") || !project->isEmpty("UI_SOURCES_DIR")) {
1490 use_implicit_rule = FALSE; 1616 use_implicit_rule = FALSE;
1491 } else { 1617 } else {
1492 int dot = src.findRev('.'); 1618 int dot = src.findRev('.');
1493 if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit))) 1619 if(dot == -1 || (src.left(dot) + Option::obj_ext != (*oit)))
1494 use_implicit_rule = FALSE; 1620 use_implicit_rule = FALSE;
1495 } 1621 }
1496 } 1622 }
1497 if(!use_implicit_rule) { 1623 if(!use_implicit_rule && !project->isEmpty("QMAKE_RUN_CXX")) {
1498 QString p = var("QMAKE_RUN_CXX"); 1624 QString p = var("QMAKE_RUN_CXX");
1499 p.replace( stringSrc, src); 1625 p.replace( stringSrc, src);
1500 p.replace( stringObj, (*oit)); 1626 p.replace( stringObj, (*oit));
1501 t << "\n\t" << p; 1627 t << "\n\t" << p;
1502 } 1628 }
1503 t << endl << endl; 1629 t << endl << endl;
1504 } 1630 }
1505} 1631}
1506 1632
1507 1633
1508void 1634void
1509MakefileGenerator::writeImageSrc(QTextStream &t, const QString &src) 1635MakefileGenerator::writeImageSrc(QTextStream &t, const QString &src)
1510{ 1636{
1511 QStringList &l = project->variables()[src]; 1637 QStringList &l = project->variables()[src];
1512 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1638 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1513 QString gen = project->first("MAKEFILE_GENERATOR"); 1639 QString gen = project->first("MAKEFILE_GENERATOR");
1514 if ( gen == "MSVC" ) { 1640 if ( gen == "MSVC" ) {
1515 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1641 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1516 << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET") 1642 << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET")
1517 << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl; 1643 << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl;
1518 } else if ( gen == "BMAKE" ) { 1644 } else if ( gen == "BMAKE" ) {
1519 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1645 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1520 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") 1646 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
1521 << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl; 1647 << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl;
1522 } else { 1648 } else {
1523 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" 1649 t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t"
1524 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") 1650 << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET")
1525 << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl; 1651 << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl;
1526 } 1652 }
1527 } 1653 }
1528} 1654}
1529 1655
1530 1656
1531void 1657void
1532MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs) 1658MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs)
1533{ 1659{
1534 QString all_installs, all_uninstalls; 1660 QString all_installs, all_uninstalls;
1535 QStringList &l = project->variables()[installs]; 1661 QStringList &l = project->variables()[installs];
1536 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 1662 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
1537 QString pvar = (*it) + ".path"; 1663 QString pvar = (*it) + ".path";
1538 if(project->variables()[pvar].isEmpty()) { 1664 if(project->variables()[pvar].isEmpty()) {
1539 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1()); 1665 warn_msg(WarnLogic, "%s is not defined: install target not created\n", pvar.latin1());
1540 continue; 1666 continue;
1541 } 1667 }
1542 1668
1543 bool do_default = TRUE; 1669 bool do_default = TRUE;
1544 QString target, dst="$(INSTALL_ROOT)" + Option::fixPathToTargetOS(project->variables()[pvar].first(), FALSE); 1670 const QString root = "$(INSTALL_ROOT)";
1671 QString target, dst= fileFixify(project->variables()[pvar].first());
1672#ifndef Q_WS_WIN
1545 if(dst.right(1) != Option::dir_sep) 1673 if(dst.right(1) != Option::dir_sep)
1546 dst += Option::dir_sep; 1674 dst += Option::dir_sep;
1547 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"]; 1675#endif
1548 //other 1676 QStringList tmp, &uninst = project->variables()[(*it) + ".uninstall"];
1549 tmp = project->variables()[(*it) + ".extra"]; 1677 //other
1550 if(!tmp.isEmpty()) { 1678 tmp = project->variables()[(*it) + ".extra"];
1679 if(!tmp.isEmpty()) {
1551 do_default = FALSE; 1680 do_default = FALSE;
1552 if(!target.isEmpty()) 1681 if(!target.isEmpty())
1553 target += "\n\t"; 1682 target += "\n\t";
1554 target += tmp.join(" "); 1683 target += tmp.join(" ");
1555 } 1684 }
1556 //masks 1685 //masks
1557 tmp = project->variables()[(*it) + ".files"]; 1686 tmp = project->variables()[(*it) + ".files"];
1558 if(!tmp.isEmpty()) { 1687 if(!tmp.isEmpty()) {
1559 if(!target.isEmpty()) 1688 if(!target.isEmpty())
1560 target += "\n"; 1689 target += "\n";
1561 do_default = FALSE; 1690 do_default = FALSE;
1562 for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) { 1691 for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) {
1563 QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild); 1692 QString wild = Option::fixPathToLocalOS((*wild_it), FALSE), wild_var = fileFixify(wild);
1693 QString dirstr = QDir::currentDirPath(), filestr = wild;
1694 int slsh = filestr.findRev(Option::dir_sep);
1695 if(slsh != -1) {
1696 dirstr = filestr.left(slsh+1);
1697 filestr = filestr.right(filestr.length() - slsh - 1);
1698 }
1699 if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep)
1700 dirstr += Option::dir_sep;
1564 if(QFile::exists(wild)) { //real file 1701 if(QFile::exists(wild)) { //real file
1702 QString file = wild;
1565 QFileInfo fi(wild); 1703 QFileInfo fi(wild);
1566 target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + 1704 if(!target.isEmpty())
1567 " \"" + Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + fileFixify(dst) + "\"\n"; 1705 target += "\t";
1706 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" +
1707 Option::fixPathToTargetOS(fileFixify(wild), FALSE) + "\" \"" + root + dst + "\"\n";
1568 if(!project->isActiveConfig("debug") && 1708 if(!project->isActiveConfig("debug") &&
1569 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1709 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1570 target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + wild) + "\"\n"; 1710 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + filestr) + "\"\n";
1571 uninst.append(QString("-$(DEL_FILE) -r") + " \"" + fileFixify(dst + wild) + "\""); 1711 if(!uninst.isEmpty())
1712 uninst.append("\n\t");
1713 uninst.append(
1714#ifdef Q_WS_WIN
1715 QString("-$(DEL_FILE)")
1716#else
1717 QString("-$(DEL_FILE) -r")
1718#endif
1719 + " \"" + root + fileFixify(dst + filestr) + "\"");
1572 continue; 1720 continue;
1573 } 1721 }
1574 QString dirstr = QDir::currentDirPath(), f = wild; //wild 1722 QDir dir(dirstr, filestr); //wild
1575 int slsh = f.findRev(Option::dir_sep);
1576 if(slsh != -1) {
1577 dirstr = f.left(slsh+1);
1578 f = f.right(f.length() - slsh - 1);
1579 }
1580 if(dirstr.right(Option::dir_sep.length()) != Option::dir_sep)
1581 dirstr += Option::dir_sep;
1582 if(!uninst.isEmpty())
1583 uninst.append("\n\t");
1584 uninst.append(QString("-$(DEL_FILE) -r") + " " + fileFixify(dst + f) + "");
1585
1586 QDir dir(dirstr, f);
1587 for(uint x = 0; x < dir.count(); x++) { 1723 for(uint x = 0; x < dir.count(); x++) {
1588 QString file = dir[x]; 1724 QString file = dir[x];
1589 if(file == "." || file == "..") //blah 1725 if(file == "." || file == "..") //blah
1590 continue; 1726 continue;
1727 if(!uninst.isEmpty())
1728 uninst.append("\n\t");
1729 uninst.append(
1730#ifdef Q_WS_WIN
1731 QString("-$(DEL_FILE)")
1732#else
1733 QString("-$(DEL_FILE) -r")
1734#endif
1735 + " \"" + root + fileFixify(dst + file) + "\"");
1591 QFileInfo fi(file); 1736 QFileInfo fi(file);
1592 target += QString("\t-") + (fi.isDir() ? "$(COPY_DIR)" : "$(COPY_FILE)") + 1737 if(!target.isEmpty())
1593 " \"" + Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) + 1738 target += "\t";
1594 "\" \"" + fileFixify(dst) + "\"\n"; 1739 target += QString(fi.isDir() ? "-$(COPY_DIR)" : "-$(COPY_FILE)") + " \"" +
1740 Option::fixPathToTargetOS(fileFixify(dirstr + file), FALSE) +
1741 "\" \"" + root + fileFixify(dst) + "\"\n";
1595 if(!project->isActiveConfig("debug") && 1742 if(!project->isActiveConfig("debug") &&
1596 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP")) 1743 !fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
1597 target += QString("\t") + var("QMAKE_STRIP") + " \"" + fileFixify(dst + file) + "\"\n"; 1744 target += QString("\t-") + var("QMAKE_STRIP") + " \"" + root + fileFixify(dst + file) + "\"\n";
1598 } 1745 }
1599 } 1746 }
1600 } 1747 }
1601 //default? 1748 //default?
1602 if(do_default) 1749 if(do_default)
1603 target = defaultInstall((*it)); 1750 target = defaultInstall((*it));
1604 1751
1605 if(!target.isEmpty()) { 1752 if(!target.isEmpty()) {
1606 t << "install_" << (*it) << ": " << "\n\t" 1753 t << "install_" << (*it) << ": " << "\n\t";
1607 << "@test -d " << dst << " || mkdir -p " << dst << "\n\t" 1754 const QStringList &dirs = project->variables()[pvar];
1608 << target << endl << endl; 1755 for(QStringList::ConstIterator pit = dirs.begin(); pit != dirs.end(); ++pit) {
1756 QString tmp_dst = fileFixify((*pit));
1757#ifndef Q_WS_WIN
1758 if(tmp_dst.right(1) != Option::dir_sep)
1759 tmp_dst += Option::dir_sep;
1760#endif
1761 t << mkdir_p_asstring(root+tmp_dst) << "\n\t";
1762 }
1763 t << target << endl << endl;
1609 all_installs += QString("install_") + (*it) + " "; 1764 all_installs += QString("install_") + (*it) + " ";
1610 if(!uninst.isEmpty()) { 1765 if(!uninst.isEmpty()) {
1611 t << "uninstall_" << (*it) << ": " << "\n\t" 1766 t << "uninstall_" << (*it) << ": " << "\n\t"
1612 << uninst.join(" ") << "\n\t" 1767 << uninst.join("") << "\n\t"
1613 << "-$(DEL_DIR) \"" << dst << "\"" << endl << endl; 1768 << "-$(DEL_DIR) \"" << ( root + dst ) << "\"" << endl << endl;
1614 all_uninstalls += "uninstall_" + (*it) + " "; 1769 all_uninstalls += "uninstall_" + (*it) + " ";
1615 } 1770 }
1616 t << endl; 1771 t << endl;
1617 } else { 1772 } else {
1618 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1()); 1773 debug_msg(1, "no definition for install %s: install target not created",(*it).latin1());
1619 } 1774 }
1620 } 1775 }
1621 t << "install: all " << all_installs << "\n\n"; 1776 t << "install: all " << all_installs << "\n\n";
1622 t << "uninstall: " << all_uninstalls << "\n\n"; 1777 t << "uninstall: " << all_uninstalls << "\n\n";
1623} 1778}
1624 1779
1625QString 1780QString
1626MakefileGenerator::var(const QString &var) 1781MakefileGenerator::var(const QString &var)
1627{ 1782{
1628 return val(project->variables()[var]); 1783 return val(project->variables()[var]);
1629} 1784}
1630 1785
1631QString 1786QString
1632MakefileGenerator::val(const QStringList &varList) 1787MakefileGenerator::val(const QStringList &varList)
1633{ 1788{
1634 return valGlue(varList, "", " ", ""); 1789 return valGlue(varList, "", " ", "");
1635} 1790}
1636 1791
1637QString 1792QString
@@ -1766,193 +1921,213 @@ QString MakefileGenerator::build_args()
1766 if(ret.isEmpty()) { 1921 if(ret.isEmpty()) {
1767 ret = "$(QMAKE)"; 1922 ret = "$(QMAKE)";
1768 1923
1769 // general options and arguments 1924 // general options and arguments
1770 ret += buildArgs(); 1925 ret += buildArgs();
1771 1926
1772 //output 1927 //output
1773 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); 1928 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name()));
1774 if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE")) 1929 if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE"))
1775 ret += " -o " + ofile; 1930 ret += " -o " + ofile;
1776 1931
1777 //inputs 1932 //inputs
1778 QStringList files = fileFixify(Option::mkfile::project_files); 1933 QStringList files = fileFixify(Option::mkfile::project_files);
1779 ret += " " + files.join(" "); 1934 ret += " " + files.join(" ");
1780 } 1935 }
1781 return ret; 1936 return ret;
1782} 1937}
1783 1938
1784bool 1939bool
1785MakefileGenerator::writeHeader(QTextStream &t) 1940MakefileGenerator::writeHeader(QTextStream &t)
1786{ 1941{
1787 time_t foo = time(NULL); 1942 time_t foo = time(NULL);
1788 t << "#############################################################################" << endl; 1943 t << "#############################################################################" << endl;
1789 t << "# Makefile for building: " << var("TARGET") << endl; 1944 t << "# Makefile for building: " << var("TARGET") << endl;
1790 t << "# Generated by qmake (" << qmake_version() << ") on: " << ctime(&foo); 1945 t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: " << ctime(&foo);
1791 t << "# Project: " << fileFixify(project->projectFile()) << endl; 1946 t << "# Project: " << fileFixify(project->projectFile()) << endl;
1792 t << "# Template: " << var("TEMPLATE") << endl; 1947 t << "# Template: " << var("TEMPLATE") << endl;
1793 t << "# Command: " << build_args() << endl; 1948 t << "# Command: " << build_args() << endl;
1794 t << "#############################################################################" << endl; 1949 t << "#############################################################################" << endl;
1795 t << endl; 1950 t << endl;
1796 return TRUE; 1951 return TRUE;
1797} 1952}
1798 1953
1799 1954
1800//makes my life easier.. 1955//makes my life easier..
1801bool 1956bool
1802MakefileGenerator::writeMakeQmake(QTextStream &t) 1957MakefileGenerator::writeMakeQmake(QTextStream &t)
1803{ 1958{
1804 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name())); 1959 QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.name()));
1805 if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && 1960 if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake") &&
1806 !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { 1961 !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
1807 QStringList files = fileFixify(Option::mkfile::project_files); 1962 QStringList files = fileFixify(Option::mkfile::project_files);
1808 t << project->first("QMAKE_INTERNAL_PRL_FILE") << ": " << "\n\t" 1963 t << project->first("QMAKE_INTERNAL_PRL_FILE") << ": " << "\n\t"
1809 << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl; 1964 << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl;
1810 } 1965 }
1811 1966
1812 QString pfile = project->projectFile(); 1967 QString pfile = project->projectFile();
1813 if(pfile != "(stdin)") { 1968 if(pfile != "(stdin)") {
1814 QString qmake = build_args(); 1969 QString qmake = build_args();
1815 if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) { 1970 if(!ofile.isEmpty() && !project->isActiveConfig("no_autoqmake")) {
1816 t << ofile << ": " << fileFixify(pfile) << " "; 1971 t << ofile << ": " << fileFixify(pfile) << " ";
1817 if(Option::mkfile::do_cache) 1972 if(Option::mkfile::do_cache)
1818 t << fileFixify(Option::mkfile::cachefile) << " "; 1973 t << fileFixify(Option::mkfile::cachefile) << " ";
1819 if(!specdir().isEmpty()) 1974 if(!specdir().isEmpty())
1820 t << specdir() << Option::dir_sep << "qmake.conf" << " "; 1975 t << specdir() << Option::dir_sep << "qmake.conf" << " ";
1821 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t" 1976 t << project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"].join(" \\\n\t\t") << "\n\t"
1822 << qmake <<endl; 1977 << qmake <<endl;
1823 } 1978 }
1824 if(project->first("QMAKE_ORIG_TARGET") != "qmake") { 1979 if(project->first("QMAKE_ORIG_TARGET") != "qmake") {
1825 t << "qmake: " << 1980 t << "qmake: " <<
1826 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t" 1981 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].join(" \\\n\t\t") << "\n\t"
1827 << "@" << qmake << endl << endl; 1982 << "@" << qmake << endl << endl;
1828 } 1983 }
1829 } 1984 }
1830 return TRUE; 1985 return TRUE;
1831} 1986}
1832 1987
1833QStringList 1988QStringList
1834MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const 1989MakefileGenerator::fileFixify(const QStringList& files, const QString &out_dir, const QString &in_dir, bool force_fix) const
1835{ 1990{
1836 if(files.isEmpty()) 1991 if(files.isEmpty())
1837 return files; 1992 return files;
1838 QStringList ret; 1993 QStringList ret;
1839 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { 1994 for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) {
1840 if(!(*it).isEmpty()) 1995 if(!(*it).isEmpty())
1841 ret << fileFixify((*it), out_dir, in_dir, force_fix); 1996 ret << fileFixify((*it), out_dir, in_dir, force_fix);
1842 } 1997 }
1843 return ret; 1998 return ret;
1844} 1999}
1845 2000
1846QString 2001QString
1847MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const 2002MakefileGenerator::fileFixify(const QString& file0, const QString &out_d, const QString &in_d, bool force_fix) const
1848{ 2003{
2004 if(file0.isEmpty())
2005 return file0;
2006 QString key = file0;
2007 if(!in_d.isEmpty() || !out_d.isEmpty() || force_fix)
2008 key.prepend(in_d + "--" + out_d + "--" + QString::number((int)force_fix) + "-");
2009 if(fileFixed.contains(key))
2010 return fileFixed[key];
2011
1849 QString file = file0; 2012 QString file = file0;
1850 if(file.isEmpty())
1851 return file;
1852 int depth = 4; 2013 int depth = 4;
1853 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 2014 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
1854 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 2015 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
1855 if(project && !project->isEmpty("QMAKE_PROJECT_DEPTH")) 2016 if(project && !project->isEmpty("QMAKE_PROJECT_DEPTH"))
1856 depth = project->first("QMAKE_PROJECT_DEPTH").toInt(); 2017 depth = project->first("QMAKE_PROJECT_DEPTH").toInt();
1857 else if(Option::mkfile::cachefile_depth != -1) 2018 else if(Option::mkfile::cachefile_depth != -1)
1858 depth = Option::mkfile::cachefile_depth; 2019 depth = Option::mkfile::cachefile_depth;
1859 } 2020 }
1860 2021
1861 QChar quote; 2022 QChar quote;
1862 if((file.startsWith("'") || file.startsWith("\"")) && file.startsWith(file.right(1))) { 2023 if((file.startsWith("'") || file.startsWith("\"")) && file.startsWith(file.right(1))) {
1863 quote = file.at(0); 2024 quote = file.at(0);
1864 file = file.mid(1, file.length() - 2); 2025 file = file.mid(1, file.length() - 2);
1865 } 2026 }
1866 QString orig_file = file; 2027 QString orig_file = file;
1867 if(!force_fix && project->isActiveConfig("no_fixpath")) { 2028 if(!force_fix && project->isActiveConfig("no_fixpath")) {
1868 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it 2029 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) { //absoluteify it
1869 QString qfile = Option::fixPathToLocalOS(file); 2030 QString qfile = Option::fixPathToLocalOS(file);
1870 if(QDir::isRelativePath(file)) { //already absolute 2031 if(QDir::isRelativePath(file)) { //already absolute
1871 QFileInfo fi(qfile); 2032 QFileInfo fi(qfile);
1872 if(!fi.convertToAbs()) //strange 2033 if(!fi.convertToAbs()) //strange
1873 file = fi.filePath(); 2034 file = fi.filePath();
1874 } 2035 }
1875 } 2036 }
1876 } else { //fix it.. 2037 } else { //fix it..
1877 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d); 2038 QString qfile(Option::fixPathToLocalOS(file, TRUE)), in_dir(in_d), out_dir(out_d);
1878 { 2039 {
1879 if(out_dir.isNull()) 2040 if(out_dir.isNull())
1880 out_dir = Option::output_dir; 2041 out_dir = Option::output_dir;
1881 if(out_dir == ".") 2042 if(out_dir == ".")
1882 out_dir = QDir::currentDirPath(); 2043 out_dir = QDir::currentDirPath();
1883 if(in_dir.isEmpty() || in_dir == ".") 2044 if(in_dir.isEmpty() || in_dir == ".")
1884 in_dir = QDir::currentDirPath(); 2045 in_dir = QDir::currentDirPath();
1885 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) { 2046 if(!QDir::isRelativePath(in_dir) || !QDir::isRelativePath(out_dir)) {
1886 QFileInfo in_fi(in_dir); 2047 QFileInfo in_fi(in_dir);
1887 if(!in_fi.convertToAbs()) 2048 if(!in_fi.convertToAbs())
1888 in_dir = in_fi.filePath(); 2049 in_dir = in_fi.filePath();
1889 QFileInfo out_fi(out_dir); 2050 QFileInfo out_fi(out_dir);
1890 if(!out_fi.convertToAbs()) 2051 if(!out_fi.convertToAbs())
1891 out_dir = out_fi.filePath(); 2052 out_dir = out_fi.filePath();
1892 } 2053 }
2054 QString in_canonical_dir = QDir(in_dir).canonicalPath(),
2055 out_canonical_dir = QDir(out_dir).canonicalPath();
2056 if(!in_canonical_dir.isEmpty())
2057 in_dir = in_canonical_dir;
2058 if(!out_canonical_dir.isEmpty())
2059 out_dir = out_canonical_dir;
1893 } 2060 }
1894 if(out_dir != in_dir || !QDir::isRelativePath(qfile)) { 2061 if(out_dir != in_dir || !QDir::isRelativePath(qfile)) {
1895 if(QDir::isRelativePath(qfile)) { 2062 if(QDir::isRelativePath(qfile)) {
1896 if(file.left(Option::dir_sep.length()) != Option::dir_sep && 2063 if(file.left(Option::dir_sep.length()) != Option::dir_sep &&
1897 in_dir.right(Option::dir_sep.length()) != Option::dir_sep) 2064 in_dir.right(Option::dir_sep.length()) != Option::dir_sep)
1898 file.prepend(Option::dir_sep); 2065 file.prepend(Option::dir_sep);
1899 file.prepend(in_dir); 2066 file.prepend(in_dir);
1900 } 2067 }
1901 file = Option::fixPathToTargetOS(file, FALSE); 2068 file = Option::fixPathToTargetOS(file, FALSE);
2069 if(QFile::exists(file) && file == Option::fixPathToTargetOS(file, TRUE)) {
2070 QString real_file = QDir(file).canonicalPath();
2071 if(!real_file.isEmpty())
2072 file = real_file;
2073 }
1902 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE); 2074 QString match_dir = Option::fixPathToTargetOS(out_dir, FALSE);
1903 if(file == match_dir) { 2075 if(file == match_dir) {
1904 file = ""; 2076 file = "";
1905 } else if(file.startsWith(match_dir) && 2077 } else if(file.startsWith(match_dir) &&
1906 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { 2078 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) {
1907 file = file.right(file.length() - (match_dir.length() + 1)); 2079 file = file.right(file.length() - (match_dir.length() + 1));
1908 } else { 2080 } else {
1909 for(int i = 1; i <= depth; i++) { 2081 for(int i = 1; i <= depth; i++) {
1910 int sl = match_dir.findRev(Option::dir_sep); 2082 int sl = match_dir.findRev(Option::dir_sep);
1911 if(sl == -1) 2083 if(sl == -1)
1912 break; 2084 break;
1913 match_dir = match_dir.left(sl); 2085 match_dir = match_dir.left(sl);
1914 if(match_dir.isEmpty()) 2086 if(match_dir.isEmpty())
1915 break; 2087 break;
1916 if(file.startsWith(match_dir) && 2088 if(file.startsWith(match_dir) &&
1917 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) { 2089 file.mid(match_dir.length(), Option::dir_sep.length()) == Option::dir_sep) {
1918 //concat 2090 //concat
1919 int remlen = file.length() - (match_dir.length() + 1); 2091 int remlen = file.length() - (match_dir.length() + 1);
1920 if (remlen < 0) 2092 if (remlen < 0)
1921 remlen = 0; 2093 remlen = 0;
1922 file = file.right(remlen); 2094 file = file.right(remlen);
1923 //prepend 2095 //prepend
1924 for(int o = 0; o < i; o++) 2096 for(int o = 0; o < i; o++)
1925 file.prepend(".." + Option::dir_sep); 2097 file.prepend(".." + Option::dir_sep);
1926 } 2098 }
1927 } 2099 }
1928 } 2100 }
1929 } 2101 }
1930 } 2102 }
1931 file = Option::fixPathToTargetOS(file, FALSE); 2103 file = Option::fixPathToTargetOS(file, FALSE);
2104 if(file.isEmpty())
2105 file = ".";
1932 if(!quote.isNull()) 2106 if(!quote.isNull())
1933 file = quote + file + quote; 2107 file = quote + file + quote;
1934 debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth); 2108 debug_msg(3, "Fixed %s :: to :: %s (%d)", orig_file.latin1(), file.latin1(), depth);
2109 ((MakefileGenerator*)this)->fileFixed.insert(key, file);
1935 return file; 2110 return file;
1936} 2111}
1937 2112
1938QString 2113QString
1939MakefileGenerator::cleanFilePath(const QString &file) const 2114MakefileGenerator::cleanFilePath(const QString &file) const
1940{ 2115{
1941 return fileFixify(Option::fixPathToTargetOS(file)); 2116 return fileFixify(Option::fixPathToTargetOS(file));
1942} 2117}
1943 2118
1944void MakefileGenerator::logicWarn(const QString &f, const QString &w) 2119void MakefileGenerator::logicWarn(const QString &f, const QString &w)
1945{ 2120{
1946 if(!(Option::warn_level & WarnLogic)) 2121 if(!(Option::warn_level & WarnLogic))
1947 return; 2122 return;
1948 QString file = f; 2123 QString file = f;
1949 int slsh = f.findRev(Option::dir_sep); 2124 int slsh = f.findRev(Option::dir_sep);
1950 if(slsh != -1) 2125 if(slsh != -1)
1951 file = file.right(file.length() - slsh - 1); 2126 file = file.right(file.length() - slsh - 1);
1952 QStringList &l = project->variables()[w]; 2127 QStringList &l = project->variables()[w];
1953 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 2128 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
1954 QString file2((*val_it)); 2129 QString file2((*val_it));
1955 slsh = file2.findRev(Option::dir_sep); 2130 slsh = file2.findRev(Option::dir_sep);
1956 if(slsh != -1) 2131 if(slsh != -1)
1957 file2 = file2.right(file2.length() - slsh - 1); 2132 file2 = file2.right(file2.length() - slsh - 1);
1958 if(file2 == file) { 2133 if(file2 == file) {
@@ -2018,68 +2193,71 @@ MakefileGenerator::openOutput(QFile &file) const
2018 } 2193 }
2019 } 2194 }
2020 if(QDir::isRelativePath(file.name())) 2195 if(QDir::isRelativePath(file.name()))
2021 file.setName(Option::output_dir + file.name()); //pwd when qmake was run 2196 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
2022 if(project->isEmpty("QMAKE_MAKEFILE")) 2197 if(project->isEmpty("QMAKE_MAKEFILE"))
2023 project->variables()["QMAKE_MAKEFILE"].append(file.name()); 2198 project->variables()["QMAKE_MAKEFILE"].append(file.name());
2024 int slsh = file.name().findRev(Option::dir_sep); 2199 int slsh = file.name().findRev(Option::dir_sep);
2025 if(slsh != -1) 2200 if(slsh != -1)
2026 createDir(file.name().left(slsh)); 2201 createDir(file.name().left(slsh));
2027 if(file.open(IO_WriteOnly | IO_Translate)) { 2202 if(file.open(IO_WriteOnly | IO_Translate)) {
2028 QFileInfo fi(Option::output); 2203 QFileInfo fi(Option::output);
2029 QString od = Option::fixPathToTargetOS((fi.isSymLink() ? fi.readLink() : fi.dirPath()) ); 2204 QString od = Option::fixPathToTargetOS((fi.isSymLink() ? fi.readLink() : fi.dirPath()) );
2030 if(QDir::isRelativePath(od)) 2205 if(QDir::isRelativePath(od))
2031 od.prepend(Option::output_dir); 2206 od.prepend(Option::output_dir);
2032 Option::output_dir = od; 2207 Option::output_dir = od;
2033 return TRUE; 2208 return TRUE;
2034 } 2209 }
2035 return FALSE; 2210 return FALSE;
2036} 2211}
2037 2212
2038 2213
2039 2214
2040//Factory thing 2215//Factory thing
2041#include "unixmake.h" 2216#include "unixmake.h"
2042#include "borland_bmake.h"
2043#include "msvc_nmake.h" 2217#include "msvc_nmake.h"
2218#include "borland_bmake.h"
2219#include "mingw_make.h"
2044#include "msvc_dsp.h" 2220#include "msvc_dsp.h"
2045#include "msvc_vcproj.h" 2221#include "msvc_vcproj.h"
2046#include "metrowerks_xml.h" 2222#include "metrowerks_xml.h"
2047#include "pbuilder_pbx.h" 2223#include "pbuilder_pbx.h"
2048#include "projectgenerator.h" 2224#include "projectgenerator.h"
2049 2225
2050MakefileGenerator * 2226MakefileGenerator *
2051MakefileGenerator::create(QMakeProject *proj) 2227MakefileGenerator::create(QMakeProject *proj)
2052{ 2228{
2053 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) 2229 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)
2054 return new ProjectGenerator(proj); 2230 return new ProjectGenerator(proj);
2055 2231
2056 MakefileGenerator *mkfile = NULL; 2232 MakefileGenerator *mkfile = NULL;
2057 QString gen = proj->first("MAKEFILE_GENERATOR"); 2233 QString gen = proj->first("MAKEFILE_GENERATOR");
2058 if(gen.isEmpty()) { 2234 if(gen.isEmpty()) {
2059 fprintf(stderr, "No generator specified in config file: %s\n", 2235 fprintf(stderr, "No generator specified in config file: %s\n",
2060 proj->projectFile().latin1()); 2236 proj->projectFile().latin1());
2061 } else if(gen == "UNIX") { 2237 } else if(gen == "UNIX") {
2062 mkfile = new UnixMakefileGenerator(proj); 2238 mkfile = new UnixMakefileGenerator(proj);
2063 } else if(gen == "MSVC") { 2239 } else if(gen == "MSVC") {
2064 // Visual Studio =< v6.0 2240 // Visual Studio =< v6.0
2065 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) 2241 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
2066 mkfile = new DspMakefileGenerator(proj); 2242 mkfile = new DspMakefileGenerator(proj);
2067 else 2243 else
2068 mkfile = new NmakeMakefileGenerator(proj); 2244 mkfile = new NmakeMakefileGenerator(proj);
2069 } else if(gen == "MSVC.NET") { 2245 } else if(gen == "MSVC.NET") {
2070 // Visual Studio >= v7.0 2246 // Visual Studio >= v7.0
2071 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1) 2247 if(proj->first("TEMPLATE").find(QRegExp("^vc.*")) != -1)
2072 mkfile = new VcprojGenerator(proj); 2248 mkfile = new VcprojGenerator(proj);
2073 else 2249 else
2074 mkfile = new NmakeMakefileGenerator(proj); 2250 mkfile = new NmakeMakefileGenerator(proj);
2075 } else if(gen == "BMAKE") { 2251 } else if(gen == "BMAKE") {
2076 mkfile = new BorlandMakefileGenerator(proj); 2252 mkfile = new BorlandMakefileGenerator(proj);
2253 } else if(gen == "MINGW") {
2254 mkfile = new MingwMakefileGenerator(proj);
2077 } else if(gen == "METROWERKS") { 2255 } else if(gen == "METROWERKS") {
2078 mkfile = new MetrowerksMakefileGenerator(proj); 2256 mkfile = new MetrowerksMakefileGenerator(proj);
2079 } else if(gen == "PROJECTBUILDER") { 2257 } else if(gen == "PROJECTBUILDER") {
2080 mkfile = new ProjectBuilderMakefileGenerator(proj); 2258 mkfile = new ProjectBuilderMakefileGenerator(proj);
2081 } else { 2259 } else {
2082 fprintf(stderr, "Unknown generator specified: %s\n", gen.latin1()); 2260 fprintf(stderr, "Unknown generator specified: %s\n", gen.latin1());
2083 } 2261 }
2084 return mkfile; 2262 return mkfile;
2085} 2263}
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index 1d19d98..4fdabe8 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -1,104 +1,104 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __MAKEFILE_H__ 37#ifndef __MAKEFILE_H__
38#define __MAKEFILE_H__ 38#define __MAKEFILE_H__
39 39
40#include "option.h" 40#include "option.h"
41#include "project.h" 41#include "project.h"
42#include <qtextstream.h> 42#include <qtextstream.h>
43 43
44class MakefileGenerator 44class MakefileGenerator
45{ 45{
46 QString spec; 46 QString spec;
47 bool init_opath_already, init_already, moc_aware, no_io; 47 bool init_opath_already, init_already, moc_aware, no_io;
48 QStringList createObjectList(const QString &var); 48 QStringList createObjectList(const QString &var);
49 QString build_args(); 49 QString build_args();
50 QMap<QString, QString> depHeuristics, depKeyMap; 50 QMap<QString, QString> depHeuristics, depKeyMap, fileFixed;
51 QMap<QString, QString> mocablesToMOC, mocablesFromMOC; 51 QMap<QString, QString> mocablesToMOC, mocablesFromMOC;
52 QMap<QString, QStringList> depends; 52 QMap<QString, QStringList> depends;
53 53
54protected: 54protected:
55 void writeObj(QTextStream &, const QString &obj, const QString &src); 55 void writeObj(QTextStream &, const QString &obj, const QString &src);
56 void writeUicSrc(QTextStream &, const QString &ui); 56 void writeUicSrc(QTextStream &, const QString &ui);
57 void writeMocObj(QTextStream &, const QString &obj, const QString &src); 57 void writeMocObj(QTextStream &, const QString &obj, const QString &src);
58 void writeMocSrc(QTextStream &, const QString &src); 58 void writeMocSrc(QTextStream &, const QString &src);
59 void writeLexSrc(QTextStream &, const QString &lex); 59 void writeLexSrc(QTextStream &, const QString &lex);
60 void writeYaccSrc(QTextStream &, const QString &yac); 60 void writeYaccSrc(QTextStream &, const QString &yac);
61 void writeInstalls(QTextStream &t, const QString &installs); 61 void writeInstalls(QTextStream &t, const QString &installs);
62 void writeImageObj(QTextStream &t, const QString &obj); 62 void writeImageObj(QTextStream &t, const QString &obj);
63 void writeImageSrc(QTextStream &t, const QString &images); 63 void writeImageSrc(QTextStream &t, const QString &images);
64 64
65protected: 65protected:
66 66
67 QMakeProject *project; 67 QMakeProject *project;
68 68
69 class MakefileDependDir { 69 class MakefileDependDir {
70 public: 70 public:
71 MakefileDependDir(QString r, QString l) : real_dir(r), local_dir(l) { } 71 MakefileDependDir(const QString &r, const QString &l) : real_dir(r), local_dir(l) { }
72 QString real_dir, local_dir; 72 QString real_dir, local_dir;
73 }; 73 };
74 bool generateDependencies(QPtrList<MakefileDependDir> &dirs, QString x, bool recurse); 74 bool generateDependencies(QPtrList<MakefileDependDir> &dirs, const QString &x, bool recurse);
75 75
76 QString buildArgs(); 76 QString buildArgs();
77 77
78 QString specdir(); 78 QString specdir();
79 QString cleanFilePath(const QString &file) const; 79 QString cleanFilePath(const QString &file) const;
80 bool generateMocList(QString fn); 80 bool generateMocList(const QString &fn);
81 81
82 QString findMocSource(const QString &moc_file) const; 82 QString findMocSource(const QString &moc_file) const;
83 QString findMocDestination(const QString &src_file) const; 83 QString findMocDestination(const QString &src_file) const;
84 QStringList &findDependencies(const QString &file); 84 QStringList &findDependencies(const QString &file);
85 85
86 void setNoIO(bool o); 86 void setNoIO(bool o);
87 bool noIO() const; 87 bool noIO() const;
88 88
89 void setMocAware(bool o); 89 void setMocAware(bool o);
90 bool mocAware() const; 90 bool mocAware() const;
91 void logicWarn(const QString &, const QString &); 91 void logicWarn(const QString &, const QString &);
92 92
93 virtual bool doDepends() const { return Option::mkfile::do_deps; } 93 virtual bool doDepends() const { return Option::mkfile::do_deps; }
94 bool writeHeader(QTextStream &); 94 bool writeHeader(QTextStream &);
95 virtual bool writeMakefile(QTextStream &); 95 virtual bool writeMakefile(QTextStream &);
96 virtual bool writeMakeQmake(QTextStream &); 96 virtual bool writeMakeQmake(QTextStream &);
97 void initOutPaths(); 97 void initOutPaths();
98 virtual void init(); 98 virtual void init();
99 99
100 //for installs 100 //for installs
101 virtual QString defaultInstall(const QString &); 101 virtual QString defaultInstall(const QString &);
102 102
103 //for prl 103 //for prl
104 bool processPrlFile(QString &); 104 bool processPrlFile(QString &);
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index 5ff6250..1515216 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -21,88 +21,96 @@
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "projectgenerator.h" 38#include "projectgenerator.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qfileinfo.h> 42#include <qfileinfo.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45QString project_builtin_regx() //calculate the builtin regular expression..
46{
47 QString ret;
48 QStringList builtin_exts(".c");
49 builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext << ".ts";
50 builtin_exts += Option::h_ext + Option::cpp_ext;
51 for(QStringList::Iterator ext_it = builtin_exts.begin();
52 ext_it != builtin_exts.end(); ++ext_it) {
53 if(!ret.isEmpty())
54 ret += "; ";
55 ret += QString("*") + (*ext_it);
56 }
57 return ret;
58}
59
60
45 61
46ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE) 62ProjectGenerator::ProjectGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE)
47{ 63{
48} 64}
49 65
50void 66void
51ProjectGenerator::init() 67ProjectGenerator::init()
52{ 68{
53 if(init_flag) 69 if(init_flag)
54 return; 70 return;
55 int file_count = 0; 71 int file_count = 0;
56 init_flag = TRUE; 72 init_flag = TRUE;
57 73
58 QMap<QString, QStringList> &v = project->variables(); 74 QMap<QString, QStringList> &v = project->variables();
59 QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template; 75 QString templ = Option::user_template.isEmpty() ? QString("app") : Option::user_template;
60 if(!Option::user_template_prefix.isEmpty()) 76 if(!Option::user_template_prefix.isEmpty())
61 templ.prepend(Option::user_template_prefix); 77 templ.prepend(Option::user_template_prefix);
62 v["TEMPLATE_ASSIGN"] += templ; 78 v["TEMPLATE_ASSIGN"] += templ;
63 79
64 //figure out target 80 //figure out target
65 if(Option::output.name() == "-" || Option::output.name().isEmpty()) 81 if(Option::output.name() == "-" || Option::output.name().isEmpty())
66 v["TARGET"] = QStringList("unknown"); 82 v["TARGET"] = QStringList("unknown");
67 83
68 //the scary stuff 84 //the scary stuff
69 if(project->first("TEMPLATE_ASSIGN") != "subdirs") { 85 if(project->first("TEMPLATE_ASSIGN") != "subdirs") {
70 QString builtin_regex; 86 QString builtin_regex = project_builtin_regx();
71 { //calculate the builtin regular expression..
72 QStringList builtin_exts(".c");
73 builtin_exts << Option::ui_ext << Option::yacc_ext << Option::lex_ext;
74 builtin_exts += Option::h_ext + Option::cpp_ext;
75 for(QStringList::Iterator ext_it = builtin_exts.begin();
76 ext_it != builtin_exts.end(); ++ext_it) {
77 if(!builtin_regex.isEmpty())
78 builtin_regex += "; ";
79 builtin_regex += QString("*") + (*ext_it);
80 }
81 }
82 QStringList dirs = Option::projfile::project_dirs; 87 QStringList dirs = Option::projfile::project_dirs;
83 if(Option::projfile::do_pwd) 88 if(Option::projfile::do_pwd) {
89 if(!v["INCLUDEPATH"].contains("."))
90 v["INCLUDEPATH"] += ".";
84 dirs.prepend(QDir::currentDirPath()); 91 dirs.prepend(QDir::currentDirPath());
92 }
85 93
86 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { 94 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
87 QString dir, regex; 95 QString dir, regex;
88 bool add_depend = FALSE; 96 bool add_depend = FALSE;
89 if(QFile::exists((*pd))) { 97 if(QFile::exists((*pd))) {
90 QFileInfo fi((*pd)); 98 QFileInfo fi((*pd));
91 if(fi.isDir()) { 99 if(fi.isDir()) {
92 dir = (*pd); 100 dir = (*pd);
93 add_depend = TRUE; 101 add_depend = TRUE;
94 if(dir.right(1) != Option::dir_sep) 102 if(dir.right(1) != Option::dir_sep)
95 dir += Option::dir_sep; 103 dir += Option::dir_sep;
96 if(Option::projfile::do_recursive) { 104 if(Option::projfile::do_recursive) {
97 QDir d(dir); 105 QDir d(dir);
98 d.setFilter(QDir::Dirs); 106 d.setFilter(QDir::Dirs);
99 for(int i = 0; i < (int)d.count(); i++) { 107 for(int i = 0; i < (int)d.count(); i++) {
100 if(d[i] != "." && d[i] != "..") 108 if(d[i] != "." && d[i] != "..")
101 dirs.append(dir + d[i] + QDir::separator() + builtin_regex); 109 dirs.append(dir + d[i] + QDir::separator() + builtin_regex);
102 } 110 }
103 } 111 }
104 regex = builtin_regex; 112 regex = builtin_regex;
105 } else { 113 } else {
106 QString file = (*pd); 114 QString file = (*pd);
107 int s = file.findRev(Option::dir_sep); 115 int s = file.findRev(Option::dir_sep);
108 if(s != -1) 116 if(s != -1)
@@ -119,51 +127,50 @@ ProjectGenerator::init()
119 int s = regex.findRev(Option::dir_sep); 127 int s = regex.findRev(Option::dir_sep);
120 if(s != -1) { 128 if(s != -1) {
121 dir = regex.left(s+1); 129 dir = regex.left(s+1);
122 regex = regex.right(regex.length() - (s+1)); 130 regex = regex.right(regex.length() - (s+1));
123 } 131 }
124 if(Option::projfile::do_recursive) { 132 if(Option::projfile::do_recursive) {
125 QDir d(dir); 133 QDir d(dir);
126 d.setFilter(QDir::Dirs); 134 d.setFilter(QDir::Dirs);
127 for(int i = 0; i < (int)d.count(); i++) { 135 for(int i = 0; i < (int)d.count(); i++) {
128 if(d[i] != "." && d[i] != "..") 136 if(d[i] != "." && d[i] != "..")
129 dirs.append(dir + d[i] + QDir::separator() + regex); 137 dirs.append(dir + d[i] + QDir::separator() + regex);
130 } 138 }
131 } 139 }
132 QDir d(dir, regex); 140 QDir d(dir, regex);
133 for(int i = 0; i < (int)d.count(); i++) { 141 for(int i = 0; i < (int)d.count(); i++) {
134 QString file = dir + d[i]; 142 QString file = dir + d[i];
135 if (addFile(file)) { 143 if (addFile(file)) {
136 add_depend = TRUE; 144 add_depend = TRUE;
137 file_count++; 145 file_count++;
138 } 146 }
139 } 147 }
140 } 148 }
141 if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) { 149 if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir)) {
142 QFileInfo fi(dir); 150 QFileInfo fi(dir);
143 if(fi.absFilePath() != QDir::currentDirPath()) { 151 if(fi.absFilePath() != QDir::currentDirPath())
144 v["DEPENDPATH"] += fileFixify(dir); 152 v["DEPENDPATH"] += fileFixify(dir);
145 }
146 } 153 }
147 } 154 }
148 } 155 }
149 if(!file_count) { //shall we try a subdir? 156 if(!file_count) { //shall we try a subdir?
150 QStringList dirs = Option::projfile::project_dirs; 157 QStringList dirs = Option::projfile::project_dirs;
151 if(Option::projfile::do_pwd) 158 if(Option::projfile::do_pwd)
152 dirs.prepend("."); 159 dirs.prepend(".");
153 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) { 160 for(QStringList::Iterator pd = dirs.begin(); pd != dirs.end(); pd++) {
154 if(QFile::exists((*pd))) { 161 if(QFile::exists((*pd))) {
155 QString newdir = (*pd); 162 QString newdir = (*pd);
156 QFileInfo fi(newdir); 163 QFileInfo fi(newdir);
157 if(fi.isDir()) { 164 if(fi.isDir()) {
158 newdir = fileFixify(newdir); 165 newdir = fileFixify(newdir);
159 QStringList &subdirs = v["SUBDIRS"]; 166 QStringList &subdirs = v["SUBDIRS"];
160 if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") && 167 if(QFile::exists(fi.filePath() + QDir::separator() + fi.fileName() + ".pro") &&
161 !subdirs.contains(newdir)) { 168 !subdirs.contains(newdir)) {
162 subdirs.append(newdir); 169 subdirs.append(newdir);
163 } else { 170 } else {
164 QDir d(newdir, "*.pro"); 171 QDir d(newdir, "*.pro");
165 d.setFilter(QDir::Files); 172 d.setFilter(QDir::Files);
166 for(int i = 0; i < (int)d.count(); i++) { 173 for(int i = 0; i < (int)d.count(); i++) {
167 QString nd = newdir + QDir::separator() + d[i]; 174 QString nd = newdir + QDir::separator() + d[i];
168 fileFixify(nd); 175 fileFixify(nd);
169 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) { 176 if(d[i] != "." && d[i] != ".." && !subdirs.contains(nd)) {
@@ -220,72 +227,81 @@ ProjectGenerator::init()
220 } 227 }
221 v["TEMPLATE_ASSIGN"] = "subdirs"; 228 v["TEMPLATE_ASSIGN"] = "subdirs";
222 return; 229 return;
223 } 230 }
224 231
225 QPtrList<MakefileDependDir> deplist; 232 QPtrList<MakefileDependDir> deplist;
226 deplist.setAutoDelete(TRUE); 233 deplist.setAutoDelete(TRUE);
227 { 234 {
228 QStringList &d = v["DEPENDPATH"]; 235 QStringList &d = v["DEPENDPATH"];
229 for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) { 236 for(QStringList::Iterator it = d.begin(); it != d.end(); ++it) {
230 QString r = (*it), l = Option::fixPathToLocalOS((*it)); 237 QString r = (*it), l = Option::fixPathToLocalOS((*it));
231 deplist.append(new MakefileDependDir(r, l)); 238 deplist.append(new MakefileDependDir(r, l));
232 } 239 }
233 } 240 }
234 QStringList &h = v["HEADERS"]; 241 QStringList &h = v["HEADERS"];
235 bool no_qt_files = TRUE; 242 bool no_qt_files = TRUE;
236 QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null }; 243 QString srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "INTERFACES", QString::null };
237 for(int i = 0; !srcs[i].isNull(); i++) { 244 for(int i = 0; !srcs[i].isNull(); i++) {
238 QStringList &l = v[srcs[i]]; 245 QStringList &l = v[srcs[i]];
239 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) { 246 for(QStringList::Iterator val_it = l.begin(); val_it != l.end(); ++val_it) {
240 if(generateDependencies(deplist, (*val_it), TRUE)) { 247 if(generateDependencies(deplist, (*val_it), TRUE)) {
241 QStringList &tmp = findDependencies((*val_it)); 248 QStringList &tmp = findDependencies((*val_it));
242 if(!tmp.isEmpty()) { 249 if(!tmp.isEmpty()) {
243 for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) { 250 for(QStringList::Iterator dep_it = tmp.begin(); dep_it != tmp.end(); ++dep_it) {
244 QString file_no_path = (*dep_it).right( 251 QString file_dir = (*dep_it).section(Option::dir_sep, 0, -2),
245 (*dep_it).length() - ((*dep_it).findRev(Option::dir_sep)+1)); 252 file_no_path = (*dep_it).section(Option::dir_sep, -1);
253 if(!file_dir.isEmpty()) {
254 for(MakefileDependDir *mdd = deplist.first(); mdd; mdd = deplist.next()) {
255 if(mdd->local_dir == file_dir && !v["INCLUDEPATH"].contains(mdd->real_dir))
256 v["INCLUDEPATH"] += mdd->real_dir;
257 }
258 }
246 if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1) 259 if(no_qt_files && file_no_path.find(QRegExp("^q[a-z_0-9].h$")) != -1)
247 no_qt_files = FALSE; 260 no_qt_files = FALSE;
248 QString h_ext; 261 QString h_ext;
249 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { 262 for(QStringList::Iterator hit = Option::h_ext.begin();
263 hit != Option::h_ext.end(); ++hit) {
250 if((*dep_it).endsWith((*hit))) { 264 if((*dep_it).endsWith((*hit))) {
251 h_ext = (*hit); 265 h_ext = (*hit);
252 break; 266 break;
253 } 267 }
254 } 268 }
255 if(!h_ext.isEmpty()) { 269 if(!h_ext.isEmpty()) {
256 if((*dep_it).left(1).lower() == "q") { 270 if((*dep_it).left(1).lower() == "q") {
257 QString qhdr = (*dep_it).lower(); 271 QString qhdr = (*dep_it).lower();
258 if(file_no_path == "qthread.h") 272 if(file_no_path == "qthread.h")
259 addConfig("thread"); 273 addConfig("thread");
260 } 274 }
261 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 275 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
262 cppit != Option::cpp_ext.end(); ++cppit) { 276 cppit != Option::cpp_ext.end(); ++cppit) {
263 QString src((*dep_it).left((*dep_it).length() - h_ext.length()) + (*cppit)); 277 QString src((*dep_it).left((*dep_it).length() - h_ext.length()) +
278 (*cppit));
264 if(QFile::exists(src)) { 279 if(QFile::exists(src)) {
265 bool exists = FALSE; 280 bool exists = FALSE;
266 QStringList &srcl = v["SOURCES"]; 281 QStringList &srcl = v["SOURCES"];
267 for(QStringList::Iterator src_it = srcl.begin(); src_it != srcl.end(); ++src_it) { 282 for(QStringList::Iterator src_it = srcl.begin();
283 src_it != srcl.end(); ++src_it) {
268 if((*src_it).lower() == src.lower()) { 284 if((*src_it).lower() == src.lower()) {
269 exists = TRUE; 285 exists = TRUE;
270 break; 286 break;
271 } 287 }
272 } 288 }
273 if(!exists) 289 if(!exists)
274 srcl.append(src); 290 srcl.append(src);
275 } 291 }
276 } 292 }
277 } else if((*dep_it).endsWith(Option::lex_ext) && 293 } else if((*dep_it).endsWith(Option::lex_ext) &&
278 file_no_path.startsWith(Option::lex_mod)) { 294 file_no_path.startsWith(Option::lex_mod)) {
279 addConfig("lex_included"); 295 addConfig("lex_included");
280 } 296 }
281 if(!h.contains((*dep_it))) { 297 if(!h.contains((*dep_it))) {
282 if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty()) 298 if(generateMocList((*dep_it)) && !findMocDestination((*dep_it)).isEmpty())
283 h += (*dep_it); 299 h += (*dep_it);
284 } 300 }
285 } 301 }
286 } 302 }
287 } 303 }
288 } 304 }
289 } 305 }
290 if(h.isEmpty()) 306 if(h.isEmpty())
291 addConfig("moc", FALSE); 307 addConfig("moc", FALSE);
@@ -316,56 +332,58 @@ ProjectGenerator::init()
316 ++val_it; 332 ++val_it;
317 } 333 }
318 } 334 }
319 } 335 }
320} 336}
321 337
322 338
323bool 339bool
324ProjectGenerator::writeMakefile(QTextStream &t) 340ProjectGenerator::writeMakefile(QTextStream &t)
325{ 341{
326 t << "######################################################################" << endl; 342 t << "######################################################################" << endl;
327 t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl; 343 t << "# Automatically generated by qmake (" << qmake_version() << ") " << QDateTime::currentDateTime().toString() << endl;
328 t << "######################################################################" << endl << endl; 344 t << "######################################################################" << endl << endl;
329 QStringList::Iterator it; 345 QStringList::Iterator it;
330 for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) 346 for(it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it)
331 t << (*it) << endl; 347 t << (*it) << endl;
332 t << getWritableVar("TEMPLATE_ASSIGN", FALSE); 348 t << getWritableVar("TEMPLATE_ASSIGN", FALSE);
333 if(project->first("TEMPLATE_ASSIGN") == "subdirs") { 349 if(project->first("TEMPLATE_ASSIGN") == "subdirs") {
334 t << endl << "# Directories" << "\n" 350 t << endl << "# Directories" << "\n"
335 << getWritableVar("SUBDIRS"); 351 << getWritableVar("SUBDIRS");
336 } else { 352 } else {
337 t << getWritableVar("TARGET") 353 t << getWritableVar("TARGET")
338 << getWritableVar("CONFIG", FALSE) 354 << getWritableVar("CONFIG", FALSE)
339 << getWritableVar("CONFIG_REMOVE", FALSE) 355 << getWritableVar("CONFIG_REMOVE", FALSE)
340 << getWritableVar("DEPENDPATH") << endl; 356 << getWritableVar("DEPENDPATH")
357 << getWritableVar("INCLUDEPATH") << endl;
341 358
342 t << "# Input" << "\n"; 359 t << "# Input" << "\n";
343 t << getWritableVar("HEADERS") 360 t << getWritableVar("HEADERS")
344 << getWritableVar("INTERFACES") 361 << getWritableVar("INTERFACES")
345 << getWritableVar("LEXSOURCES") 362 << getWritableVar("LEXSOURCES")
346 << getWritableVar("YACCSOURCES") 363 << getWritableVar("YACCSOURCES")
347 << getWritableVar("SOURCES"); 364 << getWritableVar("SOURCES")
365 << getWritableVar("TRANSLATIONS");
348 } 366 }
349 for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) 367 for(it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it)
350 t << (*it) << endl; 368 t << (*it) << endl;
351 return TRUE; 369 return TRUE;
352} 370}
353 371
354bool 372bool
355ProjectGenerator::addConfig(const QString &cfg, bool add) 373ProjectGenerator::addConfig(const QString &cfg, bool add)
356{ 374{
357 QString where = "CONFIG"; 375 QString where = "CONFIG";
358 if(!add) 376 if(!add)
359 where = "CONFIG_REMOVE"; 377 where = "CONFIG_REMOVE";
360 if(!project->variables()[where].contains(cfg)) { 378 if(!project->variables()[where].contains(cfg)) {
361 project->variables()[where] += cfg; 379 project->variables()[where] += cfg;
362 return TRUE; 380 return TRUE;
363 } 381 }
364 return FALSE; 382 return FALSE;
365} 383}
366 384
367 385
368bool 386bool
369ProjectGenerator::addFile(QString file) 387ProjectGenerator::addFile(QString file)
370{ 388{
371 file = fileFixify(file, QDir::currentDirPath()); 389 file = fileFixify(file, QDir::currentDirPath());
@@ -382,48 +400,50 @@ ProjectGenerator::addFile(QString file)
382 if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext)) 400 if(QFile::exists(file.left(file.length() - (*cppit).length()) + Option::ui_ext))
383 return FALSE; 401 return FALSE;
384 else 402 else
385 where = "SOURCES"; 403 where = "SOURCES";
386 break; 404 break;
387 } 405 }
388 } 406 }
389 if(where.isEmpty()) { 407 if(where.isEmpty()) {
390 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) { 408 for(QStringList::Iterator hit = Option::h_ext.begin(); hit != Option::h_ext.end(); ++hit) {
391 if(file.endsWith((*hit))) { 409 if(file.endsWith((*hit))) {
392 where = "HEADERS"; 410 where = "HEADERS";
393 break; 411 break;
394 } 412 }
395 } 413 }
396 } 414 }
397 if(where.isEmpty()) { 415 if(where.isEmpty()) {
398 if(file.endsWith(Option::ui_ext)) 416 if(file.endsWith(Option::ui_ext))
399 where = "INTERFACES"; 417 where = "INTERFACES";
400 else if(file.endsWith(".c")) 418 else if(file.endsWith(".c"))
401 where = "SOURCES"; 419 where = "SOURCES";
402 else if(file.endsWith(Option::lex_ext)) 420 else if(file.endsWith(Option::lex_ext))
403 where = "LEXSOURCES"; 421 where = "LEXSOURCES";
404 else if(file.endsWith(Option::yacc_ext)) 422 else if(file.endsWith(Option::yacc_ext))
405 where = "YACCSOURCES"; 423 where = "YACCSOURCES";
424 else if(file.endsWith(".ts"))
425 where = "TRANSLATIONS";
406 } 426 }
407 427
408 QString newfile = fileFixify(file); 428 QString newfile = fileFixify(file);
409 if(!where.isEmpty() && !project->variables()[where].contains(file)) { 429 if(!where.isEmpty() && !project->variables()[where].contains(file)) {
410 project->variables()[where] += newfile; 430 project->variables()[where] += newfile;
411 return TRUE; 431 return TRUE;
412 } 432 }
413 return FALSE; 433 return FALSE;
414} 434}
415 435
416 436
417QString 437QString
418ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/) 438ProjectGenerator::getWritableVar(const QString &v, bool /*fixPath*/)
419{ 439{
420 QStringList &vals = project->variables()[v]; 440 QStringList &vals = project->variables()[v];
421 if(vals.isEmpty()) 441 if(vals.isEmpty())
422 return ""; 442 return "";
423 443
424 QString ret; 444 QString ret;
425 if(v.endsWith("_REMOVE")) 445 if(v.endsWith("_REMOVE"))
426 ret = v.left(v.length() - 7) + " -= "; 446 ret = v.left(v.length() - 7) + " -= ";
427 else if(v.endsWith("_ASSIGN")) 447 else if(v.endsWith("_ASSIGN"))
428 ret = v.left(v.length() - 7) + " = "; 448 ret = v.left(v.length() - 7) + " = ";
429 else 449 else
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 7df95b2..e274481 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -1,32 +1,32 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
@@ -51,60 +51,59 @@ UnixMakefileGenerator::init()
51 return; 51 return;
52 init_flag = TRUE; 52 init_flag = TRUE;
53 53
54 if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */ 54 if(!project->isEmpty("QMAKE_FAILED_REQUIREMENTS")) /* no point */
55 return; 55 return;
56 56
57 QStringList &configs = project->variables()["CONFIG"]; 57 QStringList &configs = project->variables()["CONFIG"];
58 /* this should probably not be here, but I'm using it to wrap the .t files */ 58 /* this should probably not be here, but I'm using it to wrap the .t files */
59 if(project->first("TEMPLATE") == "app") 59 if(project->first("TEMPLATE") == "app")
60 project->variables()["QMAKE_APP_FLAG"].append("1"); 60 project->variables()["QMAKE_APP_FLAG"].append("1");
61 else if(project->first("TEMPLATE") == "lib") 61 else if(project->first("TEMPLATE") == "lib")
62 project->variables()["QMAKE_LIB_FLAG"].append("1"); 62 project->variables()["QMAKE_LIB_FLAG"].append("1");
63 else if(project->first("TEMPLATE") == "subdirs") { 63 else if(project->first("TEMPLATE") == "subdirs") {
64 MakefileGenerator::init(); 64 MakefileGenerator::init();
65 if(project->isEmpty("MAKEFILE")) 65 if(project->isEmpty("MAKEFILE"))
66 project->variables()["MAKEFILE"].append("Makefile"); 66 project->variables()["MAKEFILE"].append("Makefile");
67 if(project->isEmpty("QMAKE")) 67 if(project->isEmpty("QMAKE"))
68 project->variables()["QMAKE"].append("qmake"); 68 project->variables()["QMAKE"].append("qmake");
69 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) 69 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
70 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); 70 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
71 return; /* subdirs is done */ 71 return; /* subdirs is done */
72 } 72 }
73 73
74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) { 74 if( project->isEmpty("QMAKE_EXTENSION_SHLIB") ) {
75 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 75 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
76 if ( os == "cygwin" ) {
77 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
78 } else {
79 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" ); 76 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "so" );
77 } else {
78 project->variables()["QMAKE_EXTENSION_SHLIB"].append( "dll" );
80 } 79 }
81 } 80 }
82 if( project->isEmpty("QMAKE_COPY_FILE") ) 81 if( project->isEmpty("QMAKE_COPY_FILE") )
83 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" ); 82 project->variables()["QMAKE_COPY_FILE"].append( "$(COPY) -p" );
84 if( project->isEmpty("QMAKE_COPY_DIR") ) 83 if( project->isEmpty("QMAKE_COPY_DIR") )
85 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" ); 84 project->variables()["QMAKE_COPY_DIR"].append( "$(COPY) -pR" );
86 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET 85 //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
87 if(!project->isEmpty("TARGET")) { 86 if(!project->isEmpty("TARGET")) {
88 QString targ = project->first("TARGET"); 87 QString targ = project->first("TARGET");
89 int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep)); 88 int slsh = QMAX(targ.findRev('/'), targ.findRev(Option::dir_sep));
90 if(slsh != -1) { 89 if(slsh != -1) {
91 if(project->isEmpty("DESTDIR")) 90 if(project->isEmpty("DESTDIR"))
92 project->values("DESTDIR").append(""); 91 project->values("DESTDIR").append("");
93 else if(project->first("DESTDIR").right(1) != Option::dir_sep) 92 else if(project->first("DESTDIR").right(1) != Option::dir_sep)
94 project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep; 93 project->variables()["DESTDIR"] = project->first("DESTDIR") + Option::dir_sep;
95 project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1); 94 project->variables()["DESTDIR"] = project->first("DESTDIR") + targ.left(slsh+1);
96 project->variables()["TARGET"] = targ.mid(slsh+1); 95 project->variables()["TARGET"] = targ.mid(slsh+1);
97 } 96 }
98 } 97 }
99 98
100 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 99 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
101 100
102 bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" || 101 bool is_qt = (project->first("TARGET") == "qt" || project->first("TARGET") == "qte" ||
103 project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt"); 102 project->first("TARGET") == "qt-mt" || project->first("TARGET") == "qte-mt");
104 bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") || 103 bool extern_libs = !project->isEmpty("QMAKE_APP_FLAG") ||
105 (!project->isEmpty("QMAKE_LIB_FLAG") && 104 (!project->isEmpty("QMAKE_LIB_FLAG") &&
106 project->isActiveConfig("dll")) || is_qt; 105 project->isActiveConfig("dll")) || is_qt;
107 if(!project->isActiveConfig("global_init_link_order")) 106 if(!project->isActiveConfig("global_init_link_order"))
108 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 107 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
109 if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) || 108 if ( (!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) ||
110 (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) { 109 (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) {
@@ -117,120 +116,120 @@ UnixMakefileGenerator::init()
117 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; 116 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
118 } else if ( project->isActiveConfig("warn_on") ) { 117 } else if ( project->isActiveConfig("warn_on") ) {
119 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; 118 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
120 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; 119 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
121 } 120 }
122 if ( project->isActiveConfig("debug") ) { 121 if ( project->isActiveConfig("debug") ) {
123 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; 122 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
124 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; 123 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
125 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; 124 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
126 } else { 125 } else {
127 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; 126 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
128 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; 127 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
129 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; 128 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
130 } 129 }
131 if(!project->isEmpty("QMAKE_INCREMENTAL")) 130 if(!project->isEmpty("QMAKE_INCREMENTAL"))
132 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_INCREMENTAL"]; 131 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_INCREMENTAL"];
133 else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") && 132 else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
134 !project->variables()["QMAKE_LIB_FLAG"].isEmpty() && 133 !project->variables()["QMAKE_LIB_FLAG"].isEmpty() &&
135 project->isActiveConfig("dll")) 134 project->isActiveConfig("dll"))
136 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"]; 135 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PREBIND"];
137 if(!project->isEmpty("QMAKE_INCDIR")) 136 if(!project->isEmpty("QMAKE_INCDIR"))
138 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 137 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
139 if(!project->isEmpty("QMAKE_LIBDIR")) { 138 if(!project->isEmpty("QMAKE_LIBDIR")) {
140 if ( !project->isEmpty("QMAKE_RPATH") ) 139 if ( !project->isEmpty("QMAKE_RPATH") )
141 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"), 140 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR", " " + var("QMAKE_RPATH"),
142 " " + var("QMAKE_RPATH"), ""); 141 " " + var("QMAKE_RPATH"), "");
143 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" ); 142 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue( "QMAKE_LIBDIR", "-L", " -L", "" );
144 } 143 }
145 if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) { 144 if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) {
146 if(configs.findIndex("x11lib") == -1) 145 if(configs.findIndex("x11lib") == -1)
147 configs.append("x11lib"); 146 configs.append("x11lib");
148 if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 ) 147 if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 )
149 configs.append("x11inc"); 148 configs.append("x11inc");
150 } 149 }
151 if ( project->isActiveConfig("x11") ) { 150 if ( project->isActiveConfig("x11") ) {
152 if(configs.findIndex("x11lib") == -1) 151 if(configs.findIndex("x11lib") == -1)
153 configs.append("x11lib"); 152 configs.append("x11lib");
154 if(configs.findIndex("x11inc") == -1) 153 if(configs.findIndex("x11inc") == -1)
155 configs.append("x11inc"); 154 configs.append("x11inc");
156 } 155 }
157 if ( project->isActiveConfig("qt") ) { 156 if ( project->isActiveConfig("qt") ) {
158 if ( project->isActiveConfig("accessibility" ) ) 157 if ( project->isActiveConfig("accessibility" ) )
159 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); 158 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
160 if ( project->isActiveConfig("tablet") ) 159 if ( project->isActiveConfig("tablet") )
161 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 160 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
162 if(configs.findIndex("moc")) configs.append("moc"); 161 if(configs.findIndex("moc")) configs.append("moc");
163 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; 162 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
164 if ( !project->isActiveConfig("debug") ) 163 if ( !project->isActiveConfig("debug") )
165 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 164 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
166 if ( !is_qt ) { 165 if ( !is_qt ) {
167 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) { 166 if ( !project->isEmpty("QMAKE_LIBDIR_QT") ) {
168 if ( !project->isEmpty("QMAKE_RPATH") ) 167 if ( !project->isEmpty("QMAKE_RPATH") )
169 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"), 168 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", " " + var("QMAKE_RPATH"),
170 " " + var("QMAKE_RPATH"), ""); 169 " " + var("QMAKE_RPATH"), "");
171 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", ""); 170 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_QT", "-L", " -L", "");
172 } 171 }
173 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD")) 172 if (project->isActiveConfig("thread") && !project->isEmpty("QMAKE_LIBS_QT_THREAD"))
174 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 173 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
175 else 174 else
176 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 175 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
177 } 176 }
178 } 177 }
179 if ( project->isActiveConfig("thread") ) {
180 if(project->isActiveConfig("qt"))
181 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
182 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
183 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
184 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
185 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
186 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
187 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
188 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
189 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
190 }
191 if ( project->isActiveConfig("opengl") ) { 178 if ( project->isActiveConfig("opengl") ) {
192 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"]; 179 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_OPENGL"];
193 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL")) 180 if(!project->isEmpty("QMAKE_LIBDIR_OPENGL"))
194 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", ""); 181 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_OPENGL", "-L", " -L", "");
195 if ( is_qt ) 182 if ( is_qt )
196 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"]; 183 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL_QT"];
197 else 184 else
198 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 185 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
199 } 186 }
200 if(project->isActiveConfig("global_init_link_order")) 187 if(project->isActiveConfig("global_init_link_order"))
201 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 188 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
202 if ( project->isActiveConfig("x11sm") )
203 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
204 if ( project->isActiveConfig("dylib") )
205 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
206 if ( project->isActiveConfig("x11inc") ) 189 if ( project->isActiveConfig("x11inc") )
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"]; 190 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_X11"];
208 if ( project->isActiveConfig("x11lib") ) { 191 if ( project->isActiveConfig("x11lib") ) {
209 if(!project->isEmpty("QMAKE_LIBDIR_X11")) 192 if(!project->isEmpty("QMAKE_LIBDIR_X11"))
210 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", ""); 193 project->variables()["QMAKE_LIBDIR_FLAGS"] += varGlue("QMAKE_LIBDIR_X11", "-L", " -L", "");
211 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"]; 194 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11"];
212 } 195 }
196 if ( project->isActiveConfig("x11sm") )
197 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_X11SM"];
198 if ( project->isActiveConfig("dylib") )
199 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_DYNLOAD"];
200 if ( project->isActiveConfig("thread") ) {
201 if(project->isActiveConfig("qt"))
202 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
203 if ( !project->isEmpty("QMAKE_CFLAGS_THREAD"))
204 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"];
205 if( !project->isEmpty("QMAKE_CXXFLAGS_THREAD"))
206 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"];
207 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_THREAD"];
208 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_THREAD"];
209 if(!project->isEmpty("QMAKE_LFLAGS_THREAD"))
210 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"];
211 }
213 if ( project->isActiveConfig("moc") ) 212 if ( project->isActiveConfig("moc") )
214 setMocAware(TRUE); 213 setMocAware(TRUE);
215 if ( project->isEmpty("QMAKE_RUN_CC") ) 214 if ( project->isEmpty("QMAKE_RUN_CC") )
216 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src"); 215 project->variables()["QMAKE_RUN_CC"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src");
217 if ( project->isEmpty("QMAKE_RUN_CC_IMP") ) 216 if ( project->isEmpty("QMAKE_RUN_CC_IMP") )
218 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<"); 217 project->variables()["QMAKE_RUN_CC_IMP"].append("$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<");
219 if ( project->isEmpty("QMAKE_RUN_CXX") ) 218 if ( project->isEmpty("QMAKE_RUN_CXX") )
220 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src"); 219 project->variables()["QMAKE_RUN_CXX"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src");
221 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") ) 220 if ( project->isEmpty("QMAKE_RUN_CXX_IMP") )
222 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<"); 221 project->variables()["QMAKE_RUN_CXX_IMP"].append("$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<");
223 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " "); 222 project->variables()["QMAKE_FILETAGS"] += QStringList::split("HEADERS SOURCES TARGET DESTDIR", " ");
224 if ( !project->isEmpty("PRECOMPH") ) { 223 if ( !project->isEmpty("PRECOMPH") ) {
225 initOutPaths(); // Need to fix MOC_DIR since we do this before init() 224 initOutPaths(); // Need to fix MOC_DIR since we do this before init()
226 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir); 225 QString allmoc = fileFixify(project->first("MOC_DIR") + "/allmoc.cpp", QDir::currentDirPath(), Option::output_dir);
227 project->variables()["SOURCES"].prepend(allmoc); 226 project->variables()["SOURCES"].prepend(allmoc);
228 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"]; 227 project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"];
229 project->variables()["HEADERS"].clear(); 228 project->variables()["HEADERS"].clear();
230 } 229 }
231 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS")) 230 if( project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
232 include_deps = TRUE; //do not generate deps 231 include_deps = TRUE; //do not generate deps
233 232
234 MakefileGenerator::init(); 233 MakefileGenerator::init();
235 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 234 if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
236 if(!project->isEmpty("QMAKE_APP_FLAG")) { 235 if(!project->isEmpty("QMAKE_APP_FLAG")) {
@@ -319,202 +318,287 @@ UnixMakefileGenerator::uniqueSetLFlags(const QStringList &list1, QStringList &li
319 framework_out = (*outit); 318 framework_out = (*outit);
320 } 319 }
321 } 320 }
322 if(framework_out == framework_in) { 321 if(framework_out == framework_in) {
323 unique = FALSE; 322 unique = FALSE;
324 break; 323 break;
325 } 324 }
326 } 325 }
327 } 326 }
328 if(unique) { 327 if(unique) {
329 unique = FALSE; //because I'm about to just insert it myself 328 unique = FALSE; //because I'm about to just insert it myself
330 if(as_one) { 329 if(as_one) {
331 ret.append("-framework " + framework_in); 330 ret.append("-framework " + framework_in);
332 } else { 331 } else {
333 ret.append("-framework"); 332 ret.append("-framework");
334 ret.append(framework_in); 333 ret.append(framework_in);
335 } 334 }
336 } 335 }
337 } 336 }
338 } else { 337 } else {
339 unique = (list2.findIndex((*it)) == -1); 338 unique = (list2.findIndex((*it)) == -1);
340 } 339 }
341 } else if(QFile::exists((*it))) { 340 } else if(QFile::exists((*it))) {
342 unique = (list2.findIndex((*it)) == -1); 341 unique = (list2.findIndex((*it)) == -1);
343 } 342 }
344 if(unique) 343 if(unique)
345 ret.append((*it)); 344 ret.append((*it));
346 } 345 }
347 return ret; 346 return ret;
348} 347}
349 348
350 349
351void 350void
352UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 351UnixMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
353{ 352{
354 if(var == "QMAKE_PRL_LIBS") 353 if(var == "QMAKE_PRL_LIBS")
355 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]); 354 project->variables()["QMAKE_CURRENT_PRL_LIBS"] += uniqueSetLFlags(l, project->variables()["QMAKE_LIBS"]);
356 else 355 else
357 MakefileGenerator::processPrlVariable(var, l); 356 MakefileGenerator::processPrlVariable(var, l);
358} 357}
359 358
359bool
360UnixMakefileGenerator::findLibraries()
361{
362 QPtrList<MakefileDependDir> libdirs;
363 libdirs.setAutoDelete(TRUE);
364 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
365 for(int i = 0; !lflags[i].isNull(); i++) {
366 QStringList &l = project->variables()[lflags[i]];
367 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
368 QString stub, dir, extn, opt = (*it).stripWhiteSpace();
369 if(opt.startsWith("-")) {
370 if(opt.startsWith("-L")) {
371 QString r = opt.right(opt.length() - 2), l = r;
372 fixEnvVariables(l);
373 libdirs.append(new MakefileDependDir(r.replace("\"",""),
374 l.replace("\"","")));
375 } else if(opt.startsWith("-l")) {
376 stub = opt.mid(2);
377 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
378 if(opt.length() > 11) {
379 opt = opt.mid(11);
380 } else {
381 ++it;
382 opt = (*it);
383 }
384 extn = "";
385 dir = "/System/Library/Frameworks/" + opt + ".framework/";
386 stub = opt;
387 }
388 } else {
389 extn = dir = "";
390 stub = opt;
391 int slsh = opt.findRev(Option::dir_sep);
392 if(slsh != -1) {
393 dir = opt.left(slsh);
394 stub = opt.mid(slsh+1);
395 }
396 QRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
397 if(stub_reg.exactMatch(stub)) {
398 stub = stub_reg.cap(1);
399 extn = stub_reg.cap(2);
400 }
401 }
402 if(!stub.isEmpty()) {
403 const QString modifs[] = { "-mt", QString::null };
404 for(int modif = 0; !modifs[modif].isNull(); modif++) {
405 bool found = FALSE;
406 QStringList extens;
407 if(!extn.isNull())
408 extens << extn;
409 else
410 extens << project->variables()["QMAKE_EXTENSION_SHLIB"].first() << "a";
411 for(QStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
412 if(dir.isNull()) {
413 QString lib_stub;
414 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
415 if(QFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub +
416 modifs[modif] + "." + (*extit))) {
417 lib_stub = stub + modifs[modif];
418 break;
419 }
420 }
421 if(!lib_stub.isNull()) {
422 (*it) = "-l" + lib_stub;
423 found = TRUE;
424 break;
425 }
426 } else {
427 if(QFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) {
428 (*it) = "lib" + stub + modifs[modif] + "." + (*extit);
429 found = TRUE;
430 break;
431 }
432 }
433 }
434 if(found)
435 break;
436 }
437 }
438 }
439 }
440 return FALSE;
441}
442
360void 443void
361UnixMakefileGenerator::processPrlFiles() 444UnixMakefileGenerator::processPrlFiles()
362{ 445{
363 QDict<void> processed; 446 QDict<void> processed;
364 QPtrList<MakefileDependDir> libdirs; 447 QPtrList<MakefileDependDir> libdirs;
365 libdirs.setAutoDelete(TRUE); 448 libdirs.setAutoDelete(TRUE);
366 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; 449 const QString lflags[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
367 for(int i = 0; !lflags[i].isNull(); i++) { 450 for(int i = 0; !lflags[i].isNull(); i++) {
368 for(bool ret = FALSE; TRUE; ret = FALSE) { 451 for(bool ret = FALSE; TRUE; ret = FALSE) {
369 QStringList l_out; 452 QStringList l_out;
370 QStringList &l = project->variables()[lflags[i]]; 453 QStringList &l = project->variables()[lflags[i]];
371 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 454 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
372 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear(); 455 project->variables()["QMAKE_CURRENT_PRL_LIBS"].clear();
373 QString opt = (*it).stripWhiteSpace();; 456 QString opt = (*it).stripWhiteSpace();;
374 if(opt.startsWith("-")) { 457 if(opt.startsWith("-")) {
375 if(opt.startsWith("-L")) { 458 if(opt.startsWith("-L")) {
376 QString r = opt.right(opt.length() - 2), l = r; 459 QString r = opt.right(opt.length() - 2), l = r;
377 fixEnvVariables(l); 460 fixEnvVariables(l);
378 libdirs.append(new MakefileDependDir(r.replace("\"",""), 461 libdirs.append(new MakefileDependDir(r.replace("\"",""),
379 l.replace("\"",""))); 462 l.replace("\"","")));
380 } else if(opt.startsWith("-l") && !processed[opt]) { 463 } else if(opt.startsWith("-l") && !processed[opt]) {
381 QString lib = opt.right(opt.length() - 2), prl; 464 QString lib = opt.right(opt.length() - 2), prl;
382 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 465 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
383 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext; 466 prl = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::prl_ext;
384 if(processPrlFile(prl)) { 467 if(processPrlFile(prl)) {
385 if(prl.startsWith(mdd->local_dir)) 468 if(prl.startsWith(mdd->local_dir))
386 prl.replace(0, mdd->local_dir.length(), mdd->real_dir); 469 prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
387 QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$"); 470 QRegExp reg("^.*lib(" + lib + "[^./=]*)\\..*$");
388 if(reg.exactMatch(prl)) 471 if(reg.exactMatch(prl))
389 prl = "-l" + reg.cap(1); 472 prl = "-l" + reg.cap(1);
390 opt = prl; 473 opt = prl;
391 processed.insert(opt, (void*)1); 474 processed.insert(opt, (void*)1);
392 ret = TRUE; 475 ret = TRUE;
393 break; 476 break;
394 } 477 }
395 } 478 }
396 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) { 479 } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
397 if(opt.length() > 11) { 480 if(opt.length() > 11) {
398 opt = opt.mid(11); 481 opt = opt.mid(11);
399 } else { 482 } else {
400 ++it; 483 ++it;
401 opt = (*it); 484 opt = (*it);
402 } 485 }
403 QString prl = "/System/Library/Frameworks/" + opt + 486 QString prl = "/System/Library/Frameworks/" + opt +
404 ".framework/" + opt + Option::prl_ext; 487 ".framework/" + opt + Option::prl_ext;
405 if(processPrlFile(prl)) 488 if(processPrlFile(prl))
406 ret = TRUE; 489 ret = TRUE;
407 l_out.append("-framework"); 490 l_out.append("-framework");
408 } 491 }
409 if(!opt.isEmpty()) 492 if(!opt.isEmpty())
410 l_out.append(opt); 493 l_out.append(opt);
411 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); 494 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out);
412 } else { 495 } else {
413 if(!processed[opt] && processPrlFile(opt)) { 496 if(!processed[opt] && processPrlFile(opt)) {
414 processed.insert(opt, (void*)1); 497 processed.insert(opt, (void*)1);
415 ret = TRUE; 498 ret = TRUE;
416 } 499 }
417 if(!opt.isEmpty()) 500 if(!opt.isEmpty())
418 l_out.append(opt); 501 l_out.append(opt);
419 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out); 502 l_out += uniqueSetLFlags(project->variables()["QMAKE_CURRENT_PRL_LIBS"], l_out);
420 } 503 }
421 } 504 }
422 if(ret && l != l_out) 505 if(ret && l != l_out)
423 l = l_out; 506 l = l_out;
424 else 507 else
425 break; 508 break;
426 } 509 }
427 } 510 }
428} 511}
429 512
430QString 513QString
431UnixMakefileGenerator::defaultInstall(const QString &t) 514UnixMakefileGenerator::defaultInstall(const QString &t)
432{ 515{
433 if(t != "target" || project->first("TEMPLATE") == "subdirs") 516 if(t != "target" || project->first("TEMPLATE") == "subdirs")
434 return QString(); 517 return QString();
435 518
436 bool resource = FALSE; 519 bool resource = FALSE;
520 const QString root = "$(INSTALL_ROOT)";
437 QStringList &uninst = project->variables()[t + ".uninstall"]; 521 QStringList &uninst = project->variables()[t + ".uninstall"];
438 QString ret, destdir=fileFixify(project->first("DESTDIR")); 522 QString ret, destdir=project->first("DESTDIR");
439 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE); 523 QString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE);
440 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) 524 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
441 destdir += Option::dir_sep; 525 destdir += Option::dir_sep;
442 targetdir = "$(INSTALL_ROOT)" + Option::fixPathToTargetOS(targetdir, FALSE); 526 targetdir = fileFixify(targetdir);
443 if(targetdir.right(1) != Option::dir_sep) 527 if(targetdir.right(1) != Option::dir_sep)
444 targetdir += Option::dir_sep; 528 targetdir += Option::dir_sep;
445 529
446 QStringList links; 530 QStringList links;
447 QString target="$(TARGET)"; 531 QString target="$(TARGET)";
448 if(project->first("TEMPLATE") == "app") { 532 if(project->first("TEMPLATE") == "app") {
449 target = "$(QMAKE_TARGET)"; 533 target = "$(QMAKE_TARGET)";
450 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 534 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
451 destdir += "../../../"; 535 destdir += "../../../";
452 target += ".app"; 536 target += ".app";
453 resource = TRUE; 537 resource = TRUE;
454 } 538 }
455 } else if(project->first("TEMPLATE") == "lib") { 539 } else if(project->first("TEMPLATE") == "lib") {
456 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { 540 if(project->isActiveConfig("create_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) {
457 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE"); 541 QString dst_prl = project->first("QMAKE_INTERNAL_PRL_FILE");
458 int slsh = dst_prl.findRev('/'); 542 int slsh = dst_prl.findRev('/');
459 if(slsh != -1) 543 if(slsh != -1)
460 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); 544 dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
461 dst_prl = targetdir + dst_prl; 545 dst_prl = root + targetdir + dst_prl;
462 ret += "-$(COPY) " + project->first("QMAKE_INTERNAL_PRL_FILE") + " " + dst_prl; 546 ret += "-$(COPY) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
463 if(!uninst.isEmpty()) 547 if(!uninst.isEmpty())
464 uninst.append("\n\t"); 548 uninst.append("\n\t");
465 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); 549 uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
466 } 550 }
467 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 ); 551 if ( project->isEmpty("QMAKE_CYGWIN_SHLIB") ) {
468 if ( os != "cygwin" ) {
469 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) { 552 if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
470 if ( os == "hpux" ) { 553 if ( project->isEmpty("QMAKE_HPUX_SHLIB") ) {
471 links << "$(TARGET0)";
472 } else {
473 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)"; 554 links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
555 } else {
556 links << "$(TARGET0)";
474 } 557 }
475 } 558 }
476 } 559 }
477 } 560 }
478 QString src_targ = target; 561 QString src_targ = target;
479 if(!destdir.isEmpty()) 562 if(!destdir.isEmpty())
480 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE); 563 src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
481 QString dst_targ = fileFixify(targetdir + target); 564 QString dst_targ = root + fileFixify(targetdir + target);
482 if(!ret.isEmpty()) 565 if(!ret.isEmpty())
483 ret += "\n\t"; 566 ret += "\n\t";
484 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" + 567 ret += QString(resource ? "-$(COPY_DIR)" : "-$(COPY)") + " \"" +
485 src_targ + "\" \"" + dst_targ + "\""; 568 src_targ + "\" \"" + dst_targ + "\"";
486 if(!project->isEmpty("QMAKE_STRIP")) { 569 if(!project->isActiveConfig("debug") && !project->isEmpty("QMAKE_STRIP")) {
487 ret += "\n\t-" + var("QMAKE_STRIP"); 570 ret += "\n\t-" + var("QMAKE_STRIP");
571 if(!project->isEmpty("QMAKE_STRIPFLAGS_LIB") && project->first("TEMPLATE") == "lib")
572 ret += " " + var("QMAKE_STRIPFLAGS_LIB");
488 if(resource) 573 if(resource)
489 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)"; 574 ret = " \"" + dst_targ + "/Contents/MacOS/$(QMAKE_TARGET)\"";
490 else 575 else
491 ret += " \"" + dst_targ + "\""; 576 ret += " \"" + dst_targ + "\"";
492 } 577 }
493 if(!uninst.isEmpty()) 578 if(!uninst.isEmpty())
494 uninst.append("\n\t"); 579 uninst.append("\n\t");
495 if(resource) 580 if(resource)
496 uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\""); 581 uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
497 else 582 else
498 uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); 583 uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
499 if(!links.isEmpty()) { 584 if(!links.isEmpty()) {
500 for(QStringList::Iterator it = links.begin(); it != links.end(); it++) { 585 for(QStringList::Iterator it = links.begin(); it != links.end(); it++) {
501 if(Option::target_mode == Option::TARG_WIN_MODE || 586 if(Option::target_mode == Option::TARG_WIN_MODE ||
502 Option::target_mode == Option::TARG_MAC9_MODE) { 587 Option::target_mode == Option::TARG_MAC9_MODE) {
503 } else if(Option::target_mode == Option::TARG_UNIX_MODE || 588 } else if(Option::target_mode == Option::TARG_UNIX_MODE ||
504 Option::target_mode == Option::TARG_MACX_MODE) { 589 Option::target_mode == Option::TARG_MACX_MODE) {
505 QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE); 590 QString link = Option::fixPathToTargetOS(destdir + (*it), FALSE);
506 int lslash = link.findRev(Option::dir_sep); 591 int lslash = link.findRev(Option::dir_sep);
507 if(lslash != -1) 592 if(lslash != -1)
508 link = link.right(link.length() - (lslash + 1)); 593 link = link.right(link.length() - (lslash + 1));
509 QString dst_link = fileFixify(targetdir + link); 594 QString dst_link = root + fileFixify(targetdir + link);
510 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\""; 595 ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
511 if(!uninst.isEmpty()) 596 if(!uninst.isEmpty())
512 uninst.append("\n\t"); 597 uninst.append("\n\t");
513 uninst.append("-$(DEL_FILE) \"" + dst_link + "\""); 598 uninst.append("-$(DEL_FILE) \"" + dst_link + "\"");
514 } 599 }
515 } 600 }
516 } 601 }
517 return ret; 602 return ret;
518} 603}
519 604
520
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
index e889dcc..3d00214 100644
--- a/qmake/generators/unix/unixmake.h
+++ b/qmake/generators/unix/unixmake.h
@@ -34,38 +34,39 @@
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __UNIXMAKE_H__ 37#ifndef __UNIXMAKE_H__
38#define __UNIXMAKE_H__ 38#define __UNIXMAKE_H__
39 39
40#include "makefile.h" 40#include "makefile.h"
41 41
42class UnixMakefileGenerator : public MakefileGenerator 42class UnixMakefileGenerator : public MakefileGenerator
43{ 43{
44 bool init_flag, include_deps; 44 bool init_flag, include_deps;
45 bool writeMakefile(QTextStream &); 45 bool writeMakefile(QTextStream &);
46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2); 46 QStringList uniqueSetLFlags(const QStringList &list1, QStringList &list2);
47 47
48public: 48public:
49 UnixMakefileGenerator(QMakeProject *p); 49 UnixMakefileGenerator(QMakeProject *p);
50 ~UnixMakefileGenerator(); 50 ~UnixMakefileGenerator();
51 51
52protected: 52protected:
53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); } 53 virtual bool doDepends() const { return !include_deps && MakefileGenerator::doDepends(); }
54 virtual QString defaultInstall(const QString &); 54 virtual QString defaultInstall(const QString &);
55 virtual void processPrlVariable(const QString &, const QStringList &); 55 virtual void processPrlVariable(const QString &, const QStringList &);
56 virtual void processPrlFiles(); 56 virtual void processPrlFiles();
57 57
58 virtual bool findLibraries();
58 virtual void init(); 59 virtual void init();
59 60
60 void writeMakeParts(QTextStream &); 61 void writeMakeParts(QTextStream &);
61 void writeSubdirs(QTextStream &, bool=TRUE); 62 void writeSubdirs(QTextStream &, bool=TRUE);
62 63
63private: 64private:
64 void init2(); 65 void init2();
65}; 66};
66 67
67inline UnixMakefileGenerator::~UnixMakefileGenerator() 68inline UnixMakefileGenerator::~UnixMakefileGenerator()
68{ } 69{ }
69 70
70 71
71#endif /* __UNIXMAKE_H__ */ 72#endif /* __UNIXMAKE_H__ */
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 9bb6f6b..7fbb9f4 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -58,106 +58,113 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t)
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 59 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t); 60 writeMakeQmake(t);
61 return TRUE; 61 return TRUE;
62 } 62 }
63 63
64 if (project->variables()["TEMPLATE"].first() == "app" || 64 if (project->variables()["TEMPLATE"].first() == "app" ||
65 project->variables()["TEMPLATE"].first() == "lib") { 65 project->variables()["TEMPLATE"].first() == "lib") {
66 writeMakeParts(t); 66 writeMakeParts(t);
67 return MakefileGenerator::writeMakefile(t); 67 return MakefileGenerator::writeMakefile(t);
68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") { 68 } else if(project->variables()["TEMPLATE"].first() == "subdirs") {
69 writeSubdirs(t); 69 writeSubdirs(t);
70 return TRUE; 70 return TRUE;
71 } 71 }
72 return FALSE; 72 return FALSE;
73} 73}
74 74
75void 75void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t) 76UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{ 77{
78 QString deps = fileFixify(Option::output.name()), prl; 78 QString deps = fileFixify(Option::output.name()), prl;
79 bool do_incremental = (project->isActiveConfig("incremental") && 79 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && 80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || 81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
82 !project->isActiveConfig("staticlib"))), 82 !project->isActiveConfig("staticlib"))),
83 src_incremental=FALSE, moc_incremental=FALSE; 83 src_incremental=FALSE, moc_incremental=FALSE;
84 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
85 84
86 t << "####### Compiler, tools and options" << endl << endl; 85 t << "####### Compiler, tools and options" << endl << endl;
87 t << "CC = "; 86 t << "CC = ";
88 if (project->isActiveConfig("thread") && 87 if (project->isActiveConfig("thread") &&
89 ! project->variables()["QMAKE_CC_THREAD"].isEmpty()) 88 ! project->variables()["QMAKE_CC_THREAD"].isEmpty())
90 t << var("QMAKE_CC_THREAD") << endl; 89 t << var("QMAKE_CC_THREAD") << endl;
91 else 90 else
92 t << var("QMAKE_CC") << endl; 91 t << var("QMAKE_CC") << endl;
93 92
94 t << "CXX = "; 93 t << "CXX = ";
95 if (project->isActiveConfig("thread") && 94 if (project->isActiveConfig("thread") &&
96 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty()) 95 ! project->variables()["QMAKE_CXX_THREAD"].isEmpty())
97 t << var("QMAKE_CXX_THREAD") << endl; 96 t << var("QMAKE_CXX_THREAD") << endl;
98 else 97 else
99 t << var("QMAKE_CXX") << endl; 98 t << var("QMAKE_CXX") << endl;
100 99
101 t << "LEX = " << var("QMAKE_LEX") << endl; 100 t << "LEX = " << var("QMAKE_LEX") << endl;
102 t << "YACC = " << var("QMAKE_YACC") << endl; 101 t << "YACC = " << var("QMAKE_YACC") << endl;
103 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " 102 t << "CFLAGS = " << var("QMAKE_CFLAGS") << " "
104 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 103 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
105 << varGlue("DEFINES","-D"," -D","") << endl; 104 << varGlue("DEFINES","-D"," -D","") << endl;
106 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " 105 t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " "
107 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " 106 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
108 << varGlue("DEFINES","-D"," -D","") << endl; 107 << varGlue("DEFINES","-D"," -D","") << endl;
109 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; 108 t << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
110 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl; 109 t << "YACCFLAGS= " << var("QMAKE_YACCFLAGS") << endl;
111 t << "INCPATH = " << varGlue("INCLUDEPATH","-I", " -I", "") << " -I" << specdir() << endl; 110 t << "INCPATH = " << "-I" << specdir();
111 if(!project->isActiveConfig("no_include_pwd")) {
112 QString pwd = fileFixify(QDir::currentDirPath());
113 if(pwd.isEmpty())
114 pwd = ".";
115 t << " -I" << pwd;
116 }
117 t << varGlue("INCLUDEPATH"," -I", " -I", "") << endl;
112 118
113 if(!project->isActiveConfig("staticlib")) { 119 if(!project->isActiveConfig("staticlib")) {
114 t << "LINK = "; 120 t << "LINK = ";
115 if (project->isActiveConfig("thread") && 121 if (project->isActiveConfig("thread") &&
116 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty()) 122 ! project->variables()["QMAKE_LINK_THREAD"].isEmpty())
117 t << var("QMAKE_LINK_THREAD") << endl; 123 t << var("QMAKE_LINK_THREAD") << endl;
118 else 124 else
119 t << var("QMAKE_LINK") << endl; 125 t << var("QMAKE_LINK") << endl;
120 126
121 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; 127 t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl;
122 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl; 128 t << "LIBS = " << "$(SUBLIBS) " << var("QMAKE_LIBDIR_FLAGS") << " " << var("QMAKE_LIBS") << endl;
123 } 129 }
124 130
125 t << "AR = " << var("QMAKE_AR") << endl; 131 t << "AR = " << var("QMAKE_AR") << endl;
126 t << "RANLIB = " << var("QMAKE_RANLIB") << endl; 132 t << "RANLIB = " << var("QMAKE_RANLIB") << endl;
127 t << "MOC = " << var("QMAKE_MOC") << endl; 133 t << "MOC = " << var("QMAKE_MOC") << endl;
128 t << "UIC = "<< var("QMAKE_UIC") << endl; 134 t << "UIC = "<< var("QMAKE_UIC") << endl;
129 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 135 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
130 t << "TAR = "<< var("QMAKE_TAR") << endl; 136 t << "TAR = "<< var("QMAKE_TAR") << endl;
131 t << "GZIP = " << var("QMAKE_GZIP") << endl; 137 t << "GZIP = " << var("QMAKE_GZIP") << endl;
132 t << "COPY = " << var("QMAKE_COPY") << endl; 138 t << "COPY = " << var("QMAKE_COPY") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; 139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
134 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; 140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
135 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
136 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; 142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
137 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 143 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
138 t << "MOVE = " << var("QMAKE_MOVE") << endl; 144 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "PRO = " << fileFixify(project->projectFile() )<< endl; 145 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
146 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
140 t << endl; 147 t << endl;
141 148
142 t << "####### Output directory" << endl << endl; 149 t << "####### Output directory" << endl << endl;
143 if (! project->variables()["OBJECTS_DIR"].isEmpty()) 150 if (! project->variables()["OBJECTS_DIR"].isEmpty())
144 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl; 151 t << "OBJECTS_DIR = " << var("OBJECTS_DIR") << endl;
145 else 152 else
146 t << "OBJECTS_DIR = ./" << endl; 153 t << "OBJECTS_DIR = ./" << endl;
147 t << endl; 154 t << endl;
148 155
149 /* files */ 156 /* files */
150 t << "####### Files" << endl << endl; 157 t << "####### Files" << endl << endl;
151 t << "HEADERS = " << varList("HEADERS") << endl; 158 t << "HEADERS = " << varList("HEADERS") << endl;
152 t << "SOURCES = " << varList("SOURCES") << endl; 159 t << "SOURCES = " << varList("SOURCES") << endl;
153 if(do_incremental) { 160 if(do_incremental) {
154 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out; 161 QStringList &objs = project->variables()["OBJECTS"], &incrs = project->variables()["QMAKE_INCREMENTAL"], incrs_out;
155 t << "OBJECTS = "; 162 t << "OBJECTS = ";
156 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) { 163 for(QStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
157 bool increment = FALSE; 164 bool increment = FALSE;
158 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 165 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
159 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 166 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
160 increment = TRUE; 167 increment = TRUE;
161 incrs_out.append((*objit)); 168 incrs_out.append((*objit));
162 break; 169 break;
163 } 170 }
@@ -191,98 +198,96 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
191 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) { 198 for(QStringList::Iterator incrit = incrs.begin(); incrit != incrs.end(); ++incrit) {
192 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) { 199 if((*objit).find(QRegExp((*incrit), TRUE, TRUE)) != -1) {
193 increment = TRUE; 200 increment = TRUE;
194 incrs_out.append((*objit)); 201 incrs_out.append((*objit));
195 break; 202 break;
196 } 203 }
197 } 204 }
198 if(!increment) 205 if(!increment)
199 t << "\\\n\t\t" << (*objit); 206 t << "\\\n\t\t" << (*objit);
200 } 207 }
201 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! 208 if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done!
202 t << incrs_out.join(" \\\n\t\t") << endl; 209 t << incrs_out.join(" \\\n\t\t") << endl;
203 } else if(!incrs_out.count()) { 210 } else if(!incrs_out.count()) {
204 t << endl; 211 t << endl;
205 } else { 212 } else {
206 moc_incremental = TRUE; 213 moc_incremental = TRUE;
207 t << endl; 214 t << endl;
208 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl; 215 t << "INCREMENTAL_OBJMOC = " << incrs_out.join(" \\\n\t\t") << endl;
209 } 216 }
210 } else { 217 } else {
211 t << "OBJMOC = " << objMoc << endl; 218 t << "OBJMOC = " << objMoc << endl;
212 } 219 }
213 if(do_incremental && !moc_incremental && !src_incremental) 220 if(do_incremental && !moc_incremental && !src_incremental)
214 do_incremental = FALSE; 221 do_incremental = FALSE;
215 t << "DIST = " << varList("DISTFILES") << endl; 222 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
216 t << "PRO = " << fileFixify(project->projectFile()) << endl;
217 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; 223 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
218 t << "DESTDIR = " << var("DESTDIR") << endl; 224 t << "DESTDIR = " << var("DESTDIR") << endl;
219 t << "TARGET = " << var("TARGET") << endl; 225 t << "TARGET = " << var("TARGET") << endl;
220 if(project->isActiveConfig("plugin") ) { 226 if(project->isActiveConfig("plugin") ) {
221 t << "TARGETD = " << var("TARGET") << endl; 227 t << "TARGETD = " << var("TARGET") << endl;
222 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 228 } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
223 t << "TARGETA= " << var("TARGETA") << endl; 229 t << "TARGETA= " << var("TARGETA") << endl;
224 if (os == "hpux") { 230 if (project->isEmpty("QMAKE_HPUX_SHLIB")) {
225 t << "TARGETD= " << var("TARGET_x") << endl;
226 t << "TARGET0= " << var("TARGET_") << endl;
227 }
228 else {
229 t << "TARGETD= " << var("TARGET_x.y.z") << endl; 231 t << "TARGETD= " << var("TARGET_x.y.z") << endl;
230 t << "TARGET0= " << var("TARGET_") << endl; 232 t << "TARGET0= " << var("TARGET_") << endl;
231 t << "TARGET1= " << var("TARGET_x") << endl; 233 t << "TARGET1= " << var("TARGET_x") << endl;
232 t << "TARGET2= " << var("TARGET_x.y") << endl; 234 t << "TARGET2= " << var("TARGET_x.y") << endl;
235 } else {
236 t << "TARGETD= " << var("TARGET_x") << endl;
237 t << "TARGET0= " << var("TARGET_") << endl;
233 } 238 }
234 } 239 }
235 t << endl; 240 t << endl;
236 241
237 // blasted incldues 242 // blasted incldues
238 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; 243 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
239 QStringList::Iterator it; 244 QStringList::Iterator it;
240 for( it = qeui.begin(); it != qeui.end(); ++it) 245 for( it = qeui.begin(); it != qeui.end(); ++it)
241 t << "include " << (*it) << endl; 246 t << "include " << (*it) << endl;
242 247
243 /* rules */ 248 /* rules */
244 t << "first: all" << endl; 249 t << "first: all" << endl;
245 t << "####### Implicit rules" << endl << endl; 250 t << "####### Implicit rules" << endl << endl;
246 t << ".SUFFIXES: .c"; 251 t << ".SUFFIXES: .c";
247 QStringList::Iterator cppit; 252 QStringList::Iterator cppit;
248 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 253 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
249 t << " " << (*cppit); 254 t << " " << (*cppit);
250 t << endl << endl; 255 t << endl << endl;
251 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 256 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
252 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 257 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
253 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 258 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
254 259
255 if(include_deps) { 260 if(include_deps) {
256 QString cmd=var("QMAKE_CFLAGS_DEPS") + " "; 261 QString cmd=var("QMAKE_CFLAGS_DEPS") + " ";
257 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D",""); 262 cmd += varGlue("DEFINES","-D"," -D","") + varGlue("PRL_EXPORT_DEFINES"," -D"," -D","");
258 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) 263 if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
259 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " "; 264 cmd += " -I" + project->first("QMAKE_ABSOLUTE_SOURCE_PATH") + " ";
260 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", ""); 265 cmd += " $(INCPATH) " + varGlue("DEPENDPATH", "-I", " -I", "");
261 QString odir; 266 QString odir;
262 if(!project->variables()["OBJECTS_DIR"].isEmpty()) 267 if(!project->variables()["OBJECTS_DIR"].isEmpty())
263 odir = project->first("OBJECTS_DIR"); 268 odir = project->first("OBJECTS_DIR");
264 t << "###### Dependancies" << endl << endl; 269 t << "###### Dependencies" << endl << endl;
265 t << odir << ".deps/%.d: %.cpp\n\t" 270 t << odir << ".deps/%.d: %.cpp\n\t"
266 << "@echo Creating depend for $<" << "\n\t" 271 << "@echo Creating depend for $<" << "\n\t"
267 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 272 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
268 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 273 << "@$(CXX) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
269 274
270 t << odir << ".deps/%.d: %.c\n\t" 275 t << odir << ".deps/%.d: %.c\n\t"
271 << "@echo Creating depend for $<" << "\n\t" 276 << "@echo Creating depend for $<" << "\n\t"
272 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t" 277 << "@test -d $(@D) || mkdir -p $(@D)" << "\n\t"
273 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 278 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
274 279
275 280
276 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; 281 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
277 for(int x = 0; !src[x].isNull(); x++) { 282 for(int x = 0; !src[x].isNull(); x++) {
278 QStringList &l = project->variables()[src[x]]; 283 QStringList &l = project->variables()[src[x]];
279 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 284 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
280 if(!(*it).isEmpty()) { 285 if(!(*it).isEmpty()) {
281 QString d_file; 286 QString d_file;
282 if((*it).endsWith(".c")) { 287 if((*it).endsWith(".c")) {
283 d_file = (*it).left((*it).length() - 2); 288 d_file = (*it).left((*it).length() - 2);
284 } else { 289 } else {
285 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); 290 for(QStringList::Iterator cppit = Option::cpp_ext.begin();
286 cppit != Option::cpp_ext.end(); ++cppit) { 291 cppit != Option::cpp_ext.end(); ++cppit) {
287 if((*it).endsWith((*cppit))) { 292 if((*it).endsWith((*cppit))) {
288 d_file = (*it).left((*it).length() - (*cppit).length()); 293 d_file = (*it).left((*it).length() - (*cppit).length());
@@ -365,62 +370,64 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
365 if(!destdir.isEmpty()) 370 if(!destdir.isEmpty())
366 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 371 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
367 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << 372 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
368 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; 373 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
369 //communicated below 374 //communicated below
370 if(!destdir.isEmpty()) { 375 if(!destdir.isEmpty()) {
371 if(!incr_objs.isEmpty()) 376 if(!incr_objs.isEmpty())
372 incr_objs += " "; 377 incr_objs += " ";
373 incr_objs += "-L" + destdir; 378 incr_objs += "-L" + destdir;
374 } else { 379 } else {
375 if(!incr_objs.isEmpty()) 380 if(!incr_objs.isEmpty())
376 incr_objs += " "; 381 incr_objs += " ";
377 incr_objs += "-L" + QDir::currentDirPath(); 382 incr_objs += "-L" + QDir::currentDirPath();
378 } 383 }
379 if(!incr_objs.isEmpty()) 384 if(!incr_objs.isEmpty())
380 incr_objs += " "; 385 incr_objs += " ";
381 incr_objs += " -l" + incr_target; 386 incr_objs += " -l" + incr_target;
382 deps.prepend(incr_target_dir + " "); 387 deps.prepend(incr_target_dir + " ");
383 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 388 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
384 } 389 }
385 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" 390 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
386 << endl << endl; 391 << endl << endl;
387 392
388 //real target 393 //real target
389 t << var("TARGET") << ": " << " " << incr_deps << " " << var("TARGETDEPS") << "\n\t"; 394 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps
395 << " " << var("POST_TARGETDEPS") << "\n\t";
390 if(!destdir.isEmpty()) 396 if(!destdir.isEmpty())
391 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 397 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
392 if(!project->isEmpty("QMAKE_PRE_LINK")) 398 if(!project->isEmpty("QMAKE_PRE_LINK"))
393 t << var("QMAKE_PRE_LINK") << "\n\t"; 399 t << var("QMAKE_PRE_LINK") << "\n\t";
394 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; 400 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)";
395 if(!project->isEmpty("QMAKE_POST_LINK")) 401 if(!project->isEmpty("QMAKE_POST_LINK"))
396 t << "\n\t" << var("QMAKE_POST_LINK"); 402 t << "\n\t" << var("QMAKE_POST_LINK");
397 t << endl << endl; 403 t << endl << endl;
398 } else { 404 } else {
399 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" 405 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)"
400 << endl << endl; 406 << endl << endl;
401 407
402 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS") << "\n\t"; 408 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
409 << var("POST_TARGETDEPS") << "\n\t";
403 if(!destdir.isEmpty()) 410 if(!destdir.isEmpty())
404 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 411 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
405 if(!project->isEmpty("QMAKE_PRE_LINK")) 412 if(!project->isEmpty("QMAKE_PRE_LINK"))
406 t << var("QMAKE_PRE_LINK") << "\n\t"; 413 t << var("QMAKE_PRE_LINK") << "\n\t";
407 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 414 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)";
408 if(!project->isEmpty("QMAKE_POST_LINK")) 415 if(!project->isEmpty("QMAKE_POST_LINK"))
409 t << "\n\t" << var("QMAKE_POST_LINK"); 416 t << "\n\t" << var("QMAKE_POST_LINK");
410 t << endl << endl; 417 t << endl << endl;
411 } 418 }
412 } else if(!project->isActiveConfig("staticlib")) { 419 } else if(!project->isActiveConfig("staticlib")) {
413 QString destdir = project->first("DESTDIR"), incr_deps; 420 QString destdir = project->first("DESTDIR"), incr_deps;
414 if(do_incremental) { 421 if(do_incremental) {
415 QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first(); 422 QString s_ext = project->variables()["QMAKE_EXTENSION_SHLIB"].first();
416 QString incr_target = var("QMAKE_ORIG_TARGET").replace( 423 QString incr_target = var("QMAKE_ORIG_TARGET").replace(
417 QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental"; 424 QRegExp("\\." + s_ext), "").replace(QRegExp("^lib"), "") + "_incremental";
418 if(incr_target.find(Option::dir_sep) != -1) 425 if(incr_target.find(Option::dir_sep) != -1)
419 incr_target = incr_target.right(incr_target.length() - 426 incr_target = incr_target.right(incr_target.length() -
420 (incr_target.findRev(Option::dir_sep) + 1)); 427 (incr_target.findRev(Option::dir_sep) + 1));
421 428
422 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") { 429 if(project->first("QMAKE_INCREMENTAL_STYLE") == "ld") {
423 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext; 430 QString incr_target_dir = var("OBJECTS_DIR") + incr_target + Option::obj_ext;
424 //actual target 431 //actual target
425 const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 432 const QString link_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
426 t << incr_target_dir << ": " << link_deps << "\n\t" 433 t << incr_target_dir << ": " << link_deps << "\n\t"
@@ -439,300 +446,344 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
439 if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL")) 446 if(!project->isEmpty("QMAKE_LFLAGS_INCREMENTAL"))
440 incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " "; 447 incr_lflags += var("QMAKE_LFLAGS_INCREMENTAL") + " ";
441 if(project->isActiveConfig("debug")) 448 if(project->isActiveConfig("debug"))
442 incr_lflags += var("QMAKE_LFLAGS_DEBUG"); 449 incr_lflags += var("QMAKE_LFLAGS_DEBUG");
443 else 450 else
444 incr_lflags += var("QMAKE_LFLAGS_RELEASE"); 451 incr_lflags += var("QMAKE_LFLAGS_RELEASE");
445 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t"; 452 t << incr_target_dir << ": $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << "\n\t";
446 if(!destdir.isEmpty()) 453 if(!destdir.isEmpty())
447 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 454 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
448 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir << 455 t << "$(LINK) " << incr_lflags << " -o "<< incr_target_dir <<
449 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl; 456 " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)" << endl;
450 //communicated below 457 //communicated below
451 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"]; 458 QStringList &cmd = project->variables()["QMAKE_LINK_SHLIB_CMD"];
452 if(!destdir.isEmpty()) 459 if(!destdir.isEmpty())
453 cmd.append(" -L" + destdir); 460 cmd.append(" -L" + destdir);
454 cmd.append(" -l" + incr_target); 461 cmd.append(" -l" + incr_target);
455 deps.prepend(incr_target_dir + " "); 462 deps.prepend(incr_target_dir + " ");
456 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)"; 463 incr_deps = "$(UICDECLS) $(OBJECTS) $(OBJMOC)";
457 } 464 }
458 465
459 t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","") 466 t << "all: " << " " << deps << " " << varGlue("ALL_DEPS",""," ","")
460 << " " << var("DESTDIR_TARGET") << endl << endl; 467 << " " << var("DESTDIR_TARGET") << endl << endl;
461 468
462 //real target 469 //real target
463 t << var("DESTDIR_TARGET") << ": " << incr_deps << " $(SUBLIBS) " << 470 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " "
464 var("TARGETDEPS"); 471 << incr_deps << " $(SUBLIBS) " << var("POST_TARGETDEPS");
465 } else { 472 } else {
466 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << 473 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " <<
467 var("DESTDIR_TARGET") << endl << endl; 474 var("DESTDIR_TARGET") << endl << endl;
468 t << var("DESTDIR_TARGET") << ": $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << 475 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS")
469 var("TARGETDEPS"); 476 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << var("POST_TARGETDEPS");
470 } 477 }
471 if(!destdir.isEmpty()) 478 if(!destdir.isEmpty())
472 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir; 479 t << "\n\t" << "test -d " << destdir << " || mkdir -p " << destdir;
473 if(!project->isEmpty("QMAKE_PRE_LINK")) 480 if(!project->isEmpty("QMAKE_PRE_LINK"))
474 t << "\n\t" << var("QMAKE_PRE_LINK"); 481 t << "\n\t" << var("QMAKE_PRE_LINK");
475 482
476 if(project->isActiveConfig("plugin")) { 483 if(project->isActiveConfig("plugin")) {
477 t << "\n\t" 484 t << "\n\t"
478 << "-$(DEL_FILE) $(TARGET)" << "\n\t" 485 << "-$(DEL_FILE) $(TARGET)" << "\n\t"
479 << var("QMAKE_LINK_SHLIB_CMD"); 486 << var("QMAKE_LINK_SHLIB_CMD");
480 if(!destdir.isEmpty()) 487 if(!destdir.isEmpty())
481 t << "\n\t" 488 t << "\n\t"
482 << "-$(MOVE) $(TARGET) " << var("DESTDIR"); 489 << "-$(MOVE) $(TARGET) " << var("DESTDIR");
483 if(!project->isEmpty("QMAKE_POST_LINK")) 490 if(!project->isEmpty("QMAKE_POST_LINK"))
484 t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t"; 491 t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t";
485 t << endl << endl; 492 t << endl << endl;
486 } else if ( os == "hpux" ) { 493 } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
487 t << "\n\t"
488 << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t"
489 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
490 t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)");
491 if(!destdir.isEmpty())
492 t << "\n\t"
493 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
494 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
495 << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR");
496 if(!project->isEmpty("QMAKE_POST_LINK"))
497 t << "\n\t" << var("QMAKE_POST_LINK");
498 t << endl << endl;
499 } else {
500 t << "\n\t" 494 t << "\n\t"
501 << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t" 495 << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t"
502 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t"; 496 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
503 t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t" 497 t << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET0)") << "\n\t"
504 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t" 498 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET1)") << "\n\t"
505 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)"); 499 << varGlue("QMAKE_LN_SHLIB","-"," "," $(TARGET) $(TARGET2)");
506 if(!destdir.isEmpty()) 500 if(!destdir.isEmpty())
507 t << "\n\t" 501 t << "\n\t"
508 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t" 502 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
509 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t" 503 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
510 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t" 504 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET1)\n\t"
511 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t" 505 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET2)\n\t"
512 << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR"); 506 << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR");
513 if(!project->isEmpty("QMAKE_POST_LINK")) 507 if(!project->isEmpty("QMAKE_POST_LINK"))
514 t << "\n\t" << var("QMAKE_POST_LINK"); 508 t << "\n\t" << var("QMAKE_POST_LINK");
515 t << endl << endl; 509 t << endl << endl;
510 } else {
511 t << "\n\t"
512 << "-$(DEL_FILE) $(TARGET) $(TARGET0)" << "\n\t"
513 << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
514 t << varGlue("QMAKE_LN_SHLIB",""," "," $(TARGET) $(TARGET0)");
515 if(!destdir.isEmpty())
516 t << "\n\t"
517 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
518 << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET0)\n\t"
519 << "-$(MOVE) $(TARGET) $(TARGET0) " << var("DESTDIR");
520 if(!project->isEmpty("QMAKE_POST_LINK"))
521 t << "\n\t" << var("QMAKE_POST_LINK");
522 t << endl << endl;
516 } 523 }
517 t << endl << endl; 524 t << endl << endl;
518 525
519 if (! project->isActiveConfig("plugin")) { 526 if (! project->isActiveConfig("plugin")) {
520 t << "staticlib: $(TARGETA)" << endl << endl; 527 t << "staticlib: $(TARGETA)" << endl << endl;
521 t << "$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)"; 528 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC)";
522 if(do_incremental) 529 if(do_incremental)
523 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 530 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
524 t << var("TARGETDEPS") << "\n\t" 531 t << var("POST_TARGETDEPS") << "\n\t"
525 << "-$(DEL_FILE) $(TARGETA) " << "\n\t" 532 << "-$(DEL_FILE) $(TARGETA) " << "\n\t"
526 << var("QMAKE_AR_CMD"); 533 << var("QMAKE_AR_CMD");
527 if(do_incremental) 534 if(do_incremental)
528 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 535 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
529 if(!project->isEmpty("QMAKE_RANLIB")) 536 if(!project->isEmpty("QMAKE_RANLIB"))
530 t << "\n\t" << "$(RANLIB) $(TARGETA)"; 537 t << "\n\t" << "$(RANLIB) $(TARGETA)";
531 t << endl << endl; 538 t << endl << endl;
532 } 539 }
533 } else { 540 } else {
534 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) " 541 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
535 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n" 542 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n"
536 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; 543 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n";
537 if(project->isEmpty("QMAKE_AR_SUBLIBS")) { 544 if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
538 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(TARGETDEPS) " << "\n\t"; 545 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
546 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("POST_TARGETDEPS") << "\n\t";
539 if(!project->isEmpty("DESTDIR")) { 547 if(!project->isEmpty("DESTDIR")) {
540 QString destdir = project->first("DESTDIR"); 548 QString destdir = project->first("DESTDIR");
541 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 549 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
542 } 550 }
543 t << "-$(DEL_FILE) $(TARGET)" << "\n\t" 551 t << "-$(DEL_FILE) $(TARGET)" << "\n\t"
544 << var("QMAKE_AR_CMD") << "\n"; 552 << var("QMAKE_AR_CMD") << "\n";
545 if(!project->isEmpty("QMAKE_POST_LINK")) 553 if(!project->isEmpty("QMAKE_POST_LINK"))
546 t << "\t" << var("QMAKE_POST_LINK") << "\n"; 554 t << "\t" << var("QMAKE_POST_LINK") << "\n";
547 if(!project->isEmpty("QMAKE_RANLIB")) 555 if(!project->isEmpty("QMAKE_RANLIB"))
548 t << "\t" << "$(RANLIB) $(TARGET)" << "\n"; 556 t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
549 if(!project->isEmpty("DESTDIR")) 557 if(!project->isEmpty("DESTDIR"))
550 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n" 558 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n"
551 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; 559 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n";
552 } else { 560 } else {
553 int cnt = 0, max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); 561 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
554 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], 562 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"],
555 libs = project->variables()["QMAKE_AR_SUBLIBS"]; 563 libs = project->variables()["QMAKE_AR_SUBLIBS"];
556 libs.prepend("$(TARGET)"); 564 libs.prepend("$(TARGET)");
557 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); 565 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
558 libit != libs.end(); ++libit) { 566 libit != libs.end(); ++libit) {
559 QStringList build; 567 QStringList build;
560 for(cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) 568 for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
561 build << (*objit); 569 build << (*objit);
562 QString ar; 570 QString ar;
563 if((*libit) == "$(TARGET)") { 571 if((*libit) == "$(TARGET)") {
564 t << var("DESTDIR") << "$(TARGET): $(UICDECLS) " << " $(TARGETDEPS) " 572 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
565 << valList(build) << "\n\t"; 573 << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
566 ar = project->variables()["QMAKE_AR_CMD"].first(); 574 ar = project->variables()["QMAKE_AR_CMD"].first();
567 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", 575 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
568 build.join(" ")); 576 build.join(" "));
569 } else { 577 } else {
570 t << (*libit) << ": " << valList(build) << "\n\t"; 578 t << (*libit) << ": " << valList(build) << "\n\t";
571 ar = "$(AR) " + (*libit) + " " + build.join(" "); 579 ar = "$(AR) " + (*libit) + " " + build.join(" ");
572 } 580 }
573 if(!project->isEmpty("DESTDIR")) { 581 if(!project->isEmpty("DESTDIR")) {
574 QString destdir = project->first("DESTDIR"); 582 QString destdir = project->first("DESTDIR");
575 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 583 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
576 } 584 }
577 t << "-$(DEL_FILE) " << (*libit) << "\n\t" 585 t << "-$(DEL_FILE) " << (*libit) << "\n\t"
578 << ar << "\n"; 586 << ar << "\n";
579 if(!project->isEmpty("QMAKE_POST_LINK")) 587 if(!project->isEmpty("QMAKE_POST_LINK"))
580 t << "\t" << var("QMAKE_POST_LINK") << "\n"; 588 t << "\t" << var("QMAKE_POST_LINK") << "\n";
581 if(!project->isEmpty("QMAKE_RANLIB")) 589 if(!project->isEmpty("QMAKE_RANLIB"))
582 t << "\t" << "$(RANLIB) " << (*libit) << "\n"; 590 t << "\t" << "$(RANLIB) " << (*libit) << "\n";
583 if(!project->isEmpty("DESTDIR")) 591 if(!project->isEmpty("DESTDIR"))
584 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" 592 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n"
585 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; 593 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n";
586 } 594 }
587 } 595 }
588 t << endl << endl; 596 t << endl << endl;
589 } 597 }
590 598
591 t << "mocables: $(SRCMOC)" << endl << endl; 599 t << "mocables: $(SRCMOC)" << endl << endl;
592 600
593 if(!project->isActiveConfig("no_mocdepend")) { 601 if(!project->isActiveConfig("no_mocdepend")) {
594 //this is an implicity depend on moc, so it will be built if necesary, however 602 //this is an implicity depend on moc, so it will be built if necesary, however
595 //moc itself shouldn't have this dependancy - this is a little kludgy but it is 603 //moc itself shouldn't have this dependency - this is a little kludgy but it is
596 //better than the alternative for now. 604 //better than the alternative for now.
597 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); 605 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET");
598 fixEnvVariables(target); 606 fixEnvVariables(target);
599 fixEnvVariables(moc); 607 fixEnvVariables(moc);
600 if(target != moc) 608 if(target != moc)
601 t << "$(MOC): \n\t" 609 t << "$(MOC): \n\t"
602 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; 610 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl;
603 } 611 }
604 612
605 writeMakeQmake(t); 613 writeMakeQmake(t);
606 614
607 if(!project->first("QMAKE_PKGINFO").isEmpty()) { 615 if(!project->first("QMAKE_PKGINFO").isEmpty()) {
608 QString pkginfo = project->first("QMAKE_PKGINFO"); 616 QString pkginfo = project->first("QMAKE_PKGINFO");
609 QString destdir = project->first("DESTDIR"); 617 QString destdir = project->first("DESTDIR");
610 t << pkginfo << ": " << "\n\t"; 618 t << pkginfo << ": " << "\n\t";
611 if(!destdir.isEmpty()) 619 if(!destdir.isEmpty())
612 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 620 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
613 t << "@$(DEL_FILE) " << pkginfo << "\n\t" 621 t << "@$(DEL_FILE) " << pkginfo << "\n\t"
614 << "@echo \"APPL????\" >" << pkginfo << endl; 622 << "@echo \"APPL????\" >" << pkginfo << endl;
615 } 623 }
616 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { 624 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) {
617 QString info_plist = project->first("QMAKE_INFO_PLIST"), 625 QString info_plist = project->first("QMAKE_INFO_PLIST"),
618 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); 626 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT");
619 QString destdir = project->first("DESTDIR"); 627 QString destdir = project->first("DESTDIR");
620 t << info_plist_out << ": " << "\n\t"; 628 t << info_plist_out << ": " << "\n\t";
621 if(!destdir.isEmpty()) 629 if(!destdir.isEmpty())
622 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 630 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
623 t << "@$(DEL_FILE) " << info_plist_out << "\n\t" 631 t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
624 << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl; 632 << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl;
625 if(!project->first("RC_FILE").isEmpty()) { 633 if(!project->first("RC_FILE").isEmpty()) {
626 QString dir = destdir + "../Resources/"; 634 QString dir = destdir + "../Resources/";
627 t << dir << "application.icns:" << "\n\t" 635 t << dir << "application.icns:" << "\n\t"
628 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" 636 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t"
629 << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl; 637 << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl;
630 } 638 }
631 } 639 }
632 640
633 QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") : 641 QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") :
634 project->first("QMAKE_DISTDIR"); 642 project->first("QMAKE_DISTDIR");
635 QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") : 643 QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") :
636 project->first("OBJECTS_DIR")) + ddir); 644 project->first("OBJECTS_DIR")) + ddir);
637 t << "dist: " << "\n\t" 645 t << "dist: " << "\n\t"
638 << "@mkdir -p " << ddir_c << " && " 646 << "@mkdir -p " << ddir_c << " && "
639 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; 647 << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && ";
640 if(!project->isEmpty("TRANSLATIONS")) 648 if(!project->isEmpty("TRANSLATIONS"))
641 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; 649 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
642 if(!project->isEmpty("FORMS")) { 650 if(!project->isEmpty("FORMS")) {
643 QStringList &forms = project->variables()["FORMS"], ui_headers; 651 QStringList &forms = project->variables()["FORMS"], ui_headers;
644 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { 652 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
645 QString ui_h = fileFixify((*formit) + Option::h_ext.first()); 653 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
646 if(QFile::exists(ui_h) ) 654 if(QFile::exists(ui_h) )
647 ui_headers << ui_h; 655 ui_headers << ui_h;
648 } 656 }
649 if(!ui_headers.isEmpty()) 657 if(!ui_headers.isEmpty())
650 t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && "; 658 t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && ";
651 } 659 }
652 t << "( cd `dirname " << ddir_c << "` && " 660 t << "( cd `dirname " << ddir_c << "` && "
653 << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && " 661 << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && "
654 << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && " 662 << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && "
655 << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && " 663 << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && "
656 << "$(DEL_DIR) " << ddir_c 664 << "$(DEL_FILE) -r " << ddir_c
657 << endl << endl; 665 << endl << endl;
658 666
659 QString clean_targets; 667 QString clean_targets;
660 if(mocAware()) { 668 if(mocAware()) {
661 t << "mocclean:" << "\n"; 669 t << "mocclean:" << "\n";
662 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { 670 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) {
663 if(!objMoc.isEmpty()) 671 if(!objMoc.isEmpty())
664 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; 672 t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n';
665 if(!srcMoc.isEmpty()) 673 if(!srcMoc.isEmpty())
666 t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n'; 674 t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n';
667 if(moc_incremental) 675 if(moc_incremental)
668 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; 676 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
669 clean_targets += " mocclean"; 677 clean_targets += " mocclean";
670 } 678 }
671 t << endl; 679 t << endl;
672 } 680 }
673 t << "uiclean:" << "\n"; 681 t << "uiclean:" << "\n";
674 if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) { 682 if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) {
675 t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n"; 683 t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n";
676 clean_targets += " uiclean"; 684 clean_targets += " uiclean";
677 } 685 }
678 t << endl; 686 t << endl;
679 687
688 t << "yaccclean:" << "\n";
689 if(!var("YACCSOURCES").isEmpty()) {
690 QStringList clean, &l = project->variables()["YACCSOURCES"];
691 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
692 QFileInfo fi((*it));
693 QString dir;
694 if(fi.dirPath() != ".")
695 dir = fi.dirPath() + Option::dir_sep;
696 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
697 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
698 dir += Option::dir_sep;
699 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first();
700 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first();
701 }
702 if(!clean.isEmpty()) {
703 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
704 clean_targets += " yaccclean";
705 }
706 }
707
708 t << "lexclean:" << "\n";
709 if(!var("LEXSOURCES").isEmpty()) {
710 QStringList clean, &l = project->variables()["LEXSOURCES"];
711 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
712 QFileInfo fi((*it));
713 QString dir;
714 if(fi.dirPath() != ".")
715 dir = fi.dirPath() + Option::dir_sep;
716 dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir);
717 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
718 dir += Option::dir_sep;
719 clean << dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first();
720 }
721 if(!clean.isEmpty()) {
722 t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n";
723 clean_targets += " lexclean";
724 }
725 }
726
680 if(do_incremental) { 727 if(do_incremental) {
681 t << "incrclean:" << "\n"; 728 t << "incrclean:" << "\n";
682 if(src_incremental) 729 if(src_incremental)
683 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n"; 730 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n";
684 if(moc_incremental) 731 if(moc_incremental)
685 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; 732 t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n';
686 t << endl; 733 t << endl;
687 } 734 }
688 735
689 t << "clean:" << clean_targets << "\n\t"; 736 t << "clean:" << clean_targets << "\n\t";
690 if(!project->isEmpty("OBJECTS")) 737 if(!project->isEmpty("OBJECTS"))
691 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; 738 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t";
692 if(!project->isEmpty("IMAGES")) 739 if(!project->isEmpty("IMAGES"))
693 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; 740 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
694 if(src_incremental) 741 if(src_incremental)
695 t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; 742 t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t";
696 t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") 743 t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t")
697 << "-$(DEL_FILE) *~ core *.core" << "\n" 744 << "-$(DEL_FILE) *~ core *.core" << "\n"
698 << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; 745 << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl;
699 t << "####### Sub-libraries" << endl << endl; 746 t << "####### Sub-libraries" << endl << endl;
700 if ( !project->variables()["SUBLIBS"].isEmpty() ) { 747 if ( !project->variables()["SUBLIBS"].isEmpty() ) {
701 QString libdir = "tmp/"; 748 QString libdir = "tmp/";
702 if(!project->isEmpty("SUBLIBS_DIR")) 749 if(!project->isEmpty("SUBLIBS_DIR"))
703 libdir = project->first("SUBLIBS_DIR"); 750 libdir = project->first("SUBLIBS_DIR");
704 QStringList &l = project->variables()["SUBLIBS"]; 751 QStringList &l = project->variables()["SUBLIBS"];
705 for(it = l.begin(); it != l.end(); ++it) 752 for(it = l.begin(); it != l.end(); ++it)
706 t << libdir << "lib" << (*it) << ".a" << ":\n\t" 753 t << libdir << "lib" << (*it) << ".a" << ":\n\t"
707 << var(QString("MAKELIB") + (*it)) << endl << endl; 754 << var(QString("MAKELIB") + (*it)) << endl << endl;
708 } 755 }
709 756
710 QString destdir = project->first("DESTDIR"); 757 QString destdir = project->first("DESTDIR");
711 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) 758 if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
712 destdir += Option::dir_sep; 759 destdir += Option::dir_sep;
713 t << "distclean: " << "clean\n\t" 760 t << "distclean: " << "clean\n";
714 << "-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; 761 if(project->first("TEMPLATE") == "app" &&
762 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
763 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n";
764 else
765 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
715 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && 766 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
716 !project->isActiveConfig("plugin")) 767 !project->isActiveConfig("plugin"))
717 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " 768 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
718 << destdir << "$(TARGET2) $(TARGETA)" << "\n"; 769 << destdir << "$(TARGET2) $(TARGETA)" << "\n";
719 t << endl << endl; 770 t << endl << endl;
720 771
721 if ( !project->isEmpty("PRECOMPH") ) { 772 if ( !project->isEmpty("PRECOMPH") ) {
722 QString outdir = project->first("MOC_DIR"); 773 QString outdir = project->first("MOC_DIR");
723 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); 774 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH"));
724 t << "###### Combined headers" << endl << endl; 775 t << "###### Combined headers" << endl << endl;
725 //XXX 776 //XXX
726 t << outdir << "allmoc.cpp: " << qt_dot_h << " " 777 t << outdir << "allmoc.cpp: " << qt_dot_h << " "
727 << varList("HEADERS_ORIG") << "\n\t" 778 << varList("HEADERS_ORIG") << "\n\t"
728 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" 779 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t"
729 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " 780 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h "
730 << outdir << "allmoc.cpp" << "\n\t" 781 << outdir << "allmoc.cpp" << "\n\t"
731 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" 782 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t"
732 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" 783 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \""
733 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" 784 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t"
734 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; 785 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl;
735 } 786 }
736 787
737 // blasted user defined targets 788 // blasted user defined targets
738 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; 789 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
@@ -785,185 +836,186 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
785 while(sd->directory.right(1) == Option::dir_sep) 836 while(sd->directory.right(1) == Option::dir_sep)
786 sd->directory = sd->directory.left(sd->directory.length() - 1); 837 sd->directory = sd->directory.left(sd->directory.length() - 1);
787 if(!sd->profile.isEmpty()) { 838 if(!sd->profile.isEmpty()) {
788 QString basename = sd->directory; 839 QString basename = sd->directory;
789 int new_slsh = basename.findRev(Option::dir_sep); 840 int new_slsh = basename.findRev(Option::dir_sep);
790 if(new_slsh != -1) 841 if(new_slsh != -1)
791 basename = basename.mid(new_slsh+1); 842 basename = basename.mid(new_slsh+1);
792 if(sd->profile != basename + ".pro") 843 if(sd->profile != basename + ".pro")
793 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro 844 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro
794 } 845 }
795 sd->target = "sub-" + (*it); 846 sd->target = "sub-" + (*it);
796 sd->target.replace('/', '-'); 847 sd->target.replace('/', '-');
797 sd->target.replace('.', '_'); 848 sd->target.replace('.', '_');
798 } 849 }
799 } 850 }
800 QPtrListIterator<SubDir> it(subdirs); 851 QPtrListIterator<SubDir> it(subdirs);
801 852
802 QString ofile = Option::output.name(); 853 QString ofile = Option::output.name();
803 if(ofile.findRev(Option::dir_sep) != -1) 854 if(ofile.findRev(Option::dir_sep) != -1)
804 ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1); 855 ofile = ofile.right(ofile.length() - ofile.findRev(Option::dir_sep) -1);
805 t << "MAKEFILE =" << var("MAKEFILE") << endl; 856 t << "MAKEFILE =" << var("MAKEFILE") << endl;
806 t << "QMAKE =" << var("QMAKE") << endl; 857 t << "QMAKE =" << var("QMAKE") << endl;
807 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 858 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
808 t << "SUBTARGETS ="; // subdirectory targets are sub-directory 859 t << "SUBTARGETS ="; // subdirectory targets are sub-directory
809 for( it.toFirst(); it.current(); ++it) 860 for( it.toFirst(); it.current(); ++it)
810 t << " \\\n\t\t" << it.current()->target; 861 t << " \\\n\t\t" << it.current()->target;
811 t << endl << endl; 862 t << endl << endl;
812 t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl; 863 t << "first: all\n\nall: " << ofile << " $(SUBTARGETS)" << endl << endl;
813 864
814 // generate target rules 865 // generate target rules
815 for( it.toFirst(); it.current(); ++it) { 866 for( it.toFirst(); it.current(); ++it) {
816 bool have_dir = !(*it)->directory.isEmpty(); 867 bool have_dir = !(*it)->directory.isEmpty();
817 QString mkfile = (*it)->makefile, out; 868 QString mkfile = (*it)->makefile, out;
818 if(have_dir) 869 if(have_dir)
819 mkfile.prepend((*it)->directory + Option::dir_sep); 870 mkfile.prepend((*it)->directory + Option::dir_sep);
820 if(direct || (*it)->makefile != "$(MAKEFILE)") 871 if(direct || (*it)->makefile != "$(MAKEFILE)")
821 out = " -o " + (*it)->makefile; 872 out = " -o " + (*it)->makefile;
822 //qmake it 873 //qmake it
823 t << mkfile << ": " << "\n\t"; 874 t << mkfile << ": " << "\n\t";
824 if(have_dir) 875 if(have_dir)
825 t << "cd " << (*it)->directory << " && "; 876 t << "cd " << (*it)->directory << " && ";
826 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; 877 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl;
827 //actually compile 878 //actually compile
828 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; 879 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t";
829 if(have_dir) 880 if(have_dir)
830 t << "cd " << (*it)->directory << " && "; 881 t << "cd " << (*it)->directory << " && ";
831 t << "$(MAKE) -f " << (*it)->makefile << endl << endl; 882 t << "$(MAKE) -f " << (*it)->makefile << endl << endl;
832 } 883 }
833 884
834 if (project->isActiveConfig("ordered")) { // generate dependencies 885 if (project->isActiveConfig("ordered")) { // generate dependencies
835 for( it.toFirst(); it.current(); ) { 886 for( it.toFirst(); it.current(); ) {
836 QString tar = it.current()->target; 887 QString tar = it.current()->target;
837 ++it; 888 ++it;
838 if (it.current()) 889 if (it.current())
839 t << it.current()->target << ": " << tar << endl; 890 t << it.current()->target << ": " << tar << endl;
840 } 891 }
841 t << endl; 892 t << endl;
842 } 893 }
843 894
844 writeMakeQmake(t); 895 writeMakeQmake(t);
845 896
846 if(project->isEmpty("SUBDIRS")) { 897 if(project->isEmpty("SUBDIRS")) {
847 t << "all qmake_all distclean install uiclean mocclean clean: FORCE" << endl; 898 t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl;
848 } else { 899 } else {
849 t << "all: $(SUBTARGETS)" << endl; 900 t << "all: $(SUBTARGETS)" << endl;
850 t << "qmake_all:"; 901 t << "qmake_all:";
851 for( it.toFirst(); it.current(); ++it) { 902 for( it.toFirst(); it.current(); ++it) {
852 t << " "; 903 t << " ";
853 if(!(*it)->directory.isEmpty()) 904 if(!(*it)->directory.isEmpty())
854 t << (*it)->directory << Option::dir_sep; 905 t << (*it)->directory << Option::dir_sep;
855 t << (*it)->makefile; 906 t << (*it)->makefile;
856 } 907 }
857 for( it.toFirst(); it.current(); ++it) { 908 for( it.toFirst(); it.current(); ++it) {
858 t << "\n\t ( "; 909 t << "\n\t ( ";
859 if(!(*it)->directory.isEmpty()) 910 if(!(*it)->directory.isEmpty())
860 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 911 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
861 t << "grep \"^qmake_all:\" " << (*it)->makefile 912 t << "grep \"^qmake_all:\" " << (*it)->makefile
862 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; 913 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
863 } 914 }
864 t << endl; 915 t << endl;
865 t << "clean uninstall install uiclean mocclean: qmake_all FORCE"; 916 t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE";
866 for( it.toFirst(); it.current(); ++it) { 917 for( it.toFirst(); it.current(); ++it) {
867 t << "\n\t ( "; 918 t << "\n\t ( ";
868 if(!(*it)->directory.isEmpty()) 919 if(!(*it)->directory.isEmpty())
869 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 920 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
870 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true"; 921 t << "$(MAKE) -f " << (*it)->makefile << " $@" << "; ) || true";
871 } 922 }
872 t << endl; 923 t << endl;
873 t << "distclean: qmake_all FORCE"; 924 t << "distclean: qmake_all FORCE";
874 for( it.toFirst(); it.current(); ++it) { 925 for( it.toFirst(); it.current(); ++it) {
875 t << "\n\t ( "; 926 t << "\n\t ( ";
876 if(!(*it)->directory.isEmpty()) 927 if(!(*it)->directory.isEmpty())
877 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 928 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
878 t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true"; 929 t << "$(MAKE) -f " << (*it)->makefile << " $@; $(DEL_FILE) " << (*it)->makefile << "; ) || true";
879 } 930 }
880 t << endl << endl; 931 t << endl << endl;
881 } 932 }
882 t <<"FORCE:" << endl << endl; 933 t <<"FORCE:" << endl << endl;
883} 934}
884 935
885void UnixMakefileGenerator::init2() 936void UnixMakefileGenerator::init2()
886{ 937{
887 //version handling 938 //version handling
888 if(project->variables()["VERSION"].isEmpty()) 939 if(project->variables()["VERSION"].isEmpty())
889 project->variables()["VERSION"].append("1.0." + 940 project->variables()["VERSION"].append("1.0." +
890 (project->isEmpty("VER_PAT") ? QString("0") : 941 (project->isEmpty("VER_PAT") ? QString("0") :
891 project->first("VER_PAT")) ); 942 project->first("VER_PAT")) );
892 QStringList l = QStringList::split('.', project->first("VERSION")); 943 QStringList l = QStringList::split('.', project->first("VERSION"));
893 l << "0" << "0"; //make sure there are three 944 l << "0" << "0"; //make sure there are three
894 project->variables()["VER_MAJ"].append(l[0]); 945 project->variables()["VER_MAJ"].append(l[0]);
895 project->variables()["VER_MIN"].append(l[1]); 946 project->variables()["VER_MIN"].append(l[1]);
896 project->variables()["VER_PAT"].append(l[2]); 947 project->variables()["VER_PAT"].append(l[2]);
897 948
898 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 949 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
899#if 0 950#if 0
900 if ( project->isActiveConfig("dll") ) { 951 if ( project->isActiveConfig("dll") ) {
901 project->variables()["TARGET"] += project->variables()["TARGET.so"]; 952 project->variables()["TARGET"] += project->variables()["TARGET.so"];
902 if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty()) 953 if(project->variables()["QMAKE_LFLAGS_SHAPP"].isEmpty())
903 project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 954 project->variables()["QMAKE_LFLAGS_SHAPP"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
904 if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) 955 if(!project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty())
905 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET"); 956 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
906 } 957 }
907#endif 958#endif
908 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 959 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
960 if ( !project->variables()["QMAKE_CYGWIN_EXE"].isEmpty() )
961 project->variables()["TARGET_EXT"].append(".exe");
909 } else if ( project->isActiveConfig("staticlib") ) { 962 } else if ( project->isActiveConfig("staticlib") ) {
910 project->variables()["TARGET"].first().prepend("lib"); 963 project->variables()["TARGET"].first().prepend("lib");
911 project->variables()["TARGET"].first() += ".a"; 964 project->variables()["TARGET"].first() += ".a";
912 if(project->variables()["QMAKE_AR_CMD"].isEmpty()) 965 if(project->variables()["QMAKE_AR_CMD"].isEmpty())
913 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)"); 966 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)");
914 } else { 967 } else {
915 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); 968 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a");
916 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) 969 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() )
917 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); 970 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)");
918 else 971 else
919 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); 972 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
920 QString os = project->variables()["QMAKESPEC"].first().section( '-', 0, 0 );
921 if( project->isActiveConfig("plugin") ) { 973 if( project->isActiveConfig("plugin") ) {
922 project->variables()["TARGET_x.y.z"].append("lib" + 974 project->variables()["TARGET_x.y.z"].append("lib" +
923 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); 975 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB"));
924 if(project->isActiveConfig("lib_version_first")) 976 if(project->isActiveConfig("lib_version_first"))
925 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 977 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
926 project->first("VER_MAJ") + "." + 978 project->first("VER_MAJ") + "." +
927 project->first("QMAKE_EXTENSION_SHLIB")); 979 project->first("QMAKE_EXTENSION_SHLIB"));
928 else 980 else
929 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 981 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
930 project->first("QMAKE_EXTENSION_SHLIB") + 982 project->first("QMAKE_EXTENSION_SHLIB") +
931 "." + project->first("VER_MAJ")); 983 "." + project->first("VER_MAJ"));
932 984
933 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; 985 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
934 if(project->isActiveConfig("qt")) 986 if(project->isActiveConfig("qt"))
935 project->variables()["DEFINES"].append("QT_PLUGIN"); 987 project->variables()["DEFINES"].append("QT_PLUGIN");
936 } else if ( os == "hpux" ) { 988 } else if ( !project->isEmpty("QMAKE_HPUX_SHLIB") ) {
937 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl"); 989 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl");
938 if(project->isActiveConfig("lib_version_first")) 990 if(project->isActiveConfig("lib_version_first"))
939 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." + 991 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." +
940 project->first("TARGET")); 992 project->first("TARGET"));
941 else 993 else
942 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 994 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
943 project->first("VER_MAJ")); 995 project->first("VER_MAJ"));
944 project->variables()["TARGET"] = project->variables()["TARGET_x"]; 996 project->variables()["TARGET"] = project->variables()["TARGET_x"];
945 } else if ( os == "aix" ) { 997 } else if ( !project->isEmpty("QMAKE_AIX_SHLIB") ) {
946 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a"); 998 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".a");
947 if(project->isActiveConfig("lib_version_first")) { 999 if(project->isActiveConfig("lib_version_first")) {
948 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1000 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
949 project->first("VER_MAJ") + "." + 1001 project->first("VER_MAJ") + "." +
950 project->first("QMAKE_EXTENSION_SHLIB")); 1002 project->first("QMAKE_EXTENSION_SHLIB"));
951 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1003 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
952 project->first("VER_MAJ") + 1004 project->first("VER_MAJ") +
953 "." + project->first("VER_MIN") + "." + 1005 "." + project->first("VER_MIN") + "." +
954 project->first("QMAKE_EXTENSION_SHLIB")); 1006 project->first("QMAKE_EXTENSION_SHLIB"));
955 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + 1007 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
956 project->first("VER_MAJ") + "." + 1008 project->first("VER_MAJ") + "." +
957 project->first("VER_MIN") + "." + 1009 project->first("VER_MIN") + "." +
958 project->first("VER_PAT") + "." + 1010 project->first("VER_PAT") + "." +
959 project->first("QMAKE_EXTENSION_SHLIB")); 1011 project->first("QMAKE_EXTENSION_SHLIB"));
960 } else { 1012 } else {
961 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1013 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
962 project->first("QMAKE_EXTENSION_SHLIB") + 1014 project->first("QMAKE_EXTENSION_SHLIB") +
963 "." + project->first("VER_MAJ")); 1015 "." + project->first("VER_MAJ"));
964 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1016 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
965 project->first("QMAKE_EXTENSION_SHLIB") + 1017 project->first("QMAKE_EXTENSION_SHLIB") +
966 "." + project->first("VER_MAJ") + 1018 "." + project->first("VER_MAJ") +
967 "." + project->first("VER_MIN")); 1019 "." + project->first("VER_MIN"));
968 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." + 1020 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + "." +
969 project->first("QMAKE_EXTENSION_SHLIB") + "." + 1021 project->first("QMAKE_EXTENSION_SHLIB") + "." +
@@ -990,50 +1042,57 @@ void UnixMakefileGenerator::init2()
990 project->variables()["QMAKE_EXTENSION_SHLIB"].first()); 1042 project->variables()["QMAKE_EXTENSION_SHLIB"].first());
991 } else { 1043 } else {
992 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1044 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
993 project->first("QMAKE_EXTENSION_SHLIB") + 1045 project->first("QMAKE_EXTENSION_SHLIB") +
994 "." + project->first("VER_MAJ")); 1046 "." + project->first("VER_MAJ"));
995 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." + 1047 project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
996 project->first("QMAKE_EXTENSION_SHLIB") 1048 project->first("QMAKE_EXTENSION_SHLIB")
997 + "." + project->first("VER_MAJ") + 1049 + "." + project->first("VER_MAJ") +
998 "." + project->first("VER_MIN")); 1050 "." + project->first("VER_MIN"));
999 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") + 1051 project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") +
1000 "." + 1052 "." +
1001 project->variables()[ 1053 project->variables()[
1002 "QMAKE_EXTENSION_SHLIB"].first() + "." + 1054 "QMAKE_EXTENSION_SHLIB"].first() + "." +
1003 project->first("VER_MAJ") + "." + 1055 project->first("VER_MAJ") + "." +
1004 project->first("VER_MIN") + "." + 1056 project->first("VER_MIN") + "." +
1005 project->first("VER_PAT")); 1057 project->first("VER_PAT"));
1006 } 1058 }
1007 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"]; 1059 project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
1008 } 1060 }
1009 if(project->isEmpty("QMAKE_LN_SHLIB")) 1061 if(project->isEmpty("QMAKE_LN_SHLIB"))
1010 project->variables()["QMAKE_LN_SHLIB"].append("ln -s"); 1062 project->variables()["QMAKE_LN_SHLIB"].append("ln -s");
1011 project->variables()["DESTDIR_TARGET"].append("$(TARGET)"); 1063 project->variables()["DESTDIR_TARGET"].append("$(TARGET)");
1012 if ( !project->variables()["DESTDIR"].isEmpty() ) 1064 if ( !project->variables()["DESTDIR"].isEmpty() )
1013 project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR")); 1065 project->variables()["DESTDIR_TARGET"].first().prepend(project->first("DESTDIR"));
1014 if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty() && !project->variables()["TARGET_x"].isEmpty() ) 1066 if ( !project->variables()["QMAKE_LFLAGS_SONAME"].isEmpty()) {
1015 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x"); 1067 if(project->isActiveConfig("plugin")) {
1068 if(!project->variables()["TARGET"].isEmpty() )
1069 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET");
1070 } else {
1071 if(!project->variables()["TARGET_x"].isEmpty() )
1072 project->variables()["QMAKE_LFLAGS_SONAME"].first() += project->first("TARGET_x");
1073 }
1074 }
1016 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) 1075 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )
1017 project->variables()["QMAKE_LINK_SHLIB_CMD"].append( 1076 project->variables()["QMAKE_LINK_SHLIB_CMD"].append(
1018 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); 1077 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)");
1019 } 1078 }
1020 if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) 1079 if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
1021 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); 1080 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf");
1022 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1081 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
1023 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; 1082 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"];
1024 } else if ( project->isActiveConfig("dll") ) { 1083 } else if ( project->isActiveConfig("dll") ) {
1025 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; 1084 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"];
1026 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; 1085 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"];
1027 if ( project->isActiveConfig("plugin") ) { 1086 if ( project->isActiveConfig("plugin") ) {
1028 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; 1087 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"];
1029 if( !project->isActiveConfig("plugin_no_soname") ) 1088 if( !project->isActiveConfig("plugin_no_soname") )
1030 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1089 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1031 } else { 1090 } else {
1032 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 1091 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
1033 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1092 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1034 } 1093 }
1035 QString destdir = project->first("DESTDIR"); 1094 QString destdir = project->first("DESTDIR");
1036 if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) { 1095 if ( !destdir.isEmpty() && !project->variables()["QMAKE_RPATH"].isEmpty() ) {
1037 QString rpath_destdir = destdir; 1096 QString rpath_destdir = destdir;
1038 if(QDir::isRelativePath(rpath_destdir)) { 1097 if(QDir::isRelativePath(rpath_destdir)) {
1039 QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir)); 1098 QFileInfo fi(Option::fixPathToLocalOS(rpath_destdir));
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp
index ae7b47b..26eea88 100644
--- a/qmake/generators/win32/borland_bmake.cpp
+++ b/qmake/generators/win32/borland_bmake.cpp
@@ -111,160 +111,171 @@ BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
111 t << var("QMAKE_LFLAGS") << endl; 111 t << var("QMAKE_LFLAGS") << endl;
112 t << "LIBS =" << var("QMAKE_LIBS") << endl; 112 t << "LIBS =" << var("QMAKE_LIBS") << endl;
113 } 113 }
114 else { 114 else {
115 t << "LIB =" << var("QMAKE_LIB") << endl; 115 t << "LIB =" << var("QMAKE_LIB") << endl;
116 } 116 }
117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : 119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; 120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : 121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; 122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : 123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; 124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : 125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; 126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
127 t << "ZIP =" << var("QMAKE_ZIP") << endl; 127 t << "ZIP =" << var("QMAKE_ZIP") << endl;
128 t << "DEF_FILE =" << varList("DEF_FILE") << endl; 128 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
129 t << "RES_FILE =" << varList("RES_FILE") << endl; 129 t << "RES_FILE =" << varList("RES_FILE") << endl;
130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl; 130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl;
131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl; 131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl;
132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; 133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
134 t << "MOVE = " << var("QMAKE_MOVE") << endl; 134 t << "MOVE = " << var("QMAKE_MOVE") << endl;
135 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
136 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
135 t << endl; 137 t << endl;
136 138
137 t << "####### Files" << endl << endl; 139 t << "####### Files" << endl << endl;
138 t << "HEADERS =" << varList("HEADERS") << endl; 140 t << "HEADERS =" << varList("HEADERS") << endl;
139 t << "SOURCES =" << varList("SOURCES") << endl; 141 t << "SOURCES =" << varList("SOURCES") << endl;
140 t << "OBJECTS =" << varList("OBJECTS") << endl; 142 t << "OBJECTS =" << varList("OBJECTS") << endl;
141 t << "FORMS =" << varList("FORMS") << endl; 143 t << "FORMS =" << varList("FORMS") << endl;
142 t << "UICDECLS =" << varList("UICDECLS") << endl; 144 t << "UICDECLS =" << varList("UICDECLS") << endl;
143 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 145 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
144 t << "SRCMOC =" << varList("SRCMOC") << endl; 146 t << "SRCMOC =" << varList("SRCMOC") << endl;
145 t << "OBJMOC =" << varList("OBJMOC") << endl; 147 t << "OBJMOC =" << varList("OBJMOC") << endl;
146 t << "DIST =" << varList("DISTFILES") << endl; 148 t << "DIST =" << varList("DISTFILES") << endl;
147 t << "TARGET =" 149 t << "TARGET ="
148 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")) 150 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
149 << endl; 151 << endl;
150 t << endl; 152 t << endl;
151 153
152 t << "####### Implicit rules" << endl << endl; 154 t << "####### Implicit rules" << endl << endl;
153 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; 155 t << ".SUFFIXES: .c";
154 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 156 QStringList::Iterator cppit;
155 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 157 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
156 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 158 t << " " << (*cppit);
157 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 159 t << endl << endl;
160 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
161 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
162 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
158 163
159 t << "####### Build rules" << endl << endl; 164 t << "####### Build rules" << endl << endl;
160 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl; 165 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl;
161 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); 166 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
167 << var("POST_TARGETDEPS");
162 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
163 t << "\n\t" << "$(LINK) @&&|" << "\n\t" 169 t << "\n\t" << "$(LINK) @&&|" << "\n\t"
164 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)"; 170 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
165 } else { 171 } else {
166 t << "\n\t-del $(TARGET)" 172 t << "\n\t-del $(TARGET)"
167 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+" 173 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
168 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+" 174 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
169 << project->variables()["OBJMOC"].join(" \\\n+"); 175 << project->variables()["OBJMOC"].join(" \\\n+");
170 } 176 }
171 t << endl << "|" << endl; 177 t << endl << "|" << endl;
178
179 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
180 t << "\t" <<var("QMAKE_POST_LINK") << endl;
181
172 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
173 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 183 QStringList dlldirs = project->variables()["DLLDESTDIR"];
174 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
175 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 185 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
176 } 186 }
177 } 187 }
178 QString targetfilename = project->variables()["TARGET"].first(); 188 QString targetfilename = project->variables()["TARGET"].first();
179 if(project->isActiveConfig("activeqt")) { 189 if(project->isActiveConfig("activeqt")) {
180 QString version = project->variables()["VERSION"].first(); 190 QString version = project->variables()["VERSION"].first();
181 if ( version.isEmpty() ) 191 if ( version.isEmpty() )
182 version = "1.0"; 192 version = "1.0";
183 193
184 if ( project->isActiveConfig("dll")) { 194 if ( project->isActiveConfig("dll")) {
185 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
186 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
187 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
188 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
189 } else { 199 } else {
190 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
191 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
193 t << "\n\t" << ("-$(TARGET) -regserver"); 203 t << "\n\t" << ("-$(TARGET) -regserver");
194 } 204 }
195 } 205 }
196 t << endl << endl; 206 t << endl << endl;
197 207
198 if(!project->variables()["RC_FILE"].isEmpty()) { 208 if(!project->variables()["RC_FILE"].isEmpty()) {
199 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
200 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 210 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
201 } 211 }
202 t << "mocables: $(SRCMOC)" << endl << endl; 212 t << "mocables: $(SRCMOC)" << endl << endl;
203 213
204 writeMakeQmake(t); 214 writeMakeQmake(t);
205 215
206 t << "dist:" << "\n\t" 216 t << "dist:" << "\n\t"
207 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" 217 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)"
208 << endl << endl; 218 << endl << endl;
209 219
210 t << "clean:\n" 220 t << "clean:\n"
211 << varGlue("OBJECTS","\t-del ","\n\t-del ","") 221 << varGlue("OBJECTS","\t-del ","\n\t-del ","")
212 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 222 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
213 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 223 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
214 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 224 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
215 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 225 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
216 << "\n\t-del $(TARGET)"
217 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 226 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
218 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 227 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
219 if ( project->isActiveConfig("activeqt")) { 228 if ( project->isActiveConfig("activeqt")) {
220 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 229 t << ("\n\t-del tmp\\" + targetfilename + ".*");
221 t << "\n\t-del tmp\\dump.*"; 230 t << "\n\t-del tmp\\dump.*";
222 } 231 }
223 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
224 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
225 if(!project->isEmpty("IMAGES")) 232 if(!project->isEmpty("IMAGES"))
226 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 233 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
227 234
228 // blasted user defined targets 235 // blasted user defined targets
229 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 236 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
230 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 237 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
231 QString targ = var((*it) + ".target"), 238 QString targ = var((*it) + ".target"),
232 cmd = var((*it) + ".commands"), deps; 239 cmd = var((*it) + ".commands"), deps;
233 if(targ.isEmpty()) 240 if(targ.isEmpty())
234 targ = (*it); 241 targ = (*it);
235 QStringList &deplist = project->variables()[(*it) + ".depends"]; 242 QStringList &deplist = project->variables()[(*it) + ".depends"];
236 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 243 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
237 QString dep = var((*dep_it) + ".target"); 244 QString dep = var((*dep_it) + ".target");
238 if(dep.isEmpty()) 245 if(dep.isEmpty())
239 dep = (*dep_it); 246 dep = (*dep_it);
240 deps += " " + dep; 247 deps += " " + dep;
241 } 248 }
242 t << "\n\n" << targ << ":" << deps << "\n\t" 249 t << "\n\n" << targ << ":" << deps << "\n\t"
243 << cmd; 250 << cmd;
244 } 251 }
245 252
246 t << endl << endl; 253 t << endl << endl;
254
255 t << "distclean: clean"
256 << "\n\t-del $(TARGET)"
257 << endl << endl;
247} 258}
248 259
249void 260void
250BorlandMakefileGenerator::init() 261BorlandMakefileGenerator::init()
251{ 262{
252 if(init_flag) 263 if(init_flag)
253 return; 264 return;
254 init_flag = TRUE; 265 init_flag = TRUE;
255 266
256 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 267 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
257 268
258 /* this should probably not be here, but I'm using it to wrap the .t files */ 269 /* this should probably not be here, but I'm using it to wrap the .t files */
259 if(project->first("TEMPLATE") == "app") 270 if(project->first("TEMPLATE") == "app")
260 project->variables()["QMAKE_APP_FLAG"].append("1"); 271 project->variables()["QMAKE_APP_FLAG"].append("1");
261 else if(project->first("TEMPLATE") == "lib") 272 else if(project->first("TEMPLATE") == "lib")
262 project->variables()["QMAKE_LIB_FLAG"].append("1"); 273 project->variables()["QMAKE_LIB_FLAG"].append("1");
263 else if(project->first("TEMPLATE") == "subdirs") { 274 else if(project->first("TEMPLATE") == "subdirs") {
264 MakefileGenerator::init(); 275 MakefileGenerator::init();
265 if(project->variables()["MAKEFILE"].isEmpty()) 276 if(project->variables()["MAKEFILE"].isEmpty())
266 project->variables()["MAKEFILE"].append("Makefile"); 277 project->variables()["MAKEFILE"].append("Makefile");
267 if(project->variables()["QMAKE"].isEmpty()) 278 if(project->variables()["QMAKE"].isEmpty())
268 project->variables()["QMAKE"].append("qmake"); 279 project->variables()["QMAKE"].append("qmake");
269 return; 280 return;
270 } 281 }
@@ -343,49 +354,49 @@ BorlandMakefileGenerator::init()
343 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; 354 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
344 } 355 }
345 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { 356 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
346 project->variables()["CONFIG"].append("windows"); 357 project->variables()["CONFIG"].append("windows");
347 } 358 }
348 if ( project->isActiveConfig("qt") ) { 359 if ( project->isActiveConfig("qt") ) {
349 project->variables()["CONFIG"].append("moc"); 360 project->variables()["CONFIG"].append("moc");
350 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 361 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
351 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; 362 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
352 if ( !project->isActiveConfig("debug") ) 363 if ( !project->isActiveConfig("debug") )
353 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); 364 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
354 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 365 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
355 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { 366 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
356 project->variables()["DEFINES"].append("QT_MAKEDLL"); 367 project->variables()["DEFINES"].append("QT_MAKEDLL");
357 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; 368 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
358 } 369 }
359 } else { 370 } else {
360 if(project->isActiveConfig("thread")) 371 if(project->isActiveConfig("thread"))
361 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 372 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
362 else 373 else
363 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 374 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
364 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 375 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
365 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); 376 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
366 if ( hver == -1 ) 377 if ( hver == -1 )
367 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); 378 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qtmt");
368 if(hver != -1) { 379 if(hver != -1) {
369 QString ver; 380 QString ver;
370 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver); 381 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver);
371 QStringList &libs = project->variables()["QMAKE_LIBS"]; 382 QStringList &libs = project->variables()["QMAKE_LIBS"];
372 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) 383 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
373 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver); 384 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver);
374 } 385 }
375 } 386 }
376 if ( project->isActiveConfig( "activeqt" ) ) { 387 if ( project->isActiveConfig( "activeqt" ) ) {
377 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 388 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
378 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 389 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
379 if ( project->isActiveConfig( "dll" ) ) 390 if ( project->isActiveConfig( "dll" ) )
380 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 391 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
381 } 392 }
382 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 393 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 394 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
384 } 395 }
385 } 396 }
386 } 397 }
387 if ( project->isActiveConfig("opengl") ) { 398 if ( project->isActiveConfig("opengl") ) {
388 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 399 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
389 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 400 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
390 } 401 }
391 if ( project->isActiveConfig("dll") ) { 402 if ( project->isActiveConfig("dll") ) {
@@ -405,73 +416,94 @@ BorlandMakefileGenerator::init()
405 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; 416 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
406 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; 417 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
407 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 418 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
408 project->variables()["TARGET_EXT"].append(".exe"); 419 project->variables()["TARGET_EXT"].append(".exe");
409 } else { 420 } else {
410 project->variables()["TARGET_EXT"].append(".lib"); 421 project->variables()["TARGET_EXT"].append(".lib");
411 } 422 }
412 } 423 }
413 if ( project->isActiveConfig("windows") ) { 424 if ( project->isActiveConfig("windows") ) {
414 if ( project->isActiveConfig("console") ) { 425 if ( project->isActiveConfig("console") ) {
415 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 426 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
416 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 427 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
417 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 428 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
418 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 429 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
419 } else { 430 } else {
420 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; 431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
421 } 432 }
422 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 433 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
423 } else { 434 } else {
424 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 435 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
425 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 436 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
426 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 437 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 438 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
428 } 439 }
440 if ( project->isActiveConfig("stl") ) {
441 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
442 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
443 } else {
444 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
445 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
446 }
447 if ( project->isActiveConfig("exceptions") ) {
448 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
449 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
450 } else {
451 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
452 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
453 }
454 if ( project->isActiveConfig("rtti") ) {
455 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
456 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
457 } else {
458 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
459 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
460 }
461
429 if ( project->isActiveConfig("thread") ) { 462 if ( project->isActiveConfig("thread") ) {
430 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"]; 463 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"];
431 } else { 464 } else {
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"]; 465 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"];
433 } 466 }
434 if ( project->isActiveConfig("moc") ) { 467 if ( project->isActiveConfig("moc") ) {
435 setMocAware(TRUE); 468 setMocAware(TRUE);
436 } 469 }
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 470 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 471 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 472 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 473 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 474 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)]; 475 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 476 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 477 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 } 478 }
446 479
447 if ( !project->variables()["RC_FILE"].isEmpty()) { 480 if ( !project->variables()["RC_FILE"].isEmpty()) {
448 if ( !project->variables()["RES_FILE"].isEmpty()) { 481 if ( !project->variables()["RES_FILE"].isEmpty()) {
449 fprintf(stderr, "Both .rc and .res file specified.\n"); 482 fprintf(stderr, "Both .rc and .res file specified.\n");
450 fprintf(stderr, "Please specify one of them, not both."); 483 fprintf(stderr, "Please specify one of them, not both.");
451 exit(666); 484 exit(666);
452 } 485 }
453 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 486 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
454 project->variables()["RES_FILE"].first().replace(".rc",".res"); 487 project->variables()["RES_FILE"].first().replace(".rc",".res");
455 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"]; 488 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
456 } 489 }
457 MakefileGenerator::init(); 490 MakefileGenerator::init();
458 if ( !project->variables()["VERSION"].isEmpty()) { 491 if ( !project->variables()["VERSION"].isEmpty()) {
459 QStringList l = QStringList::split('.', project->first("VERSION")); 492 QStringList l = QStringList::split('.', project->first("VERSION"));
460 project->variables()["VER_MAJ"].append(l[0]); 493 project->variables()["VER_MAJ"].append(l[0]);
461 project->variables()["VER_MIN"].append(l[1]); 494 project->variables()["VER_MIN"].append(l[1]);
462 } 495 }
463 496
464 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 497 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
465 // bcc does not generate a .tds file for static libs 498 // bcc does not generate a .tds file for static libs
466 QString tdsPostfix; 499 QString tdsPostfix;
467 if ( !project->variables()["VERSION"].isEmpty() ) { 500 if ( !project->variables()["VERSION"].isEmpty() ) {
468 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("") 501 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("")
469 + ".tds"; 502 + ".tds";
470 } else { 503 } else {
471 tdsPostfix = ".tds"; 504 tdsPostfix = ".tds";
472 } 505 }
473 project->variables()["QMAKE_CLEAN"].append( 506 project->variables()["QMAKE_CLEAN"].append(
474 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix ); 507 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
475 } 508 }
476} 509}
477
diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h
index 90f8229..5ffed58 100644
--- a/qmake/generators/win32/borland_bmake.h
+++ b/qmake/generators/win32/borland_bmake.h
@@ -1,59 +1,58 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __BORLANDMAKE_H__ 37#ifndef __BORLAND_BMAKE_H__
38#define __BORLANDMAKE_H__ 38#define __BORLAND_BMAKE_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41 41
42class BorlandMakefileGenerator : public Win32MakefileGenerator 42class BorlandMakefileGenerator : public Win32MakefileGenerator
43{ 43{
44 bool init_flag; 44 bool init_flag;
45 void writeBorlandParts(QTextStream &); 45 void writeBorlandParts(QTextStream &);
46 46
47 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
48 void init(); 48 void init();
49 49
50public: 50public:
51 BorlandMakefileGenerator(QMakeProject *p); 51 BorlandMakefileGenerator(QMakeProject *p);
52 ~BorlandMakefileGenerator(); 52 ~BorlandMakefileGenerator();
53}; 53};
54 54
55inline BorlandMakefileGenerator::~BorlandMakefileGenerator() 55inline BorlandMakefileGenerator::~BorlandMakefileGenerator()
56{ } 56{ }
57 57
58 58#endif /* __BORLAND_BMAKE_H__ */
59#endif /* __BORLANDMAKE_H__ */
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
new file mode 100644
index 0000000..7f58a55
--- a/dev/null
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -0,0 +1,524 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#include "mingw_make.h"
37#include "option.h"
38#include <qregexp.h>
39#include <qdir.h>
40#include <stdlib.h>
41#include <time.h>
42
43
44MingwMakefileGenerator::MingwMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
45{
46 Option::obj_ext = ".o";
47}
48
49bool
50MingwMakefileGenerator::writeMakefile(QTextStream &t)
51{
52 writeHeader(t);
53 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
54 t << "all clean:" << "\n\t"
55 << "@echo \"Some of the required modules ("
56 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
57 << "@echo \"Skipped.\"" << endl << endl;
58 writeMakeQmake(t);
59 return TRUE;
60 }
61
62 if(project->first("TEMPLATE") == "app" ||
63 project->first("TEMPLATE") == "lib") {
64 writeMingwParts(t);
65 return MakefileGenerator::writeMakefile(t);
66 }
67 else if(project->first("TEMPLATE") == "subdirs") {
68 writeSubDirs(t);
69 return TRUE;
70 }
71 return FALSE;
72}
73
74void
75MingwMakefileGenerator::writeMingwParts(QTextStream &t)
76{
77 t << "####### Compiler, tools and options" << endl << endl;
78 t << "CC =" << var("QMAKE_CC") << endl;
79 t << "CXX =" << var("QMAKE_CXX") << endl;
80 t << "LEX = " << var("QMAKE_LEX") << endl;
81 t << "YACC = " << var("QMAKE_YACC") << endl;
82 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
83 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
84 << varGlue("DEFINES","-D"," -D","") << endl;
85 t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " "
86 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
87 << varGlue("DEFINES","-D"," -D","") << endl;
88 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
89 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
90
91 t << "INCPATH =";
92 QStringList &incs = project->variables()["INCLUDEPATH"];
93 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
94 QString inc = (*incit);
95 inc.replace(QRegExp("\\\\$"), "\\\\");
96 inc.replace(QRegExp("\""), "");
97 t << " -I" << inc ;
98 }
99 t << " -I" << specdir()
100 << endl;
101 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
102 t << "LINK =" << var("QMAKE_LINK") << endl;
103 t << "LFLAGS =";
104 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
105 t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";
106 t << var("QMAKE_LFLAGS") << endl;
107 t << "LIBS =" << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << endl;
108 }
109 else {
110 t << "LIB =" << var("QMAKE_LIB") << endl;
111 }
112 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
113 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
114 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
115 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
116 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
117 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
118 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
119 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
120 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
121 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
122 t << "ZIP =" << var("QMAKE_ZIP") << endl;
123 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
124 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
125 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
126 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
127 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
128 t << "MOVE = " << var("QMAKE_MOVE") << endl;
129 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
130 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
131 t << endl;
132
133 t << "####### Output directory" << endl << endl;
134 if (! project->variables()["OBJECTS_DIR"].isEmpty())
135 t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl;
136 else
137 t << "OBJECTS_DIR = . " << endl;
138 if (! project->variables()["MOC_DIR"].isEmpty())
139 t << "MOC_DIR = " << var("MOC_DIR").replace(QRegExp("\\\\$"),"") << endl;
140 else
141 t << "MOC_DIR = . " << endl;
142 t << endl;
143
144 t << "####### Files" << endl << endl;
145 t << "HEADERS =" << varList("HEADERS") << endl;
146 t << "SOURCES =" << varList("SOURCES") << endl;
147 // t << "OBJECTS =" << varList("OBJECTS").replace(QRegExp("\\.obj"),".o") << endl;
148 t << "OBJECTS =" << varList("OBJECTS") << endl;
149 t << "FORMS =" << varList("FORMS") << endl;
150 t << "UICDECLS =" << varList("UICDECLS") << endl;
151 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
152 t << "SRCMOC =" << varList("SRCMOC") << endl;
153 t << "OBJMOC =" << varList("OBJMOC") << endl;
154 // t << "OBJMOC =" << varList("OBJMOC").replace(QRegExp("\\.obj"),".o") << endl;
155 t << "DIST =" << varList("DISTFILES") << endl;
156 t << "TARGET =";
157 if( !project->variables()[ "DESTDIR" ].isEmpty() )
158 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
159 else
160 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
161 t << endl;
162 t << endl;
163
164 t << "####### Implicit rules" << endl << endl;
165 t << ".SUFFIXES: .cpp .cxx .cc .C .c" << endl << endl;
166 t << ".cpp.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
167 t << ".cxx.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
168 t << ".cc.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
169 t << ".C.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
170 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
171
172 t << "####### Build rules" << endl << endl;
173 t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
174 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
175 << var("POST_TARGETDEPS");
176 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
177 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)";
178 } else {
179 t << "\n\t" << "$(LIB) $(TARGET) $(OBJECTS) $(OBJMOC)";
180 }
181
182 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
183 QStringList dlldirs = project->variables()["DLLDESTDIR"];
184 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
185 t << "\n\t" << "copy $(TARGET) " << *dlldir;
186 }
187 }
188 QString targetfilename = project->variables()["TARGET"].first();
189 if(project->isActiveConfig("activeqt")) {
190 QString version = project->variables()["VERSION"].first();
191 if ( version.isEmpty() )
192 version = "1.0";
193
194 if ( project->isActiveConfig("dll")) {
195 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
196 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
197 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
198 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
199 } else {
200 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
201 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
202 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
203 t << "\n\t" << "-$(TARGET) -regserver";
204 }
205 }
206 t << endl << endl;
207
208 if(!project->variables()["RC_FILE"].isEmpty()) {
209 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
210 << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(QRegExp("\\.rc"),".o") << endl << endl;
211 }
212 project->variables()["RES_FILE"].first().replace(QRegExp("\\.rc"),".o");
213
214 t << "mocables: $(SRCMOC)" << endl << endl;
215
216 t << "$(OBJECTS_DIR):" << "\n\t"
217 << "@if not exist $(OBJECTS_DIR) mkdir $(OBJECTS_DIR)" << endl << endl;
218
219 t << "$(MOC_DIR):" << "\n\t"
220 << "@if not exist $(MOC_DIR) mkdir $(MOC_DIR)" << endl << endl;
221
222 writeMakeQmake(t);
223
224 t << "dist:" << "\n\t"
225 << "$(ZIP) " << var("PROJECT") << ".zip "
226 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
227
228 t << "clean:"
229 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o")
230 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
231 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","").replace(QRegExp("\\.obj"),".o")
232 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
233 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
234 << "\n\t-del $(TARGET)"
235 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
236 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
237 if ( project->isActiveConfig("activeqt")) {
238 t << ("\n\t-del tmp\\" + targetfilename + ".*");
239 t << "\n\t-del tmp\\dump.*";
240 }
241 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
242 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
243 if(!project->isEmpty("IMAGES"))
244 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
245
246 // blasted user defined targets
247 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
248 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
249 QString targ = var((*it) + ".target"),
250 cmd = var((*it) + ".commands"), deps;
251 if(targ.isEmpty())
252 targ = (*it);
253 QStringList &deplist = project->variables()[(*it) + ".depends"];
254 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
255 QString dep = var((*dep_it) + ".target");
256 if(dep.isEmpty())
257 dep = (*dep_it);
258 deps += " " + dep;
259 }
260 t << "\n\n" << targ << ":" << deps << "\n\t"
261 << cmd;
262 }
263
264 t << endl << endl;
265}
266
267
268void
269MingwMakefileGenerator::init()
270{
271 if(init_flag)
272 return;
273 init_flag = TRUE;
274
275 /* this should probably not be here, but I'm using it to wrap the .t files */
276 if(project->first("TEMPLATE") == "app")
277 project->variables()["QMAKE_APP_FLAG"].append("1");
278 else if(project->first("TEMPLATE") == "lib")
279 project->variables()["QMAKE_LIB_FLAG"].append("1");
280 else if(project->first("TEMPLATE") == "subdirs") {
281 MakefileGenerator::init();
282 if(project->variables()["MAKEFILE"].isEmpty())
283 project->variables()["MAKEFILE"].append("Makefile");
284 if(project->variables()["QMAKE"].isEmpty())
285 project->variables()["QMAKE"].append("qmake");
286 return;
287 }
288
289 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
290 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
291
292 // LIBS defined in Profile comes first for gcc
293 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
294
295 QString targetfilename = project->variables()["TARGET"].first();
296 QStringList &configs = project->variables()["CONFIG"];
297 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
298 project->variables()["DEFINES"].append("QT_DLL");
299 if (project->isActiveConfig("qt_dll"))
300 if(configs.findIndex("qt") == -1) configs.append("qt");
301 if ( project->isActiveConfig("qt") ) {
302 if ( project->isActiveConfig( "plugin" ) ) {
303 project->variables()["CONFIG"].append("dll");
304 if(project->isActiveConfig("qt"))
305 project->variables()["DEFINES"].append("QT_PLUGIN");
306 }
307 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
308 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
309 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
310 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
311 project->variables()["QMAKE_QT_DLL"].append("1");
312 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
313 project->variables()["CONFIG"].append("dll");
314 }
315 if ( project->isActiveConfig("thread") )
316 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
317 if ( project->isActiveConfig("accessibility" ) )
318 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
319 if ( project->isActiveConfig("tablet") )
320 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
321 }
322 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
323 project->variables()["CONFIG"].remove("staticlib");
324 project->variables()["QMAKE_APP_OR_DLL"].append("1");
325 } else {
326 project->variables()["CONFIG"].append("staticlib");
327 }
328 if ( project->isActiveConfig("warn_off") ) {
329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
331 } else if ( project->isActiveConfig("warn_on") ) {
332 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
333 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
334 }
335 if ( project->isActiveConfig("debug") ) {
336 if ( project->isActiveConfig("thread") ) {
337 // use the DLL RT even here
338 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
339 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
340 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
341 } else {
342 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
343 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
344 }
345 }
346 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
347 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
348 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
349 } else {
350 if ( project->isActiveConfig("thread") ) {
351 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
352 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
353 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
354 } else {
355 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
356 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
357 }
358 }
359 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
360 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
361 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
362 }
363
364 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
365 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
366 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
367 project->variables()["CONFIG"].append("windows");
368 if ( project->isActiveConfig("qt") ) {
369 project->variables()["CONFIG"].append("moc");
370 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
371 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
372 if ( !project->isActiveConfig("debug") )
373 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
374 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
375 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
376 project->variables()["DEFINES"].append("QT_MAKEDLL");
377 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
378 }
379 } else {
380 if(project->isActiveConfig("thread"))
381 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
382 else
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
384 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
385 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
386 if ( hver == -1 )
387 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
388 if(hver != -1) {
389 QString ver;
390 ver.sprintf("libqt-%s" QTDLL_POSTFIX "%d.a", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
391 QStringList &libs = project->variables()["QMAKE_LIBS"];
392// @@@HGTODO maybe we must change the replace regexp if we understand what's going on
393 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
394 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
395 }
396 }
397 if ( project->isActiveConfig( "activeqt" ) ) {
398 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
399 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
400 if ( project->isActiveConfig( "dll" ) )
401 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
402 }
403 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
404 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
405 }
406 }
407 }
408 if ( project->isActiveConfig("opengl") ) {
409 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
410 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
411 }
412 if ( project->isActiveConfig("dll") ) {
413 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
414 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
415 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
416 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
417 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
418 project->variables()["TARGET_EXT"].append(
419 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
420 } else {
421 project->variables()["TARGET_EXT"].append(".dll");
422 }
423 } else {
424 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
425 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
426 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
427 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
428 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
429 project->variables()["TARGET_EXT"].append(".exe");
430 } else {
431 project->variables()["TARGET_EXT"].append(".a");
432 project->variables()["QMAKE_LFLAGS"].append("-static");
433 if(project->variables()["TARGET"].first().left(3) != "lib")
434 project->variables()["TARGET"].first().prepend("lib");
435 }
436 }
437 if ( project->isActiveConfig("windows") ) {
438 if ( project->isActiveConfig("console") ) {
439 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
440 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
441 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
442 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
443 } else {
444 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
445 }
446 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
447 } else {
448 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
449 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
450 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
451 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
452 }
453
454 if ( project->isActiveConfig("moc") )
455 setMocAware(TRUE);
456 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
457 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
458 QStringList &l = project->variables()["QMAKE_FILETAGS"];
459 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
460 QStringList &gdmf = project->variables()[(*it)];
461 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
462 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
463 }
464
465 if ( project->isActiveConfig("dll") )
466 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--out-implib,") + project->first("DESTDIR") + "\\lib"+ project->first("TARGET") + ".a");
467
468 if ( !project->variables()["DEF_FILE"].isEmpty() )
469 project->variables()["QMAKE_LFLAGS"].append(QString("-Wl,--output-def,") + project->first("DEF_FILE"));
470// if(!project->isActiveConfig("incremental"))
471 //project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
472
473#if 0
474 if ( !project->variables()["VERSION"].isEmpty() ) {
475 QString version = project->variables()["VERSION"][0];
476 int firstDot = version.find( "." );
477 QString major = version.left( firstDot );
478 QString minor = version.right( version.length() - firstDot - 1 );
479 minor.replace( ".", "" );
480 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
481 }
482#endif
483 if ( !project->variables()["RC_FILE"].isEmpty()) {
484 if ( !project->variables()["RES_FILE"].isEmpty()) {
485 fprintf(stderr, "Both .rc and .res file specified.\n");
486 fprintf(stderr, "Please specify one of them, not both.");
487 exit(666);
488 }
489 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
490 project->variables()["RES_FILE"].first().replace(".rc",".o");
491 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
492 }
493 if ( !project->variables()["RES_FILE"].isEmpty())
494 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
495
496 MakefileGenerator::init();
497 if ( !project->variables()["VERSION"].isEmpty()) {
498 QStringList l = QStringList::split('.', project->first("VERSION"));
499 project->variables()["VER_MAJ"].append(l[0]);
500 project->variables()["VER_MIN"].append(l[1]);
501 }
502 if(project->isActiveConfig("dll")) {
503 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a");
504 }
505}
506
507void
508MingwMakefileGenerator::writeSubDirs(QTextStream &t)
509{
510 QString qs ;
511 QTextStream ts (&qs, IO_WriteOnly) ;
512 Win32MakefileGenerator::writeSubDirs( ts ) ;
513 QRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ;
514 rx.setMinimal(true);
515 int pos = 0 ;
516 while ( -1 != (pos = rx.search( qs, pos)))
517 {
518 QString qsMatch = rx.cap(2);
519 qsMatch.replace("\n\t"," && \\\n\t");
520 qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch );
521 pos += (rx.cap(1).length()+qsMatch.length());
522 }
523 t << qs ;
524}
diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h
new file mode 100644
index 0000000..c00bf1b
--- a/dev/null
+++ b/qmake/generators/win32/mingw_make.h
@@ -0,0 +1,58 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35#ifndef __MINGW_MAKE_H__
36#define __MINGW_MAKE_H__
37
38#include "winmakefile.h"
39
40class MingwMakefileGenerator : public Win32MakefileGenerator
41{
42 bool init_flag;
43 void writeMingwParts(QTextStream &);
44 void writeSubDirs(QTextStream &t) ;
45
46 bool writeMakefile(QTextStream &);
47 void init();
48
49public:
50 MingwMakefileGenerator(QMakeProject *p);
51 ~MingwMakefileGenerator();
52
53};
54
55inline MingwMakefileGenerator::~MingwMakefileGenerator()
56{ }
57
58#endif /* __MINGW_MAKE_H__ */
diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp
index 8b08c78..3fa0496 100644
--- a/qmake/generators/win32/msvc_dsp.cpp
+++ b/qmake/generators/win32/msvc_dsp.cpp
@@ -487,48 +487,72 @@ DspMakefileGenerator::writeDspParts(QTextStream &t)
487 t << "# PROP Exclude_From_Build 1" << endl; 487 t << "# PROP Exclude_From_Build 1" << endl;
488 t << "# End Source File" << endl << endl; 488 t << "# End Source File" << endl << endl;
489 } 489 }
490 } 490 }
491 else 491 else
492 t << var(variable); 492 t << var(variable);
493 } 493 }
494 t << line << endl; 494 t << line << endl;
495 } 495 }
496 t << endl; 496 t << endl;
497 file.close(); 497 file.close();
498 return TRUE; 498 return TRUE;
499} 499}
500 500
501 501
502 502
503void 503void
504DspMakefileGenerator::init() 504DspMakefileGenerator::init()
505{ 505{
506 if(init_flag) 506 if(init_flag)
507 return; 507 return;
508 QStringList::Iterator it; 508 QStringList::Iterator it;
509 init_flag = TRUE; 509 init_flag = TRUE;
510 510
511 const bool thread = project->isActiveConfig("thread");
512
513 if ( project->isActiveConfig("stl") ) {
514 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
515 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
516 } else {
517 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
518 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
519 }
520 if ( project->isActiveConfig("exceptions") ) {
521 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
522 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
523 } else {
524 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
525 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
526 }
527 if ( project->isActiveConfig("rtti") ) {
528 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
529 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
530 } else {
531 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
532 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
533 }
534
511 /* this should probably not be here, but I'm using it to wrap the .t files */ 535 /* this should probably not be here, but I'm using it to wrap the .t files */
512 if(project->first("TEMPLATE") == "vcapp" ) 536 if(project->first("TEMPLATE") == "vcapp" )
513 project->variables()["QMAKE_APP_FLAG"].append("1"); 537 project->variables()["QMAKE_APP_FLAG"].append("1");
514 else if(project->first("TEMPLATE") == "vclib") 538 else if(project->first("TEMPLATE") == "vclib")
515 project->variables()["QMAKE_LIB_FLAG"].append("1"); 539 project->variables()["QMAKE_LIB_FLAG"].append("1");
516 if ( project->variables()["QMAKESPEC"].isEmpty() ) 540 if ( project->variables()["QMAKESPEC"].isEmpty() )
517 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); 541 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
518 542
519 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); 543 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
520 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 544 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
521 545
522 QStringList &configs = project->variables()["CONFIG"]; 546 QStringList &configs = project->variables()["CONFIG"];
523 if (project->isActiveConfig("shared")) 547 if (project->isActiveConfig("shared"))
524 project->variables()["DEFINES"].append("QT_DLL"); 548 project->variables()["DEFINES"].append("QT_DLL");
525 if (project->isActiveConfig("qt_dll")) 549 if (project->isActiveConfig("qt_dll"))
526 if(configs.findIndex("qt") == -1) configs.append("qt"); 550 if(configs.findIndex("qt") == -1) configs.append("qt");
527 if ( project->isActiveConfig("qt") ) { 551 if ( project->isActiveConfig("qt") ) {
528 if ( project->isActiveConfig( "plugin" ) ) { 552 if ( project->isActiveConfig( "plugin" ) ) {
529 project->variables()["CONFIG"].append("dll"); 553 project->variables()["CONFIG"].append("dll");
530 project->variables()["DEFINES"].append("QT_PLUGIN"); 554 project->variables()["DEFINES"].append("QT_PLUGIN");
531 } 555 }
532 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && 556 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
533 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || 557 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
534 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || 558 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
@@ -547,103 +571,103 @@ DspMakefileGenerator::init()
547 571
548 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { 572 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
549 project->variables()["CONFIG"].append("windows"); 573 project->variables()["CONFIG"].append("windows");
550 } 574 }
551 if ( !project->variables()["VERSION"].isEmpty() ) { 575 if ( !project->variables()["VERSION"].isEmpty() ) {
552 QString version = project->variables()["VERSION"][0]; 576 QString version = project->variables()["VERSION"][0];
553 int firstDot = version.find( "." ); 577 int firstDot = version.find( "." );
554 QString major = version.left( firstDot ); 578 QString major = version.left( firstDot );
555 QString minor = version.right( version.length() - firstDot - 1 ); 579 QString minor = version.right( version.length() - firstDot - 1 );
556 minor.replace( ".", "" ); 580 minor.replace( ".", "" );
557 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); 581 project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor );
558 } 582 }
559 583
560 if ( project->isActiveConfig("qt") ) { 584 if ( project->isActiveConfig("qt") ) {
561 project->variables()["CONFIG"].append("moc"); 585 project->variables()["CONFIG"].append("moc");
562 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; 586 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
563 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; 587 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
564 588
565 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 589 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
566 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 590 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
567 project->variables()["DEFINES"].append("QT_MAKEDLL"); 591 project->variables()["DEFINES"].append("QT_MAKEDLL");
568 project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\""); 592 project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\"");
569 } 593 }
570 } else { 594 } else {
571 if(project->isActiveConfig("thread")) 595 if( thread )
572 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; 596 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
573 else 597 else
574 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; 598 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
575 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 599 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
576 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); 600 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
577 if ( hver == -1 ) 601 if ( hver == -1 )
578 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); 602 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
579 if(hver != -1) { 603 if(hver != -1) {
580 QString ver; 604 QString ver;
581 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); 605 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (thread ? "-mt" : ""), hver);
582 QStringList &libs = project->variables()["QMAKE_LIBS"]; 606 QStringList &libs = project->variables()["QMAKE_LIBS"];
583 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) 607 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
584 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); 608 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
585 } 609 }
586 } 610 }
587 if ( project->isActiveConfig( "activeqt" ) ) { 611 if ( project->isActiveConfig( "activeqt" ) ) {
588 project->variables().remove("QMAKE_LIBS_QT_ENTRY"); 612 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
589 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; 613 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
590 if ( project->isActiveConfig( "dll" ) ) 614 if ( project->isActiveConfig( "dll" ) )
591 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; 615 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
592 } 616 }
593 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { 617 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
594 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; 618 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
595 } 619 }
596 } 620 }
597 } 621 }
598 622
599 if ( project->isActiveConfig("debug") ) { 623 if ( project->isActiveConfig("debug") ) {
600 if ( !project->first("OBJECTS_DIR").isEmpty() ) 624 if ( !project->first("OBJECTS_DIR").isEmpty() )
601 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); 625 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR");
602 else 626 else
603 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; 627 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
604 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; 628 project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release";
605 if ( !project->first("DESTDIR").isEmpty() ) 629 if ( !project->first("DESTDIR").isEmpty() )
606 project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); 630 project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR");
607 else 631 else
608 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; 632 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
609 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; 633 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
610 } else { 634 } else {
611 if ( !project->first("OBJECTS_DIR").isEmpty() ) 635 if ( !project->first("OBJECTS_DIR").isEmpty() )
612 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); 636 project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR");
613 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; 637 project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug";
614 if ( !project->first("DESTDIR").isEmpty() ) 638 if ( !project->first("DESTDIR").isEmpty() )
615 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); 639 project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR");
616 else 640 else
617 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; 641 project->variables()["MSVCDSP_TARGETDIRREL"] = "Release";
618 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; 642 project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug";
619 } 643 }
620 644
621 if ( project->isActiveConfig("opengl") ) { 645 if ( project->isActiveConfig("opengl") ) {
622 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; 646 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
623 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; 647 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
624 } 648 }
625 if ( project->isActiveConfig("thread") ) { 649 if ( thread ) {
626 if(project->isActiveConfig("qt")) 650 if(project->isActiveConfig("qt"))
627 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); 651 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" );
628 if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" 652 if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain"
629 || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { 653 || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
630 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; 654 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
631 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; 655 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
632 } else { 656 } else {
633 // YES we want to use the DLL even in a static build 657 // YES we want to use the DLL even in a static build
634 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; 658 project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
635 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; 659 project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"];
636 } 660 }
637 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt 661 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt
638 && project->first("TARGET") != "qtmain" ) 662 && project->first("TARGET") != "qtmain" )
639 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); 663 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
640 } 664 }
641 665
642 if(project->isActiveConfig("qt")) { 666 if(project->isActiveConfig("qt")) {
643 if ( project->isActiveConfig("accessibility" ) ) 667 if ( project->isActiveConfig("accessibility" ) )
644 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); 668 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
645 if ( project->isActiveConfig("tablet") ) 669 if ( project->isActiveConfig("tablet") )
646 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); 670 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
647 } 671 }
648 if ( project->isActiveConfig("dll") ) { 672 if ( project->isActiveConfig("dll") ) {
649 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 673 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
@@ -711,239 +735,258 @@ DspMakefileGenerator::init()
711 project->variables()["MSVCDSP_SUBSYSTEM"].append("console"); 735 project->variables()["MSVCDSP_SUBSYSTEM"].append("console");
712 } else { 736 } else {
713 project->variables()["MSVCDSP_CONSOLE"].clear(); 737 project->variables()["MSVCDSP_CONSOLE"].clear();
714 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); 738 project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS");
715 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); 739 project->variables()["MSVCDSP_DSPTYPE"].append("0x0101");
716 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows"); 740 project->variables()["MSVCDSP_SUBSYSTEM"].append("windows");
717 } 741 }
718 } else { 742 } else {
719 if ( project->isActiveConfig("dll") ) { 743 if ( project->isActiveConfig("dll") ) {
720 project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); 744 project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) );
721 } else { 745 } else {
722 project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); 746 project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) );
723 } 747 }
724 } 748 }
725 749
726 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 750 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
727 751
728 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 752 project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
729 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 753 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
730 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); 754 project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""));
731 project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; 755 project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
732 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 756 project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
733 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); 757 project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
734 758
759 processPrlFiles();
735 QStringList &libs = project->variables()["QMAKE_LIBS"]; 760 QStringList &libs = project->variables()["QMAKE_LIBS"];
736 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { 761 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
737 QString lib = (*libit); 762 QString lib = (*libit);
738 lib.replace(QRegExp("\""), ""); 763 lib.replace(QRegExp("\""), "");
739 project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); 764 project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\"");
740 } 765 }
741 766
742 QStringList &incs = project->variables()["INCLUDEPATH"]; 767 QStringList &incs = project->variables()["INCLUDEPATH"];
743 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 768 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
744 QString inc = (*incit); 769 QString inc = (*incit);
745 inc.replace("\"", ""); 770 inc.replace("\"", "");
746 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); 771 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\"");
747 } 772 }
748 773
749 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); 774 project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\"");
750 if ( project->isActiveConfig("qt") ) { 775 if ( project->isActiveConfig("qt") ) {
751 project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); 776 project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\"");
752 } else { 777 } else {
753 project->variables()["MSVCDSP_RELDEFS"].clear(); 778 project->variables()["MSVCDSP_RELDEFS"].clear();
754 } 779 }
755 780
756 QString dest; 781 QString dest;
782 QString postLinkStep;
783 QString copyDllStep;
784 QString activeQtStepPreCopyDll;
785 QString activeQtStepPostCopyDll;
786 QString activeQtStepPreCopyDllDebug;
787 QString activeQtStepPostCopyDllDebug;
788 QString activeQtStepPreCopyDllRelease;
789 QString activeQtStepPostCopyDllRelease;
790
791 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
792 postLinkStep += var("QMAKE_POST_LINK");
793
757 if ( !project->variables()["DESTDIR"].isEmpty() ) { 794 if ( !project->variables()["DESTDIR"].isEmpty() ) {
758 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 795 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
759 Option::fixPathToTargetOS(project->first("TARGET")); 796 Option::fixPathToTargetOS(project->first("TARGET"));
760 dest = project->first("TARGET"); 797 dest = project->first("TARGET");
761 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 798 if ( project->first("TARGET").startsWith("$(QTDIR)") )
762 dest.replace( "$(QTDIR)", getenv("QTDIR") ); 799 dest.replace( "$(QTDIR)", getenv("QTDIR") );
763 project->variables()["MSVCDSP_TARGET"].append( 800 project->variables()["MSVCDSP_TARGET"].append(
764 QString("/out:\"") + dest + "\""); 801 QString("/out:\"") + dest + "\"");
765 if ( project->isActiveConfig("dll") ) { 802 if ( project->isActiveConfig("dll") ) {
766 QString imp = dest; 803 QString imp = dest;
767 imp.replace(".dll", ".lib"); 804 imp.replace(".dll", ".lib");
768 project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\""); 805 project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\"");
769 } 806 }
770 } 807 }
771 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { 808 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
772 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 809 QStringList dlldirs = project->variables()["DLLDESTDIR"];
773 QString copydll = "# Begin Special Build Tool\n" 810 if ( dlldirs.count() )
774 "TargetPath=" + dest + "\n" 811 copyDllStep += "\t";
775 "SOURCE=$(InputPath)\n"
776 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
777 "PostBuild_Cmds=";
778
779 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 812 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
780 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; 813 copyDllStep += "copy \"$(TargetPath)\" \"" + *dlldir + "\"\t";
781 } 814 }
782
783 copydll += "\n# End Special Build Tool";
784 project->variables()["MSVCDSP_COPY_DLL_REL"].append( copydll );
785 project->variables()["MSVCDSP_COPY_DLL_DBG"].append( copydll );
786 } 815 }
816
787 if ( project->isActiveConfig("activeqt") ) { 817 if ( project->isActiveConfig("activeqt") ) {
788 QString idl = project->variables()["QMAKE_IDL"].first(); 818 QString idl = project->variables()["QMAKE_IDL"].first();
789 QString idc = project->variables()["QMAKE_IDC"].first(); 819 QString idc = project->variables()["QMAKE_IDC"].first();
790 QString version = project->variables()["VERSION"].first(); 820 QString version = project->variables()["VERSION"].first();
791 if ( version.isEmpty() ) 821 if ( version.isEmpty() )
792 version = "1.0"; 822 version = "1.0";
793 823
794 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); 824 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
795 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); 825 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
796 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); 826 project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
797 if ( project->isActiveConfig( "dll" ) ) { 827 if ( project->isActiveConfig( "dll" ) ) {
798 QString regcmd = "# Begin Special Build Tool\n" 828 activeQtStepPreCopyDll +=
799 "TargetPath=" + targetfilename + "\n" 829 "\t" + idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
800 "SOURCE=$(InputPath)\n"
801 "PostBuild_Desc=Finalizing ActiveQt server...\n"
802 "PostBuild_Cmds=" +
803 idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
804 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 830 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"
805 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 831 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb";
806 "\t" + idc + " %1 /regserver\n" 832 activeQtStepPostCopyDll +=
807 "# End Special Build Tool"; 833 "\t" + idc + " %1 /regserver\n";
808 834
809 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); 835 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".dll";
810 project->variables()["MSVCDSP_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 836 activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable);
837 activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable);
811 838
812 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); 839 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".dll";
813 project->variables()["MSVCDSP_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 840 activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable);
841 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable);
814 } else { 842 } else {
815 QString regcmd = "# Begin Special Build Tool\n" 843 activeQtStepPreCopyDll +=
816 "TargetPath=" + targetfilename + "\n" 844 "\t%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
817 "SOURCE=$(InputPath)\n"
818 "PostBuild_Desc=Finalizing ActiveQt server...\n"
819 "PostBuild_Cmds="
820 "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
821 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" 845 "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"
822 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" 846 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb";
823 "\t%1 -regserver\n" 847 activeQtStepPostCopyDll +=
824 "# End Special Build Tool"; 848 "\t%1 -regserver\n";
825 849 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe";
826 QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); 850 activeQtStepPreCopyDllRelease = activeQtStepPreCopyDll.arg(executable).arg(executable);
827 project->variables()["MSVCDSP_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 851 activeQtStepPostCopyDllRelease = activeQtStepPostCopyDll.arg(executable);
828 852
829 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); 853 executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".exe";
830 project->variables()["MSVCDSP_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); 854 activeQtStepPreCopyDllDebug = activeQtStepPreCopyDll.arg(executable).arg(executable);
855 activeQtStepPostCopyDllDebug = activeQtStepPostCopyDll.arg(executable);
831 } 856 }
832 857
833 } 858 }
859
860
861 if ( !postLinkStep.isEmpty() || !copyDllStep.isEmpty() || !activeQtStepPreCopyDllDebug.isEmpty() || !activeQtStepPreCopyDllRelease.isEmpty() ) {
862 project->variables()["MSVCDSP_POST_LINK_DBG"].append(
863 "# Begin Special Build Tool\n"
864 "SOURCE=$(InputPath)\n"
865 "PostBuild_Desc=Post Build Step\n"
866 "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllDebug + copyDllStep + activeQtStepPostCopyDllDebug + "\n"
867 "# End Special Build Tool\n" );
868 project->variables()["MSVCDSP_POST_LINK_REL"].append(
869 "# Begin Special Build Tool\n"
870 "SOURCE=$(InputPath)\n"
871 "PostBuild_Desc=Post Build Step\n"
872 "PostBuild_Cmds=" + postLinkStep + activeQtStepPreCopyDllRelease + copyDllStep + activeQtStepPostCopyDllRelease + "\n"
873 "# End Special Build Tool\n" );
874 }
875
834 if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { 876 if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) {
835 project->variables()["SOURCES"] += project->variables()["RC_FILE"]; 877 project->variables()["SOURCES"] += project->variables()["RC_FILE"];
836 } 878 }
837 QStringList &list = project->variables()["FORMS"]; 879 QStringList &list = project->variables()["FORMS"];
838 for( it = list.begin(); it != list.end(); ++it ) { 880 for( it = list.begin(); it != list.end(); ++it ) {
839 if ( QFile::exists( *it + ".h" ) ) 881 if ( QFile::exists( *it + ".h" ) )
840 project->variables()["SOURCES"].append( *it + ".h" ); 882 project->variables()["SOURCES"].append( *it + ".h" );
841 } 883 }
842 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; 884 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS";
843} 885}
844 886
845 887
846QString 888QString
847DspMakefileGenerator::findTemplate(QString file) 889DspMakefileGenerator::findTemplate(const QString &file)
848{ 890{
849 QString ret; 891 QString ret;
850 if(!QFile::exists((ret = file)) && 892 if(!QFile::exists((ret = file)) &&
851 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && 893 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
852 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) && 894 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) &&
853 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) 895 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
854 return ""; 896 return "";
855 return ret; 897 return ret;
856} 898}
857 899
858 900
859void 901void
860DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) 902DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
861{ 903{
862 if(var == "QMAKE_PRL_DEFINES") { 904 if(var == "QMAKE_PRL_DEFINES") {
863 QStringList &out = project->variables()["MSVCDSP_DEFINES"]; 905 QStringList &out = project->variables()["MSVCDSP_DEFINES"];
864 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { 906 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
865 if(out.findIndex((*it)) == -1) 907 if(out.findIndex((*it)) == -1)
866 out.append((" /D \"" + *it + "\"")); 908 out.append((" /D \"" + *it + "\""));
867 } 909 }
868 } else { 910 } else {
869 MakefileGenerator::processPrlVariable(var, l); 911 MakefileGenerator::processPrlVariable(var, l);
870 } 912 }
871} 913}
872 914
873 915
874int 916void
875DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t, 917DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t,
876 QString filter) 918 const QString& filter)
877{ 919{
878 if(project->isActiveConfig("flat")) 920 if(project->isActiveConfig("flat"))
879 return 0; 921 return;
880 922
881 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE); 923 fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE);
882 file = file.section(Option::dir_sep, 0, -2); 924 file = file.section(Option::dir_sep, 0, -2);
883 if(file.right(Option::dir_sep.length()) != Option::dir_sep) 925 if(file.right(Option::dir_sep.length()) != Option::dir_sep)
884 file += Option::dir_sep; 926 file += Option::dir_sep;
885 if(file == currentGroup) 927 if(file == currentGroup)
886 return 0; 928 return;
887 929
888 if(file.isEmpty() || !QDir::isRelativePath(file)) { 930 if(file.isEmpty() || !QDir::isRelativePath(file)) {
889 endGroups(t); 931 endGroups(t);
890 return 0; 932 return;
891 } 933 }
892 if(file.startsWith(currentGroup)) 934 if(file.startsWith(currentGroup))
893 file = file.mid(currentGroup.length()); 935 file = file.mid(currentGroup.length());
894 else 936 int dirSep = currentGroup.findRev( Option::dir_sep );
895 endGroups(t); 937 while( !file.startsWith( currentGroup ) && dirSep != -1 ) {
896 int lvl = file.contains(Option::dir_sep), old_lvl = currentGroup.contains(Option::dir_sep); 938 currentGroup.truncate( dirSep );
897 if(lvl > old_lvl) { 939 dirSep = currentGroup.findRev( Option::dir_sep );
898 QStringList dirs = QStringList::split(Option::dir_sep, file); 940 if ( !file.startsWith( currentGroup ) && dirSep != -1 )
899 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
900 t << "# Begin Group \"" << (*dir_it) << "\"\n"
901 << "# Prop Default_Filter \"" << filter << "\"\n";
902 }
903 } else {
904 for(int x = old_lvl - lvl; x; x--)
905 t << "\n# End Group\n"; 941 t << "\n# End Group\n";
906 } 942 }
943 if ( !file.startsWith( currentGroup ) ) {
944 t << "\n# End Group\n";
945 currentGroup = "";
946 }
947 QStringList dirs = QStringList::split(Option::dir_sep, file.right( file.length() - currentGroup.length() ) );
948 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
949 t << "# Begin Group \"" << (*dir_it) << "\"\n"
950 << "# Prop Default_Filter \"" << filter << "\"\n";
951 }
907 currentGroup = file; 952 currentGroup = file;
908 return lvl - old_lvl;
909} 953}
910 954
911 955
912int 956void
913DspMakefileGenerator::endGroups(QTextStream &t) 957DspMakefileGenerator::endGroups(QTextStream &t)
914{ 958{
915 if(project->isActiveConfig("flat")) 959 if(project->isActiveConfig("flat"))
916 return 0; 960 return;
917 else if(currentGroup.isEmpty()) 961 else if(currentGroup.isEmpty())
918 return 0; 962 return;
919 963
920 QStringList dirs = QStringList::split(Option::dir_sep, currentGroup); 964 QStringList dirs = QStringList::split(Option::dir_sep, currentGroup);
921 for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) { 965 for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) {
922 t << "\n# End Group\n"; 966 t << "\n# End Group\n";
923 } 967 }
924 currentGroup = ""; 968 currentGroup = "";
925 return dirs.count();
926} 969}
927 970
928bool 971bool
929DspMakefileGenerator::openOutput(QFile &file) const 972DspMakefileGenerator::openOutput(QFile &file) const
930{ 973{
931 QString outdir; 974 QString outdir;
932 if(!file.name().isEmpty()) { 975 if(!file.name().isEmpty()) {
933 QFileInfo fi(file); 976 QFileInfo fi(file);
934 if(fi.isDir()) 977 if(fi.isDir())
935 outdir = file.name() + QDir::separator(); 978 outdir = file.name() + QDir::separator();
936 } 979 }
937 if(!outdir.isEmpty() || file.name().isEmpty()) 980 if(!outdir.isEmpty() || file.name().isEmpty())
938 file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION")); 981 file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION"));
939 if(QDir::isRelativePath(file.name())) { 982 if(QDir::isRelativePath(file.name())) {
940 QString ofile; 983 QString ofile;
941 ofile = file.name(); 984 ofile = file.name();
942 int slashfind = ofile.findRev('\\'); 985 int slashfind = ofile.findRev('\\');
943 if (slashfind == -1) { 986 if (slashfind == -1) {
944 ofile = ofile.replace(QRegExp("-"), "_"); 987 ofile = ofile.replace(QRegExp("-"), "_");
945 } else { 988 } else {
946 int hypenfind = ofile.find('-', slashfind); 989 int hypenfind = ofile.find('-', slashfind);
947 while (hypenfind != -1 && slashfind < hypenfind) { 990 while (hypenfind != -1 && slashfind < hypenfind) {
948 ofile = ofile.replace(hypenfind, 1, "_"); 991 ofile = ofile.replace(hypenfind, 1, "_");
949 hypenfind = ofile.find('-', hypenfind + 1); 992 hypenfind = ofile.find('-', hypenfind + 1);
diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h
index a7fc3e7..3a7d18e 100644
--- a/qmake/generators/win32/msvc_dsp.h
+++ b/qmake/generators/win32/msvc_dsp.h
@@ -1,73 +1,73 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __DSPMAKE_H__ 37#ifndef __MSVC_DSP_H__
38#define __DSPMAKE_H__ 38#define __MSVC_DSP_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41#include <qvaluestack.h> 41#include <qvaluestack.h>
42 42
43class DspMakefileGenerator : public Win32MakefileGenerator 43class DspMakefileGenerator : public Win32MakefileGenerator
44{ 44{
45 QString currentGroup; 45 QString currentGroup;
46 int beginGroupForFile(QString file, QTextStream &, const QString filter=""); 46 void beginGroupForFile(QString file, QTextStream &, const QString& filter="");
47 int endGroups(QTextStream &); 47 void endGroups(QTextStream &);
48 48
49 bool init_flag; 49 bool init_flag;
50 bool writeDspParts(QTextStream &); 50 bool writeDspParts(QTextStream &);
51 51
52 bool writeMakefile(QTextStream &); 52 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file); 53 QString findTemplate(const QString &file);
54 void init(); 54 void init();
55 55
56public: 56public:
57 DspMakefileGenerator(QMakeProject *p); 57 DspMakefileGenerator(QMakeProject *p);
58 ~DspMakefileGenerator(); 58 ~DspMakefileGenerator();
59 59
60 bool openOutput(QFile &file) const; 60 bool openOutput(QFile &file) const;
61 61
62protected: 62protected:
63 virtual void processPrlVariable(const QString &, const QStringList &); 63 virtual void processPrlVariable(const QString &, const QStringList &);
64 virtual bool findLibraries(); 64 virtual bool findLibraries();
65}; 65};
66 66
67inline DspMakefileGenerator::~DspMakefileGenerator() 67inline DspMakefileGenerator::~DspMakefileGenerator()
68{ } 68{ }
69 69
70inline bool DspMakefileGenerator::findLibraries() 70inline bool DspMakefileGenerator::findLibraries()
71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } 71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); }
72 72
73#endif /* __DSPMAKE_H__ */ 73#endif /* __MSVC_DSP_H__ */
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index 9cc9a69..ecef34d 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -1,64 +1,65 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "msvc_nmake.h" 38#include "msvc_nmake.h"
39#include "option.h" 39#include "option.h"
40#include <qregexp.h> 40#include <qregexp.h>
41#include <qdict.h>
41#include <qdir.h> 42#include <qdir.h>
42#include <stdlib.h> 43#include <stdlib.h>
43#include <time.h> 44#include <time.h>
44 45
45 46
46NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 47NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{ 48{
48 49
49} 50}
50 51
51bool 52bool
52NmakeMakefileGenerator::writeMakefile(QTextStream &t) 53NmakeMakefileGenerator::writeMakefile(QTextStream &t)
53{ 54{
54 writeHeader(t); 55 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 56 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 57 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules (" 58 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 59 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl; 60 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t); 61 writeMakeQmake(t);
61 return TRUE; 62 return TRUE;
62 } 63 }
63 64
64 if(project->first("TEMPLATE") == "app" || 65 if(project->first("TEMPLATE") == "app" ||
@@ -114,159 +115,209 @@ NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
114 lib.replace(QRegExp("\""), ""); 115 lib.replace(QRegExp("\""), "");
115 t << " \"" << lib << "\""; 116 t << " \"" << lib << "\"";
116 } 117 }
117 t << endl; 118 t << endl;
118 } 119 }
119 else { 120 else {
120 t << "LIB =" << var("QMAKE_LIB") << endl; 121 t << "LIB =" << var("QMAKE_LIB") << endl;
121 } 122 }
122 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") : 123 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
123 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; 124 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
124 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") : 125 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
125 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; 126 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
126 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : 127 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
127 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; 128 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
128 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") : 129 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
129 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; 130 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
130 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") : 131 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
131 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; 132 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
132 t << "ZIP =" << var("QMAKE_ZIP") << endl; 133 t << "ZIP =" << var("QMAKE_ZIP") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY") << endl; 134 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
134 t << "COPY_DIR= " << var("QMAKE_COPY") << endl; 135 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
135 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl; 136 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
136 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl; 137 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
137 t << "MOVE = " << var("QMAKE_MOVE") << endl; 138 t << "MOVE = " << var("QMAKE_MOVE") << endl;
139 t << "CHK_DIR_EXISTS =" << var("QMAKE_CHK_DIR_EXISTS") << endl;
140 t << "MKDIR =" << var("QMAKE_MKDIR") << endl;
138 t << endl; 141 t << endl;
139 142
140 t << "####### Files" << endl << endl; 143 t << "####### Files" << endl << endl;
141 t << "HEADERS =" << varList("HEADERS") << endl; 144 t << "HEADERS =" << varList("HEADERS") << endl;
142 t << "SOURCES =" << varList("SOURCES") << endl; 145 t << "SOURCES =" << varList("SOURCES") << endl;
143 t << "OBJECTS =" << varList("OBJECTS") << endl; 146 t << "OBJECTS =" << varList("OBJECTS") << endl;
144 t << "FORMS =" << varList("FORMS") << endl; 147 t << "FORMS =" << varList("FORMS") << endl;
145 t << "UICDECLS =" << varList("UICDECLS") << endl; 148 t << "UICDECLS =" << varList("UICDECLS") << endl;
146 t << "UICIMPLS =" << varList("UICIMPLS") << endl; 149 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
147 t << "SRCMOC =" << varList("SRCMOC") << endl; 150 t << "SRCMOC =" << varList("SRCMOC") << endl;
148 t << "OBJMOC =" << varList("OBJMOC") << endl; 151 t << "OBJMOC =" << varList("OBJMOC") << endl;
149 t << "DIST =" << varList("DISTFILES") << endl; 152 t << "DIST =" << varList("DISTFILES") << endl;
150 t << "TARGET ="; 153 t << "TARGET =";
151 if( !project->variables()[ "DESTDIR" ].isEmpty() ) 154 if( !project->variables()[ "DESTDIR" ].isEmpty() )
152 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); 155 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
153 else 156 else
154 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); 157 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
155 t << endl; 158 t << endl;
156 t << endl; 159 t << endl;
157 160
158 t << "####### Implicit rules" << endl << endl; 161 t << "####### Implicit rules" << endl << endl;
159 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl; 162 t << ".SUFFIXES: .c";
160 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 163 QStringList::Iterator cppit;
161 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 164 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
162 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 165 t << " " << (*cppit);
163 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 166 t << endl << endl;
167 if(!project->isActiveConfig("no_batch")) {
168 // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC
169 project->variables().remove("QMAKE_RUN_CXX");
170 project->variables().remove("QMAKE_RUN_CC");
171
172 QDict<void> source_directories;
173 source_directories.insert(".", (void*)1);
174 if(!project->isEmpty("MOC_DIR"))
175 source_directories.insert(project->first("MOC_DIR"), (void*)1);
176 if(!project->isEmpty("UI_SOURCES_DIR"))
177 source_directories.insert(project->first("UI_SOURCES_DIR"), (void*)1);
178 else if(!project->isEmpty("UI_DIR"))
179 source_directories.insert(project->first("UI_DIR"), (void*)1);
180 QString srcs[] = { QString("SOURCES"), QString("UICIMPLS"), QString("SRCMOC"), QString::null };
181 for(int x = 0; !srcs[x].isNull(); x++) {
182 QStringList &l = project->variables()[srcs[x]];
183 for(QStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) {
184 QString sep = "\\";
185 if((*sit).find(sep) == -1)
186 sep = "/";
187 QString dir = (*sit).section(sep, 0, -2);
188 if(!dir.isEmpty() && !source_directories[dir])
189 source_directories.insert(dir, (void*)1);
190 }
191 }
192
193 for(QDictIterator<void> it(source_directories); it.current(); ++it) {
194 if(it.currentKey().isEmpty())
195 continue;
196 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
197 t << "{" << it.currentKey() << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
198 << var("QMAKE_RUN_CXX_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
199 t << "{" << it.currentKey() << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t"
200 << var("QMAKE_RUN_CC_IMP_BATCH").replace( QRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl;
201 }
202 } else {
203 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
204 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
205 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
206 }
164 207
165 t << "####### Build rules" << endl << endl; 208 t << "####### Build rules" << endl << endl;
166 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; 209 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
167 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS"); 210 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
211 << var("POST_TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { 212 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " 213 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
170 << "$(OBJECTS) $(OBJMOC) $(LIBS)"; 214 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
171 } else { 215 } else {
172 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " 216 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
173 << "$(OBJECTS) $(OBJMOC)"; 217 << "$(OBJECTS) $(OBJMOC)";
174 } 218 }
175 t << endl << "<<" << endl; 219 t << endl << "<<" << endl;
220 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() )
221 t << "\t" << var( "QMAKE_POST_LINK" ) << endl;
176 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { 222 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
177 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 223 QStringList dlldirs = project->variables()["DLLDESTDIR"];
178 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 224 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
179 t << "\n\t" << "-copy $(TARGET) " << *dlldir; 225 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
180 } 226 }
181 } 227 }
182 QString targetfilename = project->variables()["TARGET"].first(); 228 QString targetfilename = project->variables()["TARGET"].first();
183 if(project->isActiveConfig("activeqt")) { 229 if(project->isActiveConfig("activeqt")) {
184 QString version = project->variables()["VERSION"].first(); 230 QString version = project->variables()["VERSION"].first();
185 if ( version.isEmpty() ) 231 if ( version.isEmpty() )
186 version = "1.0"; 232 version = "1.0";
187 233
188 if ( project->isActiveConfig("dll")) { 234 if ( project->isActiveConfig("dll")) {
189 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version); 235 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
190 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 236 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
191 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 237 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); 238 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
193 } else { 239 } else {
194 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version); 240 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
195 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl"); 241 t << "\n\t" << ("-$(IDL) tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl");
196 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb"); 242 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
197 t << "\n\t" << "-$(TARGET) -regserver"; 243 t << "\n\t" << "-$(TARGET) -regserver";
198 } 244 }
199 } 245 }
200 t << endl << endl; 246 t << endl << endl;
201 247
202 if(!project->variables()["RC_FILE"].isEmpty()) { 248 if(!project->variables()["RC_FILE"].isEmpty()) {
203 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" 249 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
204 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; 250 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
205 } 251 }
206 252
207 t << "mocables: $(SRCMOC)" << endl << endl; 253 t << "mocables: $(SRCMOC)" << endl << endl;
208 254
209 writeMakeQmake(t); 255 writeMakeQmake(t);
210 256
211 t << "dist:" << "\n\t" 257 t << "dist:" << "\n\t"
212 << "$(ZIP) " << var("PROJECT") << ".zip " 258 << "$(ZIP) " << var("PROJECT") << ".zip "
213 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; 259 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
214 260
215 t << "clean:" 261 t << "clean:"
216 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","") 262 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","")
217 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","") 263 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
218 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","") 264 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
219 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","") 265 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
220 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","") 266 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
221 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","") 267 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
222 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ",""); 268 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
269
223 if ( project->isActiveConfig("activeqt")) { 270 if ( project->isActiveConfig("activeqt")) {
224 t << ("\n\t-del tmp\\" + targetfilename + ".*"); 271 t << ("\n\t-del tmp\\" + targetfilename + ".*");
225 t << "\n\t-del tmp\\dump.*"; 272 t << "\n\t-del tmp\\dump.*";
226 } 273 }
227 if(!project->isEmpty("IMAGES")) 274 if(!project->isEmpty("IMAGES"))
228 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", ""); 275 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
229 276
230 // blasted user defined targets 277 // blasted user defined targets
231 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; 278 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
232 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { 279 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
233 QString targ = var((*it) + ".target"), 280 QString targ = var((*it) + ".target"),
234 cmd = var((*it) + ".commands"), deps; 281 cmd = var((*it) + ".commands"), deps;
235 if(targ.isEmpty()) 282 if(targ.isEmpty())
236 targ = (*it); 283 targ = (*it);
237 QStringList &deplist = project->variables()[(*it) + ".depends"]; 284 QStringList &deplist = project->variables()[(*it) + ".depends"];
238 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { 285 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
239 QString dep = var((*dep_it) + ".target"); 286 QString dep = var((*dep_it) + ".target");
240 if(dep.isEmpty()) 287 if(dep.isEmpty())
241 dep = (*dep_it); 288 dep = (*dep_it);
242 deps += " " + dep; 289 deps += " " + dep;
243 } 290 }
244 t << "\n\n" << targ << ":" << deps << "\n\t" 291 t << "\n\n" << targ << ":" << deps << "\n\t"
245 << cmd; 292 << cmd;
246 } 293 }
247 294
248 t << endl << endl; 295 t << endl << endl;
296
297 t << "distclean: clean"
298 << "\n\t-del $(TARGET)"
299 << endl << endl;
249} 300}
250 301
251 302
252void 303void
253NmakeMakefileGenerator::init() 304NmakeMakefileGenerator::init()
254{ 305{
255 if(init_flag) 306 if(init_flag)
256 return; 307 return;
257 init_flag = TRUE; 308 init_flag = TRUE;
258 309
259 /* this should probably not be here, but I'm using it to wrap the .t files */ 310 /* this should probably not be here, but I'm using it to wrap the .t files */
260 if(project->first("TEMPLATE") == "app") 311 if(project->first("TEMPLATE") == "app")
261 project->variables()["QMAKE_APP_FLAG"].append("1"); 312 project->variables()["QMAKE_APP_FLAG"].append("1");
262 else if(project->first("TEMPLATE") == "lib") 313 else if(project->first("TEMPLATE") == "lib")
263 project->variables()["QMAKE_LIB_FLAG"].append("1"); 314 project->variables()["QMAKE_LIB_FLAG"].append("1");
264 else if(project->first("TEMPLATE") == "subdirs") { 315 else if(project->first("TEMPLATE") == "subdirs") {
265 MakefileGenerator::init(); 316 MakefileGenerator::init();
266 if(project->variables()["MAKEFILE"].isEmpty()) 317 if(project->variables()["MAKEFILE"].isEmpty())
267 project->variables()["MAKEFILE"].append("Makefile"); 318 project->variables()["MAKEFILE"].append("Makefile");
268 if(project->variables()["QMAKE"].isEmpty()) 319 if(project->variables()["QMAKE"].isEmpty())
269 project->variables()["QMAKE"].append("qmake"); 320 project->variables()["QMAKE"].append("qmake");
270 return; 321 return;
271 } 322 }
272 323
@@ -410,79 +461,102 @@ NmakeMakefileGenerator::init()
410 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; 461 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
411 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; 462 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
412 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { 463 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
413 project->variables()["TARGET_EXT"].append(".exe"); 464 project->variables()["TARGET_EXT"].append(".exe");
414 } else { 465 } else {
415 project->variables()["TARGET_EXT"].append(".lib"); 466 project->variables()["TARGET_EXT"].append(".lib");
416 } 467 }
417 } 468 }
418 if ( project->isActiveConfig("windows") ) { 469 if ( project->isActiveConfig("windows") ) {
419 if ( project->isActiveConfig("console") ) { 470 if ( project->isActiveConfig("console") ) {
420 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 471 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
421 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 472 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
422 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 473 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
423 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 474 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
424 } else { 475 } else {
425 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; 476 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
426 } 477 }
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 478 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
428 } else { 479 } else {
429 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; 480 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
430 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; 481 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; 482 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; 483 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
433 } 484 }
485 if ( project->isActiveConfig("stl") ) {
486 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
487 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
488 } else {
489 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
490 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
491 }
492 if ( project->isActiveConfig("exceptions") ) {
493 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
494 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
495 } else {
496 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
497 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
498 }
499 if ( project->isActiveConfig("rtti") ) {
500 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
501 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
502 } else {
503 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
504 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
505 }
506
434 507
435 if ( project->isActiveConfig("moc") ) 508 if ( project->isActiveConfig("moc") )
436 setMocAware(TRUE); 509 setMocAware(TRUE);
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 510 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', 511 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 512 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 513 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 514 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)]; 515 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 516 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 517 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 } 518 }
446 519
447 if ( !project->variables()["DEF_FILE"].isEmpty() ) 520 if ( !project->variables()["DEF_FILE"].isEmpty() )
448 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE")); 521 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
449 if(!project->isActiveConfig("incremental")) 522 if(!project->isActiveConfig("incremental"))
450 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 523 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
451 524
452 if ( !project->variables()["VERSION"].isEmpty() ) { 525 if ( !project->variables()["VERSION"].isEmpty() ) {
453 QString version = project->variables()["VERSION"][0]; 526 QString version = project->variables()["VERSION"][0];
454 int firstDot = version.find( "." ); 527 int firstDot = version.find( "." );
455 QString major = version.left( firstDot ); 528 QString major = version.left( firstDot );
456 QString minor = version.right( version.length() - firstDot - 1 ); 529 QString minor = version.right( version.length() - firstDot - 1 );
457 minor.replace( ".", "" ); 530 minor.replace( ".", "" );
458 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); 531 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
459 } 532 }
460 if ( !project->variables()["RC_FILE"].isEmpty()) { 533 if ( !project->variables()["RC_FILE"].isEmpty()) {
461 if ( !project->variables()["RES_FILE"].isEmpty()) { 534 if ( !project->variables()["RES_FILE"].isEmpty()) {
462 fprintf(stderr, "Both .rc and .res file specified.\n"); 535 fprintf(stderr, "Both .rc and .res file specified.\n");
463 fprintf(stderr, "Please specify one of them, not both."); 536 fprintf(stderr, "Please specify one of them, not both.");
464 exit(666); 537 exit(666);
465 } 538 }
466 project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; 539 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
467 project->variables()["RES_FILE"].first().replace(".rc",".res"); 540 project->variables()["RES_FILE"].first().replace(".rc",".res");
468 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"]; 541 project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"];
469 } 542 }
470 if ( !project->variables()["RES_FILE"].isEmpty()) 543 if ( !project->variables()["RES_FILE"].isEmpty())
471 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; 544 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
472 545
473 MakefileGenerator::init(); 546 MakefileGenerator::init();
474 if ( !project->variables()["VERSION"].isEmpty()) { 547 if ( !project->variables()["VERSION"].isEmpty()) {
475 QStringList l = QStringList::split('.', project->first("VERSION")); 548 QStringList l = QStringList::split('.', project->first("VERSION"));
476 project->variables()["VER_MAJ"].append(l[0]); 549 project->variables()["VER_MAJ"].append(l[0]);
477 project->variables()["VER_MIN"].append(l[1]); 550 project->variables()["VER_MIN"].append(l[1]);
478 } 551 }
552
553 QString version = QStringList::split('.', project->first("VERSION")).join("");
479 if(project->isActiveConfig("dll")) { 554 if(project->isActiveConfig("dll")) {
480 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib"); 555 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp");
481 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp");
482 } 556 }
483 if(project->isActiveConfig("debug")) { 557 if(project->isActiveConfig("debug")) {
484 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb"); 558 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb");
485 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk"); 559 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk");
486 project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); 560 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
487 } 561 }
488} 562}
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
index d3e170f..579fc35 100644
--- a/qmake/generators/win32/msvc_nmake.h
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -1,59 +1,59 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __NMAKEMAKE_H__ 37#ifndef __MSVC_NMAKE_H__
38#define __NMAKEMAKE_H__ 38#define __MSVC_NMAKE_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41 41
42class NmakeMakefileGenerator : public Win32MakefileGenerator 42class NmakeMakefileGenerator : public Win32MakefileGenerator
43{ 43{
44 bool init_flag; 44 bool init_flag;
45 void writeNmakeParts(QTextStream &); 45 void writeNmakeParts(QTextStream &);
46 46
47 bool writeMakefile(QTextStream &); 47 bool writeMakefile(QTextStream &);
48 void init(); 48 void init();
49 49
50public: 50public:
51 NmakeMakefileGenerator(QMakeProject *p); 51 NmakeMakefileGenerator(QMakeProject *p);
52 ~NmakeMakefileGenerator(); 52 ~NmakeMakefileGenerator();
53 53
54}; 54};
55 55
56inline NmakeMakefileGenerator::~NmakeMakefileGenerator() 56inline NmakeMakefileGenerator::~NmakeMakefileGenerator()
57{ } 57{ }
58 58
59#endif /* __NMAKEMAKE_H__ */ 59#endif /* __MSVC_NMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index c2b9e30..7ffe4f7 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -233,69 +233,69 @@ const char* _TurnOffAssemblyGeneration = "\n\t\t\t\tTurnOffAssemblyGeneration=
233 const char* _TypeLibraryFile = "\n\t\t\t\tTypeLibraryFile=\""; 233 const char* _TypeLibraryFile = "\n\t\t\t\tTypeLibraryFile=\"";
234 const char* _TypeLibraryName = "\n\t\t\t\tTypeLibraryName=\""; 234 const char* _TypeLibraryName = "\n\t\t\t\tTypeLibraryName=\"";
235 const char* _TypeLibraryResourceID = "\n\t\t\t\tTypeLibraryResourceID=\""; 235 const char* _TypeLibraryResourceID = "\n\t\t\t\tTypeLibraryResourceID=\"";
236const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\""; 236const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\"";
237 const char* _UndefinePreprocessorDefinitions = "\n\t\t\t\tUndefinePreprocessorDefinitions=\""; 237 const char* _UndefinePreprocessorDefinitions = "\n\t\t\t\tUndefinePreprocessorDefinitions=\"";
238 const char* _UseOfATL = "\n\t\t\tUseOfATL=\""; 238 const char* _UseOfATL = "\n\t\t\tUseOfATL=\"";
239 const char* _UseOfMfc = "\n\t\t\tUseOfMfc=\""; 239 const char* _UseOfMfc = "\n\t\t\tUseOfMfc=\"";
240 const char* _UsePrecompiledHeader = "\n\t\t\t\tUsePrecompiledHeader=\""; 240 const char* _UsePrecompiledHeader = "\n\t\t\t\tUsePrecompiledHeader=\"";
241 const char* _ValidateParameters = "\n\t\t\t\tValidateParameters=\""; 241 const char* _ValidateParameters = "\n\t\t\t\tValidateParameters=\"";
242 const char* _VCCLCompilerToolName = "\n\t\t\t\tName=\"VCCLCompilerTool\""; 242 const char* _VCCLCompilerToolName = "\n\t\t\t\tName=\"VCCLCompilerTool\"";
243 const char* _VCCustomBuildTool = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\""; 243 const char* _VCCustomBuildTool = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"";
244 const char* _VCLinkerToolName = "\n\t\t\t\tName=\"VCLinkerTool\""; 244 const char* _VCLinkerToolName = "\n\t\t\t\tName=\"VCLinkerTool\"";
245 const char* _VCResourceCompilerToolName = "\n\t\t\t\tName=\"VCResourceCompilerTool\""; 245 const char* _VCResourceCompilerToolName = "\n\t\t\t\tName=\"VCResourceCompilerTool\"";
246 const char* _VCMIDLToolName = "\n\t\t\t\tName=\"VCMIDLTool\""; 246 const char* _VCMIDLToolName = "\n\t\t\t\tName=\"VCMIDLTool\"";
247 const char* _Version1 = "\n\tVersion=\""; 247 const char* _Version1 = "\n\tVersion=\"";
248 const char* _Version4 = "\n\t\t\t\tVersion=\""; 248 const char* _Version4 = "\n\t\t\t\tVersion=\"";
249 const char* _WarnAsError = "\n\t\t\t\tWarnAsError=\""; 249 const char* _WarnAsError = "\n\t\t\t\tWarnAsError=\"";
250 const char* _WarnLevel = "\n\t\t\t\tWarnLevel=\""; 250 const char* _WarnLevel = "\n\t\t\t\tWarnLevel=\"";
251 const char* _WarningLevel = "\n\t\t\t\tWarningLevel=\""; 251 const char* _WarningLevel = "\n\t\t\t\tWarningLevel=\"";
252 const char* _WholeProgramOptimization = "\n\t\t\t\tWholeProgramOptimization=\""; 252 const char* _WholeProgramOptimization = "\n\t\t\t\tWholeProgramOptimization=\"";
253 253
254// Property name and value as Pairs --------------------------------- 254// Property name and value as Pairs ---------------------------------
255struct TPair { 255struct TPair {
256 TPair( const char* n, const triState v ) : name(n), value(v) {}; 256 TPair( const char* n, const triState v ) : name(n), value(v) {};
257 const char* name; 257 const char* name;
258 const triState value; 258 const triState value;
259}; 259};
260struct EPair { 260struct EPair {
261 EPair( const char* n, const int v ) : name(n), value(v) {}; 261 EPair( const char* n, const int v ) : name(n), value(v) {};
262 const char* name; 262 const char* name;
263 const int value; 263 const int value;
264}; 264};
265struct LPair { 265struct LPair {
266 LPair( const char* n, const long v ) : name(n), value(v) {}; 266 LPair( const char* n, const long v ) : name(n), value(v) {};
267 const char* name; 267 const char* name;
268 const long value; 268 const long value;
269}; 269};
270struct SPair { 270struct SPair {
271 SPair( const char* n, const QString& v ) : name(n), value(v) {}; 271 SPair( const char* n, const QString& v ) : name(n), value(v) {};
272 const char* name; 272 const char* name;
273 const QString& value; 273 const QString& value;
274}; 274};
275struct XPair { 275struct XPair {
276 XPair( const char* n, const QStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {}; 276 XPair( const char* n, const QStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {};
277 const char* name; 277 const char* name;
278 const QStringList& value; 278 const QStringList& value;
279 const char* sep; 279 const char* sep;
280}; 280};
281 281
282// void streamSPair( QTextStream &strm, const char *n, const QString &s ) 282// void streamSPair( QTextStream &strm, const char *n, const QString &s )
283 283
284 284
285// Streaming operators for property Pairs --------------------------- 285// Streaming operators for property Pairs ---------------------------
286QTextStream &operator<<( QTextStream &strm, const TPair &prop ) 286QTextStream &operator<<( QTextStream &strm, const TPair &prop )
287{ 287{
288 switch( prop.value ) { 288 switch( prop.value ) {
289 case _False: 289 case _False:
290 strm << prop.name << "FALSE\""; 290 strm << prop.name << "FALSE\"";
291 break; 291 break;
292 case _True: 292 case _True:
293 strm << prop.name << "TRUE\""; 293 strm << prop.name << "TRUE\"";
294 break; 294 break;
295 case unset: 295 case unset:
296 default: 296 default:
297 break; 297 break;
298 } 298 }
299 return strm; 299 return strm;
300} 300}
301 301
@@ -362,49 +362,49 @@ VCCLCompilerTool::VCCLCompilerTool()
362 OptimizeForProcessor( procOptimizeBlended ), 362 OptimizeForProcessor( procOptimizeBlended ),
363 OptimizeForWindowsApplication( unset ), 363 OptimizeForWindowsApplication( unset ),
364 RuntimeLibrary( rtMultiThreaded ), 364 RuntimeLibrary( rtMultiThreaded ),
365 RuntimeTypeInfo( unset ), 365 RuntimeTypeInfo( unset ),
366 ShowIncludes( unset ), 366 ShowIncludes( unset ),
367 SmallerTypeCheck( unset ), 367 SmallerTypeCheck( unset ),
368 StringPooling( unset ), 368 StringPooling( unset ),
369 StructMemberAlignment( alignNotSet ), 369 StructMemberAlignment( alignNotSet ),
370 SuppressStartupBanner( unset ), 370 SuppressStartupBanner( unset ),
371 TreatWChar_tAsBuiltInType( unset ), 371 TreatWChar_tAsBuiltInType( unset ),
372 TurnOffAssemblyGeneration( unset ), 372 TurnOffAssemblyGeneration( unset ),
373 UndefineAllPreprocessorDefinitions( unset ), 373 UndefineAllPreprocessorDefinitions( unset ),
374 UsePrecompiledHeader( pchGenerateAuto ), 374 UsePrecompiledHeader( pchGenerateAuto ),
375 WarnAsError( unset ), 375 WarnAsError( unset ),
376 WarningLevel( warningLevel_0 ), 376 WarningLevel( warningLevel_0 ),
377 WholeProgramOptimization( unset ) 377 WholeProgramOptimization( unset )
378{ 378{
379} 379}
380 380
381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool ) 381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
382{ 382{
383 strm << _begTool3; 383 strm << _begTool3;
384 strm << _VCCLCompilerToolName; 384 strm << _VCCLCompilerToolName;
385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories ); 387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories );
388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation ); 388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation );
389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput ); 389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput );
390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks ); 390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks );
391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation ); 391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation );
392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile ); 392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile );
393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck ); 393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck );
394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention ); 394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention );
395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs ); 395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs );
396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged ); 396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
397 strm << TPair( _CompileOnly, tool.CompileOnly ); 397 strm << TPair( _CompileOnly, tool.CompileOnly );
398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat ); 398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned ); 399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems ); 400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions ); 401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings ); 402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings );
403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations ); 403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations );
404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking ); 404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking );
405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions ); 405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions );
406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling ); 406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling );
407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource ); 407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource );
408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed ); 408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed );
409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope ); 409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles ); 410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
@@ -421,94 +421,98 @@ QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
421 strm << EPair( _Optimization, tool.Optimization ); 421 strm << EPair( _Optimization, tool.Optimization );
422 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor ); 422 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor );
423 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication ); 423 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication );
424 strm << SPair( _OutputFile, tool.OutputFile ); 424 strm << SPair( _OutputFile, tool.OutputFile );
425 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile ); 425 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile );
426 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough ); 426 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough );
427 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 427 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
428 strm << SPair( _ProgramDataBaseFileName, tool.ProgramDataBaseFileName ); 428 strm << SPair( _ProgramDataBaseFileName, tool.ProgramDataBaseFileName );
429 strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary ); 429 strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary );
430 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo ); 430 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo );
431 strm << TPair( _ShowIncludes, tool.ShowIncludes ); 431 strm << TPair( _ShowIncludes, tool.ShowIncludes );
432 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck ); 432 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck );
433 strm << TPair( _StringPooling, tool.StringPooling ); 433 strm << TPair( _StringPooling, tool.StringPooling );
434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); 434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType ); 436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType );
437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); 437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions ); 438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions );
439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); 439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
440 if ( !tool.PrecompiledHeaderFile.isEmpty() || 440 if ( !tool.PrecompiledHeaderFile.isEmpty() ||
441 !tool.PrecompiledHeaderThrough.isEmpty() ) 441 !tool.PrecompiledHeaderThrough.isEmpty() )
442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader ); 442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
443 strm << TPair( _WarnAsError, tool.WarnAsError ); 443 strm << TPair( _WarnAsError, tool.WarnAsError );
444 strm << EPair( _WarningLevel, tool.WarningLevel ); 444 strm << EPair( _WarningLevel, tool.WarningLevel );
445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); 445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
446 strm << "/>"; 446 strm << "/>";
447return strm; 447return strm;
448} 448}
449 449
450bool VCCLCompilerTool::parseOption( const char* option ) 450bool VCCLCompilerTool::parseOption( const char* option )
451{ 451{
452 // skip index 0 ('/' or '-') 452 // skip index 0 ('/' or '-')
453 char first = option[1]; 453 char first = option[1];
454 char second = option[2]; 454 char second = option[2];
455 char third = option[3]; 455 char third = option[3];
456 char fourth = option[4]; 456 char fourth = option[4];
457 bool found = TRUE;
457 458
458 switch ( first ) { 459 switch ( first ) {
459 case '?': 460 case '?':
460 case 'h': 461 case 'h':
461 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" ); 462 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" );
462 return FALSE; 463 found = FALSE;
464 break;
463 case '@': 465 case '@':
464 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" ); 466 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" );
465 return FALSE; 467 found = FALSE;
468 break;
466 case 'l': 469 case 'l':
467 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" ); 470 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" );
468 return FALSE; 471 found = FALSE;
469 472 break;
470 case 'A': 473 case 'A':
471 if ( second != 'I' ) 474 if ( second != 'I' ) {
472 return FALSE; 475 found = FALSE; break;
476 }
473 AdditionalUsingDirectories += option+2; 477 AdditionalUsingDirectories += option+2;
474 break; 478 break;
475 case 'C': 479 case 'C':
476 KeepComments = _True; 480 KeepComments = _True;
477 break; 481 break;
478 case 'D': 482 case 'D':
479 PreprocessorDefinitions += option+1; 483 PreprocessorDefinitions += option+1;
480 break; 484 break;
481 case 'E': 485 case 'E':
482 if ( second == 'H' ) { 486 if ( second == 'H' ) {
483 if ( third == 'a' || third == 'c' || third == 's' ) { 487 if ( third == 'a' || third == 'c' || third == 's' ) {
484 // ExceptionHandling must be false, or it will override 488 // ExceptionHandling must be false, or it will override
485 // with an /EHsc option 489 // with an /EHsc option
486 ExceptionHandling = _False; 490 ExceptionHandling = _False;
487 AdditionalOptions += option; 491 AdditionalOptions += option;
488 break; 492 break;
489 } 493 }
490 return FALSE; 494 found = FALSE; break;
491 } 495 }
492 GeneratePreprocessedFile = preprocessYes; 496 GeneratePreprocessedFile = preprocessYes;
493 break; 497 break;
494 case 'F': 498 case 'F':
495 if ( second <= '9' && second >= '0' ) { 499 if ( second <= '9' && second >= '0' ) {
496 AdditionalOptions += option; 500 AdditionalOptions += option;
497 break; 501 break;
498 } else { 502 } else {
499 switch ( second ) { 503 switch ( second ) {
500 case 'A': 504 case 'A':
501 if ( third == 'c' ) { 505 if ( third == 'c' ) {
502 AssemblerOutput = asmListingAsmMachine; 506 AssemblerOutput = asmListingAsmMachine;
503 if ( fourth == 's' ) 507 if ( fourth == 's' )
504 AssemblerOutput = asmListingAsmMachineSrc; 508 AssemblerOutput = asmListingAsmMachineSrc;
505 } else if ( third == 's' ) { 509 } else if ( third == 's' ) {
506 AssemblerOutput = asmListingAsmSrc; 510 AssemblerOutput = asmListingAsmSrc;
507 } else { 511 } else {
508 AssemblerOutput = asmListingAssemblyOnly; 512 AssemblerOutput = asmListingAssemblyOnly;
509 } 513 }
510 break; 514 break;
511 case 'a': 515 case 'a':
512 AssemblerListingLocation = option+3; 516 AssemblerListingLocation = option+3;
513 break; 517 break;
514 case 'I': 518 case 'I':
@@ -523,58 +527,58 @@ bool VCCLCompilerTool::parseOption( const char* option )
523 BrowseInformationFile = option+3; 527 BrowseInformationFile = option+3;
524 break; 528 break;
525 case 'U': 529 case 'U':
526 ForcedUsingFiles += option+3; 530 ForcedUsingFiles += option+3;
527 break; 531 break;
528 case 'd': 532 case 'd':
529 ProgramDataBaseFileName = option+3; 533 ProgramDataBaseFileName = option+3;
530 break; 534 break;
531 case 'e': 535 case 'e':
532 OutputFile = option+3; 536 OutputFile = option+3;
533 break; 537 break;
534 case 'm': 538 case 'm':
535 AdditionalOptions += option; 539 AdditionalOptions += option;
536 break; 540 break;
537 case 'o': 541 case 'o':
538 ObjectFile = option+3; 542 ObjectFile = option+3;
539 break; 543 break;
540 case 'p': 544 case 'p':
541 PrecompiledHeaderFile = option+3; 545 PrecompiledHeaderFile = option+3;
542 break; 546 break;
543 case 'x': 547 case 'x':
544 ExpandAttributedSource = _True; 548 ExpandAttributedSource = _True;
545 break; 549 break;
546 default: 550 default:
547 return FALSE; 551 found = FALSE; break;
548 } 552 }
549 } 553 }
550 break; 554 break;
551 case 'G': 555 case 'G':
552 switch ( second ) { 556 switch ( second ) {
553 case '3': 557 case '3':
554 case '4': 558 case '4':
555 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" ); 559 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" );
556 return FALSE; 560 found = FALSE; break;
557 case '5': 561 case '5':
558 OptimizeForProcessor = procOptimizePentium; 562 OptimizeForProcessor = procOptimizePentium;
559 break; 563 break;
560 case '6': 564 case '6':
561 case 'B': 565 case 'B':
562 OptimizeForProcessor = procOptimizePentiumProAndAbove; 566 OptimizeForProcessor = procOptimizePentiumProAndAbove;
563 break; 567 break;
564 case 'A': 568 case 'A':
565 OptimizeForWindowsApplication = _True; 569 OptimizeForWindowsApplication = _True;
566 break; 570 break;
567 case 'F': 571 case 'F':
568 StringPooling = _True; 572 StringPooling = _True;
569 break; 573 break;
570 case 'H': 574 case 'H':
571 AdditionalOptions += option; 575 AdditionalOptions += option;
572 break; 576 break;
573 case 'L': 577 case 'L':
574 WholeProgramOptimization = _True; 578 WholeProgramOptimization = _True;
575 if ( third == '-' ) 579 if ( third == '-' )
576 WholeProgramOptimization = _False; 580 WholeProgramOptimization = _False;
577 break; 581 break;
578 case 'R': 582 case 'R':
579 RuntimeTypeInfo = _True; 583 RuntimeTypeInfo = _True;
580 if ( third == '-' ) 584 if ( third == '-' )
@@ -598,410 +602,413 @@ bool VCCLCompilerTool::parseOption( const char* option )
598 case 'f': 602 case 'f':
599 StringPooling = _True; 603 StringPooling = _True;
600 AdditionalOptions += option; 604 AdditionalOptions += option;
601 break; 605 break;
602 case 'm': 606 case 'm':
603 MinimalRebuild = _True; 607 MinimalRebuild = _True;
604 if ( third == '-' ) 608 if ( third == '-' )
605 MinimalRebuild = _False; 609 MinimalRebuild = _False;
606 break; 610 break;
607 case 'r': 611 case 'r':
608 CallingConvention = callConventionFastCall; 612 CallingConvention = callConventionFastCall;
609 break; 613 break;
610 case 's': 614 case 's':
611 // Warning: following [num] is not used, 615 // Warning: following [num] is not used,
612 // were should we put it? 616 // were should we put it?
613 BufferSecurityCheck = _True; 617 BufferSecurityCheck = _True;
614 break; 618 break;
615 case 'y': 619 case 'y':
616 EnableFunctionLevelLinking = _True; 620 EnableFunctionLevelLinking = _True;
617 break; 621 break;
618 case 'z': 622 case 'z':
619 CallingConvention = callConventionStdCall; 623 CallingConvention = callConventionStdCall;
620 break; 624 break;
621 default: 625 default:
622 return FALSE; 626 found = FALSE; break;
623 } 627 }
624 break; 628 break;
625 case 'H': 629 case 'H':
626 AdditionalOptions += option; 630 AdditionalOptions += option;
627 break; 631 break;
628 case 'I': 632 case 'I':
629 AdditionalIncludeDirectories += option+2; 633 AdditionalIncludeDirectories += option+2;
630 break; 634 break;
631 case 'L': 635 case 'L':
632 if ( second == 'D' ) { 636 if ( second == 'D' ) {
633 AdditionalOptions += option; 637 AdditionalOptions += option;
634 break; 638 break;
635 } 639 }
636 return FALSE; 640 found = FALSE; break;
637 case 'M': 641 case 'M':
638 if ( second == 'D' ) { 642 if ( second == 'D' ) {
639 RuntimeLibrary = rtMultiThreadedDLL; 643 RuntimeLibrary = rtMultiThreadedDLL;
640 if ( third == 'd' ) 644 if ( third == 'd' )
641 RuntimeLibrary = rtMultiThreadedDebugDLL; 645 RuntimeLibrary = rtMultiThreadedDebugDLL;
642 break; 646 break;
643 } else if ( second == 'L' ) { 647 } else if ( second == 'L' ) {
644 RuntimeLibrary = rtSingleThreaded; 648 RuntimeLibrary = rtSingleThreaded;
645 if ( third == 'd' ) 649 if ( third == 'd' )
646 RuntimeLibrary = rtSingleThreadedDebug; 650 RuntimeLibrary = rtSingleThreadedDebug;
647 break; 651 break;
648 } else if ( second == 'T' ) { 652 } else if ( second == 'T' ) {
649 RuntimeLibrary = rtMultiThreaded; 653 RuntimeLibrary = rtMultiThreaded;
650 if ( third == 'd' ) 654 if ( third == 'd' )
651 RuntimeLibrary = rtMultiThreadedDebug; 655 RuntimeLibrary = rtMultiThreadedDebug;
652 break; 656 break;
653 } 657 }
654 return FALSE; 658 found = FALSE; break;
655 case 'O': 659 case 'O':
656 switch ( second ) { 660 switch ( second ) {
657 case '1': 661 case '1':
658 Optimization = optimizeMinSpace; 662 Optimization = optimizeMinSpace;
659 break; 663 break;
660 case '2': 664 case '2':
661 Optimization = optimizeMaxSpeed; 665 Optimization = optimizeMaxSpeed;
662 break; 666 break;
663 case 'a': 667 case 'a':
664 AdditionalOptions += option; 668 AdditionalOptions += option;
665 break; 669 break;
666 case 'b': 670 case 'b':
667 if ( third == '0' ) 671 if ( third == '0' )
668 InlineFunctionExpansion = expandDisable; 672 InlineFunctionExpansion = expandDisable;
669 else if ( third == '1' ) 673 else if ( third == '1' )
670 InlineFunctionExpansion = expandOnlyInline; 674 InlineFunctionExpansion = expandOnlyInline;
671 else if ( third == '2' ) 675 else if ( third == '2' )
672 InlineFunctionExpansion = expandAnySuitable; 676 InlineFunctionExpansion = expandAnySuitable;
673 else 677 else
674 return FALSE; 678 found = FALSE;
675 break; 679 break;
676 case 'd': 680 case 'd':
677 Optimization = optimizeDisabled; 681 Optimization = optimizeDisabled;
678 break; 682 break;
679 case 'g': 683 case 'g':
680 GlobalOptimizations = _True; 684 GlobalOptimizations = _True;
681 break; 685 break;
682 case 'i': 686 case 'i':
683 EnableIntrinsicFunctions = _True; 687 EnableIntrinsicFunctions = _True;
684 break; 688 break;
685 case 'p': 689 case 'p':
686 ImproveFloatingPointConsistency = _True; 690 ImproveFloatingPointConsistency = _True;
687 if ( third == '-' ) 691 if ( third == '-' )
688 ImproveFloatingPointConsistency = _False; 692 ImproveFloatingPointConsistency = _False;
689 break; 693 break;
690 case 's': 694 case 's':
691 FavorSizeOrSpeed = favorSize; 695 FavorSizeOrSpeed = favorSize;
692 break; 696 break;
693 case 't': 697 case 't':
694 FavorSizeOrSpeed = favorSpeed; 698 FavorSizeOrSpeed = favorSpeed;
695 break; 699 break;
696 case 'w': 700 case 'w':
697 AdditionalOptions += option; 701 AdditionalOptions += option;
698 break; 702 break;
699 case 'x': 703 case 'x':
700 Optimization = optimizeFull; 704 Optimization = optimizeFull;
701 break; 705 break;
702 case 'y': 706 case 'y':
703 OmitFramePointers = _True; 707 OmitFramePointers = _True;
704 if ( third == '-' ) 708 if ( third == '-' )
705 OmitFramePointers = _False; 709 OmitFramePointers = _False;
706 break; 710 break;
707 default: 711 default:
708 return FALSE; 712 found = FALSE; break;
709 } 713 }
710 break; 714 break;
711 case 'P': 715 case 'P':
712 GeneratePreprocessedFile = preprocessYes; 716 GeneratePreprocessedFile = preprocessYes;
713 break; 717 break;
714 case 'Q': 718 case 'Q':
715 if ( second == 'I' ) { 719 if ( second == 'I' ) {
716 AdditionalOptions += option; 720 AdditionalOptions += option;
717 break; 721 break;
718 } 722 }
719 return FALSE; 723 found = FALSE; break;
720 case 'R': 724 case 'R':
721 if ( second == 'T' && third == 'C' ) { 725 if ( second == 'T' && third == 'C' ) {
722 if ( fourth == '1' ) 726 if ( fourth == '1' )
723 BasicRuntimeChecks = runtimeBasicCheckAll; 727 BasicRuntimeChecks = runtimeBasicCheckAll;
724 else if ( fourth == 'c' ) 728 else if ( fourth == 'c' )
725 SmallerTypeCheck = _True; 729 SmallerTypeCheck = _True;
726 else if ( fourth == 's' ) 730 else if ( fourth == 's' )
727 BasicRuntimeChecks = runtimeCheckStackFrame; 731 BasicRuntimeChecks = runtimeCheckStackFrame;
728 else if ( fourth == 'u' ) 732 else if ( fourth == 'u' )
729 BasicRuntimeChecks = runtimeCheckUninitVariables; 733 BasicRuntimeChecks = runtimeCheckUninitVariables;
730 else 734 else
731 return FALSE; 735 found = FALSE; break;
732 } 736 }
733 break; 737 break;
734 case 'T': 738 case 'T':
735 if ( second == 'C' ) { 739 if ( second == 'C' ) {
736 CompileAs = compileAsC; 740 CompileAs = compileAsC;
737 } else if ( second == 'P' ) { 741 } else if ( second == 'P' ) {
738 CompileAs = compileAsCPlusPlus; 742 CompileAs = compileAsCPlusPlus;
739 } else { 743 } else {
740 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" ); 744 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" );
741 return FALSE; 745 found = FALSE; break;
742 } 746 }
743 break; 747 break;
744 case 'U': 748 case 'U':
745 UndefinePreprocessorDefinitions += option+2; 749 UndefinePreprocessorDefinitions += option+2;
746 break; 750 break;
747 case 'V': 751 case 'V':
748 AdditionalOptions += option; 752 AdditionalOptions += option;
749 break; 753 break;
750 case 'W': 754 case 'W':
751 switch ( second ) { 755 switch ( second ) {
752 case 'a': 756 case 'a':
753 case '4': 757 case '4':
754 WarningLevel = warningLevel_4; 758 WarningLevel = warningLevel_4;
755 break; 759 break;
756 case '3': 760 case '3':
757 WarningLevel = warningLevel_3; 761 WarningLevel = warningLevel_3;
758 break; 762 break;
759 case '2': 763 case '2':
760 WarningLevel = warningLevel_2; 764 WarningLevel = warningLevel_2;
761 break; 765 break;
762 case '1': 766 case '1':
763 WarningLevel = warningLevel_1; 767 WarningLevel = warningLevel_1;
764 break; 768 break;
765 case '0': 769 case '0':
766 WarningLevel = warningLevel_0; 770 WarningLevel = warningLevel_0;
767 break; 771 break;
768 case 'L': 772 case 'L':
769 AdditionalOptions += option; 773 AdditionalOptions += option;
770 break; 774 break;
771 case 'X': 775 case 'X':
772 WarnAsError = _True; 776 WarnAsError = _True;
773 break; 777 break;
774 case 'p': 778 case 'p':
775 if ( third == '6' && fourth == '4' ) { 779 if ( third == '6' && fourth == '4' ) {
776 Detect64BitPortabilityProblems = _True; 780 Detect64BitPortabilityProblems = _True;
777 break; 781 break;
778 } 782 }
779 // Fallthrough 783 // Fallthrough
780 default: 784 default:
781 return FALSE; 785 found = FALSE; break;
782 } 786 }
783 break; 787 break;
784 case 'X': 788 case 'X':
785 IgnoreStandardIncludePath = _True; 789 IgnoreStandardIncludePath = _True;
786 break; 790 break;
787 case 'Y': 791 case 'Y':
788 switch ( second ) { 792 switch ( second ) {
789 case '\0': 793 case '\0':
790 case '-': 794 case '-':
791 AdditionalOptions += option; 795 AdditionalOptions += option;
792 break; 796 break;
793 case 'X': 797 case 'X':
794 UsePrecompiledHeader = pchGenerateAuto; 798 UsePrecompiledHeader = pchGenerateAuto;
795 PrecompiledHeaderFile = option+3; 799 PrecompiledHeaderFile = option+3;
796 break; 800 break;
797 case 'c': 801 case 'c':
798 UsePrecompiledHeader = pchCreateUsingSpecific; 802 UsePrecompiledHeader = pchCreateUsingSpecific;
799 PrecompiledHeaderFile = option+3; 803 PrecompiledHeaderFile = option+3;
800 break; 804 break;
801 case 'd': 805 case 'd':
802 case 'l': 806 case 'l':
803 AdditionalOptions =+ option; 807 AdditionalOptions =+ option;
804 break; 808 break;
805 case 'u': 809 case 'u':
806 UsePrecompiledHeader = pchUseUsingSpecific; 810 UsePrecompiledHeader = pchUseUsingSpecific;
807 PrecompiledHeaderFile = option+3; 811 PrecompiledHeaderFile = option+3;
808 break; 812 break;
809 default: 813 default:
810 return FALSE; 814 found = FALSE; break;
811 } 815 }
812 break; 816 break;
813 case 'Z': 817 case 'Z':
814 switch ( second ) { 818 switch ( second ) {
815 case '7': 819 case '7':
816 DebugInformationFormat = debugOldStyleInfo; 820 DebugInformationFormat = debugOldStyleInfo;
817 break; 821 break;
818 case 'I': 822 case 'I':
819 DebugInformationFormat = debugEditAndContinue; 823 DebugInformationFormat = debugEditAndContinue;
820 break; 824 break;
821 case 'd': 825 case 'd':
822 DebugInformationFormat = debugLineInfoOnly; 826 DebugInformationFormat = debugLineInfoOnly;
823 break; 827 break;
824 case 'i': 828 case 'i':
825 DebugInformationFormat = debugEnabled; 829 DebugInformationFormat = debugEnabled;
826 break; 830 break;
827 case 'l': 831 case 'l':
828 DebugInformationFormat = debugEditAndContinue; 832 DebugInformationFormat = debugEditAndContinue;
829 break; 833 break;
830 case 'a': 834 case 'a':
831 DisableLanguageExtensions = _True; 835 DisableLanguageExtensions = _True;
832 break; 836 break;
833 case 'e': 837 case 'e':
834 DisableLanguageExtensions = _False; 838 DisableLanguageExtensions = _False;
835 break; 839 break;
836 case 'c': 840 case 'c':
837 if ( third == ':' ) { 841 if ( third == ':' ) {
838 if ( fourth == 'f' ) 842 if ( fourth == 'f' )
839 ForceConformanceInForLoopScope = _True; 843 ForceConformanceInForLoopScope = _True;
840 else if ( fourth == 'w' ) 844 else if ( fourth == 'w' )
841 TreatWChar_tAsBuiltInType = _True; 845 TreatWChar_tAsBuiltInType = _True;
842 else 846 else
843 return FALSE; 847 found = FALSE;
844 } else { 848 } else {
845 return FALSE; 849 found = FALSE; break;
846 } 850 }
847 break; 851 break;
848 case 'g': 852 case 'g':
849 case 'm': 853 case 'm':
850 case 's': 854 case 's':
851 AdditionalOptions += option; 855 AdditionalOptions += option;
852 break; 856 break;
853 case 'p': 857 case 'p':
854 switch ( third ) 858 switch ( third )
855 { 859 {
856 case '\0': 860 case '\0':
857 case '1': 861 case '1':
858 StructMemberAlignment = alignSingleByte; 862 StructMemberAlignment = alignSingleByte;
859 if ( fourth == '6' ) 863 if ( fourth == '6' )
860 StructMemberAlignment = alignSixteenBytes; 864 StructMemberAlignment = alignSixteenBytes;
861 break; 865 break;
862 case '2': 866 case '2':
863 StructMemberAlignment = alignTwoBytes; 867 StructMemberAlignment = alignTwoBytes;
864 break; 868 break;
865 case '4': 869 case '4':
866 StructMemberAlignment = alignFourBytes; 870 StructMemberAlignment = alignFourBytes;
867 break; 871 break;
868 case '8': 872 case '8':
869 StructMemberAlignment = alignEightBytes; 873 StructMemberAlignment = alignEightBytes;
870 break; 874 break;
871 default: 875 default:
872 return FALSE; 876 found = FALSE; break;
873 } 877 }
874 break; 878 break;
875 default: 879 default:
876 return FALSE; 880 found = FALSE; break;
877 } 881 }
878 break; 882 break;
879 case 'c': 883 case 'c':
880 if ( second == '\0' ) { 884 if ( second == '\0' ) {
881 CompileOnly = _True; 885 CompileOnly = _True;
882 } else if ( second == 'l' ) { 886 } else if ( second == 'l' ) {
883 if ( *(option+5) == 'n' ) { 887 if ( *(option+5) == 'n' ) {
884 CompileAsManaged = managedAssembly; 888 CompileAsManaged = managedAssembly;
885 TurnOffAssemblyGeneration = _True; 889 TurnOffAssemblyGeneration = _True;
886 } else { 890 } else {
887 CompileAsManaged = managedAssembly; 891 CompileAsManaged = managedAssembly;
888 } 892 }
889 } else { 893 } else {
890 return FALSE; 894 found = FALSE; break;
891 } 895 }
892 break; 896 break;
893 case 'd': 897 case 'd':
894 if ( second != 'r' ) 898 if ( second != 'r' ) {
895 return FALSE; 899 found = FALSE; break;
900 }
896 CompileAsManaged = managedAssembly; 901 CompileAsManaged = managedAssembly;
897 break; 902 break;
898 case 'n': 903 case 'n':
899 if ( second == 'o' && third == 'B' && fourth == 'o' ) { 904 if ( second == 'o' && third == 'B' && fourth == 'o' ) {
900 AdditionalOptions += "/noBool"; 905 AdditionalOptions += "/noBool";
901 break; 906 break;
902 } 907 }
903 if ( second == 'o' && third == 'l' && fourth == 'o' ) { 908 if ( second == 'o' && third == 'l' && fourth == 'o' ) {
904 SuppressStartupBanner = _True; 909 SuppressStartupBanner = _True;
905 break; 910 break;
906 } 911 }
907 return FALSE; 912 found = FALSE; break;
908 case 's': 913 case 's':
909 if ( second == 'h' && third == 'o' && fourth == 'w' ) { 914 if ( second == 'h' && third == 'o' && fourth == 'w' ) {
910 ShowIncludes = _True; 915 ShowIncludes = _True;
911 break; 916 break;
912 } 917 }
913 return FALSE; 918 found = FALSE; break;
914 case 'u': 919 case 'u':
915 UndefineAllPreprocessorDefinitions = _True; 920 UndefineAllPreprocessorDefinitions = _True;
916 break; 921 break;
917 case 'v': 922 case 'v':
918 if ( second == 'd' || second == 'm' ) { 923 if ( second == 'd' || second == 'm' ) {
919 AdditionalOptions += option; 924 AdditionalOptions += option;
920 break; 925 break;
921 } 926 }
922 return FALSE; 927 found = FALSE; break;
923 case 'w': 928 case 'w':
924 switch ( second ) { 929 switch ( second ) {
925 case '\0': 930 case '\0':
926 WarningLevel = warningLevel_0; 931 WarningLevel = warningLevel_0;
927 break; 932 break;
928 case 'd': 933 case 'd':
929 DisableSpecificWarnings += option+3; 934 DisableSpecificWarnings += option+3;
930 break; 935 break;
931 default: 936 default:
932 AdditionalOptions += option; 937 AdditionalOptions += option;
933 } 938 }
934 break; 939 break;
935 default: 940 default:
936 return FALSE; 941 found = FALSE; break;
937 } 942 }
943 if( !found )
944 warn_msg( WarnLogic, "Could not parse Compiler option: %s", option );
938 return TRUE; 945 return TRUE;
939} 946}
940 947
941// VCLinkerTool ----------------------------------------------------- 948// VCLinkerTool -----------------------------------------------------
942VCLinkerTool::VCLinkerTool() 949VCLinkerTool::VCLinkerTool()
943 :EnableCOMDATFolding( optFoldingDefault ), 950 :EnableCOMDATFolding( optFoldingDefault ),
944 GenerateDebugInformation( unset ), 951 GenerateDebugInformation( unset ),
945 GenerateMapFile( unset ), 952 GenerateMapFile( unset ),
946 HeapCommitSize( -1 ), 953 HeapCommitSize( -1 ),
947 HeapReserveSize( -1 ), 954 HeapReserveSize( -1 ),
948 IgnoreAllDefaultLibraries( unset ), 955 IgnoreAllDefaultLibraries( unset ),
949 IgnoreEmbeddedIDL( unset ), 956 IgnoreEmbeddedIDL( unset ),
950 IgnoreImportLibrary( unset ), 957 IgnoreImportLibrary( unset ),
951 LargeAddressAware( addrAwareDefault ), 958 LargeAddressAware( addrAwareDefault ),
952 LinkDLL( unset ), 959 LinkDLL( unset ),
953 LinkIncremental( linkIncrementalYes ), 960 LinkIncremental( linkIncrementalYes ),
954 LinkTimeCodeGeneration( unset ), 961 LinkTimeCodeGeneration( unset ),
955 MapExports( unset ), 962 MapExports( unset ),
956 MapLines( unset ), 963 MapLines( unset ),
957 OptimizeForWindows98( optWin98Default ), 964 OptimizeForWindows98( optWin98Default ),
958 OptimizeReferences( optReferencesDefault ), 965 OptimizeReferences( optReferencesDefault ),
959 RegisterOutput( unset ), 966 RegisterOutput( unset ),
960 ResourceOnlyDLL( unset ), 967 ResourceOnlyDLL( unset ),
961 SetChecksum( unset ), 968 SetChecksum( unset ),
962 ShowProgress( linkProgressNotSet ), 969 ShowProgress( linkProgressNotSet ),
963 StackCommitSize( -1 ), 970 StackCommitSize( -1 ),
964 StackReserveSize( -1 ), 971 StackReserveSize( -1 ),
965 SubSystem( subSystemNotSet ), 972 SubSystem( subSystemNotSet ),
966 SupportUnloadOfDelayLoadedDLL( unset ), 973 SupportUnloadOfDelayLoadedDLL( unset ),
967 SuppressStartupBanner( unset ), 974 SuppressStartupBanner( unset ),
968 SwapRunFromCD( unset ), 975 SwapRunFromCD( unset ),
969 SwapRunFromNet( unset ), 976 SwapRunFromNet( unset ),
970 TargetMachine( machineNotSet ), 977 TargetMachine( machineNotSet ),
971 TerminalServerAware( termSvrAwareDefault ), 978 TerminalServerAware( termSvrAwareDefault ),
972 TurnOffAssemblyGeneration( unset ), 979 TurnOffAssemblyGeneration( unset ),
973 TypeLibraryResourceID( 0 ) 980 TypeLibraryResourceID( 0 )
974{ 981{
975} 982}
976 983
977QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool ) 984QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
978{ 985{
979 strm << _begTool3; 986 strm << _begTool3;
980 strm << _VCLinkerToolName; 987 strm << _VCLinkerToolName;
981 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " ); 988 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " );
982 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); 989 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
983 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 990 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
984 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly ); 991 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly );
985 strm << SPair( _BaseAddress, tool.BaseAddress ); 992 strm << SPair( _BaseAddress, tool.BaseAddress );
986 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs ); 993 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs );
987 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding ); 994 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding );
988 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol ); 995 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol );
989 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); 996 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
990 strm << SPair( _FunctionOrder, tool.FunctionOrder ); 997 strm << SPair( _FunctionOrder, tool.FunctionOrder );
991 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation ); 998 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation );
992 strm << TPair( _GenerateMapFile, tool.GenerateMapFile ); 999 strm << TPair( _GenerateMapFile, tool.GenerateMapFile );
993 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize ); 1000 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize );
994 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize ); 1001 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize );
995 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); 1002 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
996 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); 1003 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
997 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL ); 1004 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL );
998 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary ); 1005 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary );
999 strm << SPair( _ImportLibrary, tool.ImportLibrary ); 1006 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1000 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware ); 1007 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware );
1001 strm << TPair( _LinkDLL, tool.LinkDLL ); 1008 strm << TPair( _LinkDLL, tool.LinkDLL );
1002 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental ); 1009 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental );
1003 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration ); 1010 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration );
1004 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile ); 1011 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile );
1005 strm << TPair( _MapExports, tool.MapExports ); 1012 strm << TPair( _MapExports, tool.MapExports );
1006 strm << SPair( _MapFileName, tool.MapFileName ); 1013 strm << SPair( _MapFileName, tool.MapFileName );
1007 strm << TPair( _MapLines, tool.MapLines ); 1014 strm << TPair( _MapLines, tool.MapLines );
@@ -1025,144 +1032,148 @@ QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
1025 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 1032 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1026 strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD ); 1033 strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD );
1027 strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet ); 1034 strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet );
1028 if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine ); 1035 if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine );
1029 if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware ); 1036 if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware );
1030 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); 1037 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
1031 strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile ); 1038 strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile );
1032 if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID ); 1039 if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID );
1033 strm << SPair( _Version4, tool.Version ); 1040 strm << SPair( _Version4, tool.Version );
1034 strm << "/>"; 1041 strm << "/>";
1035 return strm; 1042 return strm;
1036} 1043}
1037 1044
1038// Hashing routine to do fast option lookups ---- 1045// Hashing routine to do fast option lookups ----
1039// Slightly rewritten to stop on ':' ',' and '\0' 1046// Slightly rewritten to stop on ':' ',' and '\0'
1040// Original routine in qtranslator.cpp ---------- 1047// Original routine in qtranslator.cpp ----------
1041static uint elfHash( const char* name ) 1048static uint elfHash( const char* name )
1042{ 1049{
1043 const uchar *k; 1050 const uchar *k;
1044 uint h = 0; 1051 uint h = 0;
1045 uint g; 1052 uint g;
1046 1053
1047 if ( name ) { 1054 if ( name ) {
1048 k = (const uchar *) name; 1055 k = (const uchar *) name;
1049 while ( (*k) && 1056 while ( (*k) &&
1050 (*k)!= ':' && 1057 (*k)!= ':' &&
1051 (*k)!=',' && 1058 (*k)!=',' &&
1052 (*k)!=' ' ) { 1059 (*k)!=' ' ) {
1053 h = ( h << 4 ) + *k++; 1060 h = ( h << 4 ) + *k++;
1054 if ( (g = (h & 0xf0000000)) != 0 ) 1061 if ( (g = (h & 0xf0000000)) != 0 )
1055 h ^= g >> 24; 1062 h ^= g >> 24;
1056 h &= ~g; 1063 h &= ~g;
1057 } 1064 }
1058 } 1065 }
1059 if ( !h ) 1066 if ( !h )
1060 h = 1; 1067 h = 1;
1061 return h; 1068 return h;
1062} 1069}
1070
1071//#define USE_DISPLAY_HASH
1072#ifdef USE_DISPLAY_HASH
1063static void displayHash( const char* str ) 1073static void displayHash( const char* str )
1064{ 1074{
1065 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str ); 1075 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str );
1066} 1076}
1077#endif
1067 1078
1068bool VCLinkerTool::parseOption( const char* option ) 1079bool VCLinkerTool::parseOption( const char* option )
1069{ 1080{
1070#if 0 1081#ifdef USE_DISPLAY_HASH
1071 // Main options 1082 // Main options
1072 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" ); 1083 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" );
1073 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" ); 1084 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" );
1074 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" ); 1085 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" );
1075 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" ); 1086 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" );
1076 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" ); 1087 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" );
1077 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" ); 1088 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" );
1078 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" ); 1089 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" );
1079 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" ); 1090 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" );
1080 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" ); 1091 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" );
1081 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" ); 1092 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" );
1082 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" ); 1093 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" );
1083 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" ); 1094 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" );
1084 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" ); 1095 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" );
1085 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" ); 1096 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" );
1086 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" ); 1097 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" );
1087 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" ); 1098 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" );
1088 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" ); 1099 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" );
1089 displayHash( "/VXD" ); displayHash( "/WS " ); 1100 displayHash( "/VXD" ); displayHash( "/WS " );
1090#endif 1101#endif
1091#if 0 1102#ifdef USE_DISPLAY_HASH
1092 // Sub options 1103 // Sub options
1093 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" ); 1104 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" );
1094 displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" ); 1105 displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" );
1095 displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" ); 1106 displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" );
1096 displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" ); 1107 displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" );
1097 displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" ); 1108 displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" );
1098 displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" ); 1109 displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" );
1099 displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" ); 1110 displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" );
1100#endif 1111#endif
1101 1112 bool found = TRUE;
1102 switch ( elfHash(option) ) { 1113 switch ( elfHash(option) ) {
1103 case 0x3360dbe: // /ALIGN[:number] 1114 case 0x3360dbe: // /ALIGN[:number]
1104 case 0x1485c34: // /ALLOWBIND[:NO] 1115 case 0x1485c34: // /ALLOWBIND[:NO]
1105 case 0x6b21972: // /DEFAULTLIB:library 1116 case 0x6b21972: // /DEFAULTLIB:library
1106 case 0x396ea92: // /DRIVER[:UPONLY | :WDM] 1117 case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
1107 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] 1118 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
1108 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] 1119 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
1109 case 0x33aec94: // /FIXED[:NO] 1120 case 0x33aec94: // /FIXED[:NO]
1110 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] 1121 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
1111 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] 1122 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
1112 case 0x0348992: // /STUB:filename 1123 case 0x0348992: // /STUB:filename
1113 case 0x0034bc4: // /VXD 1124 case 0x0034bc4: // /VXD
1114 case 0x0034c50: // /WS 1125 case 0x0034c50: // /WS
1115 AdditionalOptions += option; 1126 AdditionalOptions += option;
1116 break; 1127 break;
1117 case 0x679c075: // /ASSEMBLYMODULE:filename 1128 case 0x679c075: // /ASSEMBLYMODULE:filename
1118 AddModuleNamesToAssembly += option+15; 1129 AddModuleNamesToAssembly += option+15;
1119 break; 1130 break;
1120 case 0x062d065: // /ASSEMBLYRESOURCE:filename 1131 case 0x062d065: // /ASSEMBLYRESOURCE:filename
1121 LinkToManagedResourceFile = option+18; 1132 LinkToManagedResourceFile = option+18;
1122 break; 1133 break;
1123 case 0x0336675: // /BASE:{address | @filename,key} 1134 case 0x0336675: // /BASE:{address | @filename,key}
1124 // Do we need to do a manual lookup when '@filename,key'? 1135 // Do we need to do a manual lookup when '@filename,key'?
1125 // Seems BaseAddress only can contain the location... 1136 // Seems BaseAddress only can contain the location...
1126 // We don't use it in Qt, so keep it simple for now 1137 // We don't use it in Qt, so keep it simple for now
1127 BaseAddress = option+6; 1138 BaseAddress = option+6;
1128 break; 1139 break;
1129 case 0x3389797: // /DEBUG 1140 case 0x3389797: // /DEBUG
1130 GenerateDebugInformation = _True; 1141 GenerateDebugInformation = _True;
1131 break; 1142 break;
1132 case 0x0033896: // /DEF:filename 1143 case 0x0033896: // /DEF:filename
1133 ModuleDefinitionFile = option+5; 1144 ModuleDefinitionFile = option+5;
1134 break; 1145 break;
1135 case 0x338a069: // /DELAY:{UNLOAD | NOBIND} 1146 case 0x338a069: // /DELAY:{UNLOAD | NOBIND}
1136 // MS documentation does not specify what to do with 1147 // MS documentation does not specify what to do with
1137 // this option, so we'll put it in AdditionalOptions 1148 // this option, so we'll put it in AdditionalOptions
1138 AdditionalOptions += option; 1149 AdditionalOptions += option;
1139 break; 1150 break;
1140 case 0x06f4bf4: // /DELAYLOAD:dllname 1151 case 0x06f4bf4: // /DELAYLOAD:dllname
1141 DelayLoadDLLs += option+11; 1152 DelayLoadDLLs += option+11;
1142 break; 1153 break;
1143 // case 0x003390c: // /DLL 1154 // case 0x003390c: // /DLL
1144 // This option is not used for vcproj files 1155 // This option is not used for vcproj files
1145 //break; 1156 //break;
1146 case 0x33a3979: // /ENTRY:function 1157 case 0x33a3979: // /ENTRY:function
1147 EntryPointSymbol = option+7; 1158 EntryPointSymbol = option+7;
1148 break; 1159 break;
1149 case 0x033c960: // /HEAP:reserve[,commit] 1160 case 0x033c960: // /HEAP:reserve[,commit]
1150 { 1161 {
1151 QStringList both = QStringList::split( ",", option+6 ); 1162 QStringList both = QStringList::split( ",", option+6 );
1152 HeapReserveSize = both[0].toLong(); 1163 HeapReserveSize = both[0].toLong();
1153 if ( both.count() == 2 ) 1164 if ( both.count() == 2 )
1154 HeapCommitSize = both[1].toLong(); 1165 HeapCommitSize = both[1].toLong();
1155 } 1166 }
1156 break; 1167 break;
1157 case 0x3d91494: // /IDLOUT:[path\]filename 1168 case 0x3d91494: // /IDLOUT:[path\]filename
1158 MergedIDLBaseFileName = option+8; 1169 MergedIDLBaseFileName = option+8;
1159 break; 1170 break;
1160 case 0x345a04c: // /IGNOREIDL 1171 case 0x345a04c: // /IGNOREIDL
1161 IgnoreEmbeddedIDL = _True; 1172 IgnoreEmbeddedIDL = _True;
1162 break; 1173 break;
1163 case 0x3e250e2: // /IMPLIB:filename 1174 case 0x3e250e2: // /IMPLIB:filename
1164 ImportLibrary = option+8; 1175 ImportLibrary = option+8;
1165 break; 1176 break;
1166 case 0xe281ab5: // /INCLUDE:symbol 1177 case 0xe281ab5: // /INCLUDE:symbol
1167 ForceSymbolReferences += option+9; 1178 ForceSymbolReferences += option+9;
1168 break; 1179 break;
@@ -1171,73 +1182,73 @@ bool VCLinkerTool::parseOption( const char* option )
1171 *(option+13) == 'n' ) 1182 *(option+13) == 'n' )
1172 LinkIncremental = linkIncrementalNo; 1183 LinkIncremental = linkIncrementalNo;
1173 else 1184 else
1174 LinkIncremental = linkIncrementalYes; 1185 LinkIncremental = linkIncrementalYes;
1175 break; 1186 break;
1176 case 0x26e4675: // /LARGEADDRESSAWARE[:no] 1187 case 0x26e4675: // /LARGEADDRESSAWARE[:no]
1177 if ( *(option+18) == ':' && 1188 if ( *(option+18) == ':' &&
1178 *(option+19) == 'n' ) 1189 *(option+19) == 'n' )
1179 LargeAddressAware = addrAwareNoLarge; 1190 LargeAddressAware = addrAwareNoLarge;
1180 else 1191 else
1181 LargeAddressAware = addrAwareLarge; 1192 LargeAddressAware = addrAwareLarge;
1182 break; 1193 break;
1183 case 0x0d745c8: // /LIBPATH:dir 1194 case 0x0d745c8: // /LIBPATH:dir
1184 AdditionalLibraryDirectories += option+9; 1195 AdditionalLibraryDirectories += option+9;
1185 break; 1196 break;
1186 case 0x0341877: // /LTCG[:NOSTATUS|:STATUS] 1197 case 0x0341877: // /LTCG[:NOSTATUS|:STATUS]
1187 config->WholeProgramOptimization = _True; 1198 config->WholeProgramOptimization = _True;
1188 LinkTimeCodeGeneration = _True; 1199 LinkTimeCodeGeneration = _True;
1189 if ( *(option+5) == ':' && 1200 if ( *(option+5) == ':' &&
1190 *(option+6) == 'S' ) 1201 *(option+6) == 'S' )
1191 ShowProgress = linkProgressAll; 1202 ShowProgress = linkProgressAll;
1192 break; 1203 break;
1193 case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE} 1204 case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}
1194 switch ( elfHash(option+9) ) { 1205 switch ( elfHash(option+9) ) {
1195 // Very limited documentation on all options but X86, 1206 // Very limited documentation on all options but X86,
1196 // so we put the others in AdditionalOptions... 1207 // so we put the others in AdditionalOptions...
1197 case 0x0046063: // AM33 1208 case 0x0046063: // AM33
1198 case 0x000466d: // ARM 1209 case 0x000466d: // ARM
1199 case 0x0004795: // CEE 1210 case 0x0004795: // CEE
1200 case 0x004d494: // IA64 1211 case 0x004d494: // IA64
1201 case 0x0050672: // M32R 1212 case 0x0050672: // M32R
1202 case 0x0051e53: // MIPS 1213 case 0x0051e53: // MIPS
1203 case 0x51e5646: // MIPS16 1214 case 0x51e5646: // MIPS16
1204 case 0x1e57b05: // MIPSFPU 1215 case 0x1e57b05: // MIPSFPU
1205 case 0x57b09a6: // MIPSFPU16 1216 case 0x57b09a6: // MIPSFPU16
1206 case 0x5852738: // MIPSR41XX 1217 case 0x5852738: // MIPSR41XX
1207 case 0x0005543: // PPC 1218 case 0x0005543: // PPC
1208 case 0x00057b3: // SH3 1219 case 0x00057b3: // SH3
1209 case 0x00057b4: // SH4 1220 case 0x00057b4: // SH4
1210 case 0x00057b5: // SH5 1221 case 0x00057b5: // SH5
1211 case 0x058da12: // THUMB 1222 case 0x058da12: // THUMB
1212 case 0x96d8435: // TRICORE 1223 case 0x96d8435: // TRICORE
1213 AdditionalOptions += option; 1224 AdditionalOptions += option;
1214 break; 1225 break;
1215 case 0x0005bb6: // X86 1226 case 0x0005bb6: // X86
1216 TargetMachine = machineX86; 1227 TargetMachine = machineX86;
1217 break; 1228 break;
1218 default: 1229 default:
1219 return FALSE; 1230 found = FALSE;
1220 } 1231 }
1221 break; 1232 break;
1222 case 0x0034160: // /MAP[:filename] 1233 case 0x0034160: // /MAP[:filename]
1223 GenerateMapFile = _True; 1234 GenerateMapFile = _True;
1224 MapFileName = option+5; 1235 MapFileName = option+5;
1225 break; 1236 break;
1226 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES} 1237 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES}
1227 if ( *(option+9) == 'E' ) 1238 if ( *(option+9) == 'E' )
1228 MapExports = _True; 1239 MapExports = _True;
1229 else if ( *(option+9) == 'L' ) 1240 else if ( *(option+9) == 'L' )
1230 MapLines = _True; 1241 MapLines = _True;
1231 break; 1242 break;
1232 case 0x341a6b5: // /MERGE:from=to 1243 case 0x341a6b5: // /MERGE:from=to
1233 MergeSections = option+7; 1244 MergeSections = option+7;
1234 break; 1245 break;
1235 case 0x0341d8c: // /MIDL:@file 1246 case 0x0341d8c: // /MIDL:@file
1236 MidlCommandFile = option+7; 1247 MidlCommandFile = option+7;
1237 break; 1248 break;
1238 case 0x84e2679: // /NOASSEMBLY 1249 case 0x84e2679: // /NOASSEMBLY
1239 TurnOffAssemblyGeneration = _True; 1250 TurnOffAssemblyGeneration = _True;
1240 break; 1251 break;
1241 case 0x2b21942: // /NODEFAULTLIB[:library] 1252 case 0x2b21942: // /NODEFAULTLIB[:library]
1242 if ( *(option+13) == '\0' ) 1253 if ( *(option+13) == '\0' )
1243 IgnoreAllDefaultLibraries = _True; 1254 IgnoreAllDefaultLibraries = _True;
@@ -1254,316 +1265,319 @@ bool VCLinkerTool::parseOption( const char* option )
1254 { 1265 {
1255 char third = *(option+7); 1266 char third = *(option+7);
1256 switch ( third ) { 1267 switch ( third ) {
1257 case 'F': // REF 1268 case 'F': // REF
1258 if ( *(option+5) == 'R' ) { 1269 if ( *(option+5) == 'R' ) {
1259 OptimizeReferences = optReferences; 1270 OptimizeReferences = optReferences;
1260 } else { // ICF[=iterations] 1271 } else { // ICF[=iterations]
1261 EnableCOMDATFolding = optFolding; 1272 EnableCOMDATFolding = optFolding;
1262 // [=iterations] case is not documented 1273 // [=iterations] case is not documented
1263 } 1274 }
1264 break; 1275 break;
1265 case 'R': // NOREF 1276 case 'R': // NOREF
1266 OptimizeReferences = optNoReferences; 1277 OptimizeReferences = optNoReferences;
1267 break; 1278 break;
1268 case 'I': // NOICF 1279 case 'I': // NOICF
1269 EnableCOMDATFolding = optNoFolding; 1280 EnableCOMDATFolding = optNoFolding;
1270 break; 1281 break;
1271 case 'N': // WIN98 1282 case 'N': // WIN98
1272 OptimizeForWindows98 = optWin98Yes; 1283 OptimizeForWindows98 = optWin98Yes;
1273 break; 1284 break;
1274 case 'W': // NOWIN98 1285 case 'W': // NOWIN98
1275 OptimizeForWindows98 = optWin98No; 1286 OptimizeForWindows98 = optWin98No;
1276 break; 1287 break;
1277 default: 1288 default:
1278 return FALSE; 1289 found = FALSE;
1279 } 1290 }
1280 } 1291 }
1281 break; 1292 break;
1282 case 0x34468a2: // /ORDER:@filename 1293 case 0x34468a2: // /ORDER:@filename
1283 FunctionOrder = option+8; 1294 FunctionOrder = option+8;
1284 break; 1295 break;
1285 case 0x00344a4: // /OUT:filename 1296 case 0x00344a4: // /OUT:filename
1286 OutputFile = option+5; 1297 OutputFile = option+5;
1287 break; 1298 break;
1288 case 0x0034482: // /PDB:filename 1299 case 0x0034482: // /PDB:filename
1289 ProgramDatabaseFile = option+5; 1300 ProgramDatabaseFile = option+5;
1290 break; 1301 break;
1291 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name 1302 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
1292 StripPrivateSymbols = option+13; 1303 StripPrivateSymbols = option+13;
1293 break; 1304 break;
1294 case 0x6a09535: // /RELEASE 1305 case 0x6a09535: // /RELEASE
1295 SetChecksum = _True; 1306 SetChecksum = _True;
1296 break; 1307 break;
1297 case 0x348857b: // /STACK:reserve[,commit] 1308 case 0x348857b: // /STACK:reserve[,commit]
1298 { 1309 {
1299 QStringList both = QStringList::split( ",", option+7 ); 1310 QStringList both = QStringList::split( ",", option+7 );
1300 StackReserveSize = both[0].toLong(); 1311 StackReserveSize = both[0].toLong();
1301 if ( both.count() == 2 ) 1312 if ( both.count() == 2 )
1302 StackCommitSize = both[1].toLong(); 1313 StackCommitSize = both[1].toLong();
1303 } 1314 }
1304 break; 1315 break;
1305 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]] 1316 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
1306 { 1317 {
1307 // Split up in subsystem, and version number 1318 // Split up in subsystem, and version number
1308 QStringList both = QStringList::split( ",", option+11 ); 1319 QStringList both = QStringList::split( ",", option+11 );
1309 switch ( elfHash(both[0].latin1()) ) { 1320 switch ( elfHash(both[0].latin1()) ) {
1310 case 0x8438445: // CONSOLE 1321 case 0x8438445: // CONSOLE
1311 SubSystem = subSystemConsole; 1322 SubSystem = subSystemConsole;
1312 break; 1323 break;
1313 case 0xbe29493: // WINDOWS 1324 case 0xbe29493: // WINDOWS
1314 SubSystem = subSystemWindows; 1325 SubSystem = subSystemWindows;
1315 break; 1326 break;
1316 // The following are undocumented, so add them to AdditionalOptions 1327 // The following are undocumented, so add them to AdditionalOptions
1317 case 0x240949e: // EFI_APPLICATION 1328 case 0x240949e: // EFI_APPLICATION
1318 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER 1329 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
1319 case 0x9af477d: // EFI_ROM 1330 case 0x9af477d: // EFI_ROM
1320 case 0xd34df42: // EFI_RUNTIME_DRIVER 1331 case 0xd34df42: // EFI_RUNTIME_DRIVER
1321 case 0x5268ea5: // NATIVE 1332 case 0x5268ea5: // NATIVE
1322 case 0x05547e8: // POSIX 1333 case 0x05547e8: // POSIX
1323 case 0x2949c95: // WINDOWSCE 1334 case 0x2949c95: // WINDOWSCE
1324 AdditionalOptions += option; 1335 AdditionalOptions += option;
1325 break; 1336 break;
1326 default: 1337 default:
1327 return FALSE; 1338 found = FALSE;
1328 } 1339 }
1329 } 1340 }
1330 break; 1341 break;
1331 case 0x8b654de: // /SWAPRUN:{NET | CD} 1342 case 0x8b654de: // /SWAPRUN:{NET | CD}
1332 if ( *(option+9) == 'N' ) 1343 if ( *(option+9) == 'N' )
1333 SwapRunFromNet = _True; 1344 SwapRunFromNet = _True;
1334 else if ( *(option+9) == 'C' ) 1345 else if ( *(option+9) == 'C' )
1335 SwapRunFromCD = _True; 1346 SwapRunFromCD = _True;
1336 else 1347 else
1337 return FALSE; 1348 found = FALSE;
1338 break; 1349 break;
1339 case 0x34906d4: // /TLBID:id 1350 case 0x34906d4: // /TLBID:id
1340 TypeLibraryResourceID = QString( option+7 ).toLong(); 1351 TypeLibraryResourceID = QString( option+7 ).toLong();
1341 break; 1352 break;
1342 case 0x4907494: // /TLBOUT:[path\]filename 1353 case 0x4907494: // /TLBOUT:[path\]filename
1343 TypeLibraryFile = option+8; 1354 TypeLibraryFile = option+8;
1344 break; 1355 break;
1345 case 0x976b525: // /TSAWARE[:NO] 1356 case 0x976b525: // /TSAWARE[:NO]
1346 if ( *(option+8) == ':' ) 1357 if ( *(option+8) == ':' )
1347 TerminalServerAware = termSvrAwareNo; 1358 TerminalServerAware = termSvrAwareNo;
1348 else 1359 else
1349 TerminalServerAware = termSvrAwareYes; 1360 TerminalServerAware = termSvrAwareYes;
1350 break; 1361 break;
1351 case 0xaa67735: // /VERBOSE[:lib] 1362 case 0xaa67735: // /VERBOSE[:lib]
1352 if ( *(option+9) == ':' ) { 1363 if ( *(option+9) == ':' ) {
1353 ShowProgress = linkProgressLibs; 1364 ShowProgress = linkProgressLibs;
1354 AdditionalOptions += option; 1365 AdditionalOptions += option;
1355 } else { 1366 } else {
1356 ShowProgress = linkProgressAll; 1367 ShowProgress = linkProgressAll;
1357 } 1368 }
1358 break; 1369 break;
1359 case 0xaa77f7e: // /VERSION:major[.minor] 1370 case 0xaa77f7e: // /VERSION:major[.minor]
1360 Version = option+9; 1371 Version = option+9;
1361 break; 1372 break;
1362 default: 1373 default:
1363 return FALSE; 1374 found = FALSE;
1364 } 1375 }
1365 return TRUE; 1376 if( !found )
1377 warn_msg( WarnLogic, "Could not parse Linker options: %s", option );
1378 return found;
1366} 1379}
1367 1380
1368// VCMIDLTool ------------------------------------------------------- 1381// VCMIDLTool -------------------------------------------------------
1369VCMIDLTool::VCMIDLTool() 1382VCMIDLTool::VCMIDLTool()
1370 :DefaultCharType( midlCharUnsigned ), 1383 :DefaultCharType( midlCharUnsigned ),
1371 EnableErrorChecks( midlDisableAll ), 1384 EnableErrorChecks( midlDisableAll ),
1372 ErrorCheckAllocations( unset ), 1385 ErrorCheckAllocations( unset ),
1373 ErrorCheckBounds( unset ), 1386 ErrorCheckBounds( unset ),
1374 ErrorCheckEnumRange( unset ), 1387 ErrorCheckEnumRange( unset ),
1375 ErrorCheckRefPointers( unset ), 1388 ErrorCheckRefPointers( unset ),
1376 ErrorCheckStubData( unset ), 1389 ErrorCheckStubData( unset ),
1377 GenerateStublessProxies( unset ), 1390 GenerateStublessProxies( unset ),
1378 GenerateTypeLibrary( unset ), 1391 GenerateTypeLibrary( unset ),
1379 IgnoreStandardIncludePath( unset ), 1392 IgnoreStandardIncludePath( unset ),
1380 MkTypLibCompatible( unset ), 1393 MkTypLibCompatible( unset ),
1381 StructMemberAlignment( midlAlignNotSet ), 1394 StructMemberAlignment( midlAlignNotSet ),
1382 SuppressStartupBanner( unset ), 1395 SuppressStartupBanner( unset ),
1383 TargetEnvironment( midlTargetNotSet ), 1396 TargetEnvironment( midlTargetNotSet ),
1384 ValidateParameters( unset ), 1397 ValidateParameters( unset ),
1385 WarnAsError( unset ), 1398 WarnAsError( unset ),
1386 WarningLevel( midlWarningLevel_0 ) 1399 WarningLevel( midlWarningLevel_0 )
1387{ 1400{
1388} 1401}
1389 1402
1390QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool ) 1403QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool )
1391{ 1404{
1392 strm << _begTool3; 1405 strm << _begTool3;
1393 strm << _VCMIDLToolName; 1406 strm << _VCMIDLToolName;
1394 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 1407 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1395 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1408 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1396 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions ); 1409 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions );
1397 strm << EPair( _DefaultCharType, tool.DefaultCharType ); 1410 strm << EPair( _DefaultCharType, tool.DefaultCharType );
1398 strm << SPair( _DLLDataFileName, tool.DLLDataFileName ); 1411 strm << SPair( _DLLDataFileName, tool.DLLDataFileName );
1399 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks ); 1412 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks );
1400 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations ); 1413 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations );
1401 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds ); 1414 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds );
1402 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange ); 1415 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange );
1403 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers ); 1416 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers );
1404 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData ); 1417 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData );
1405 strm << XPair( _FullIncludePath, tool.FullIncludePath ); 1418 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1406 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies ); 1419 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies );
1407 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary ); 1420 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary );
1408 strm << SPair( _HeaderFileName, tool.HeaderFileName ); 1421 strm << SPair( _HeaderFileName, tool.HeaderFileName );
1409 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); 1422 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1410 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName ); 1423 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName );
1411 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible ); 1424 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible );
1412 strm << SPair( _OutputDirectory4, tool.OutputDirectory ); 1425 strm << SPair( _OutputDirectory4, tool.OutputDirectory );
1413 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 1426 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1414 strm << SPair( _ProxyFileName, tool.ProxyFileName ); 1427 strm << SPair( _ProxyFileName, tool.ProxyFileName );
1415 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors ); 1428 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors );
1416 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); 1429 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
1417 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 1430 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1418 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment ); 1431 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment );
1419 strm << SPair( _TypeLibraryName, tool.TypeLibraryName ); 1432 strm << SPair( _TypeLibraryName, tool.TypeLibraryName );
1420 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); 1433 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
1421 strm << TPair( _ValidateParameters, tool.ValidateParameters ); 1434 strm << TPair( _ValidateParameters, tool.ValidateParameters );
1422 strm << TPair( _WarnAsError, tool.WarnAsError ); 1435 strm << TPair( _WarnAsError, tool.WarnAsError );
1423 strm << EPair( _WarningLevel, tool.WarningLevel ); 1436 strm << EPair( _WarningLevel, tool.WarningLevel );
1424 strm << "/>"; 1437 strm << "/>";
1425 return strm; 1438 return strm;
1426} 1439}
1427 1440
1428bool VCMIDLTool::parseOption( const char* option ) 1441bool VCMIDLTool::parseOption( const char* option )
1429{ 1442{
1430#if 0 1443#ifdef USE_DISPLAY_HASH
1431 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" ); 1444 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" );
1432 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" ); 1445 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" );
1433 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" ); 1446 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" );
1434 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" ); 1447 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" );
1435 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" ); 1448 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" );
1436 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" ); 1449 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" );
1437 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" ); 1450 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" );
1438 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" ); 1451 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" );
1439 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" ); 1452 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" );
1440 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" ); 1453 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" );
1441 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" ); 1454 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" );
1442 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" ); 1455 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" );
1443 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" ); 1456 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" );
1444 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" ); 1457 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" );
1445 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" ); 1458 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" );
1446 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" ); 1459 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" );
1447 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" ); 1460 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" );
1448 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" ); 1461 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" );
1449 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" ); 1462 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" );
1450 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" ); 1463 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" );
1451 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" ); 1464 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" );
1452 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" ); 1465 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" );
1453 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" ); 1466 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" );
1454 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" ); 1467 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" );
1455 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" ); 1468 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" );
1456 displayHash( "/win32" ); displayHash( "/win64" ); 1469 displayHash( "/win32" ); displayHash( "/win64" );
1457#endif 1470#endif
1471 bool found = TRUE;
1458 int offset = 0; 1472 int offset = 0;
1459 switch( elfHash(option) ) { 1473 switch( elfHash(option) ) {
1460 case 0x0000334: // /D name[=def] 1474 case 0x0000334: // /D name[=def]
1461 PreprocessorDefinitions += option+3; 1475 PreprocessorDefinitions += option+3;
1462 break; 1476 break;
1463 case 0x0000339: // /I directory-list 1477 case 0x0000339: // /I directory-list
1464 AdditionalIncludeDirectories += option+3; 1478 AdditionalIncludeDirectories += option+3;
1465 break; 1479 break;
1466 case 0x0345f96: // /Oicf 1480 case 0x0345f96: // /Oicf
1467 case 0x00345f6: // /Oif 1481 case 0x00345f6: // /Oif
1468 GenerateStublessProxies = _True; 1482 GenerateStublessProxies = _True;
1469 break; 1483 break;
1470 case 0x0000345: // /U name 1484 case 0x0000345: // /U name
1471 UndefinePreprocessorDefinitions += option+3; 1485 UndefinePreprocessorDefinitions += option+3;
1472 break; 1486 break;
1473 case 0x00034c8: // /WX 1487 case 0x00034c8: // /WX
1474 WarnAsError = _True; 1488 WarnAsError = _True;
1475 break; 1489 break;
1476 case 0x3582fde: // /align {N} 1490 case 0x3582fde: // /align {N}
1477 offset = 3; // Fallthrough 1491 offset = 3; // Fallthrough
1478 case 0x0003510: // /Zp {N} 1492 case 0x0003510: // /Zp {N}
1479 switch ( *(option+offset+4) ) { 1493 switch ( *(option+offset+4) ) {
1480 case '1': 1494 case '1':
1481 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes; 1495 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes;
1482 break; 1496 break;
1483 case '2': 1497 case '2':
1484 StructMemberAlignment = midlAlignTwoBytes; 1498 StructMemberAlignment = midlAlignTwoBytes;
1485 break; 1499 break;
1486 case '4': 1500 case '4':
1487 StructMemberAlignment = midlAlignFourBytes; 1501 StructMemberAlignment = midlAlignFourBytes;
1488 break; 1502 break;
1489 case '8': 1503 case '8':
1490 StructMemberAlignment = midlAlignEightBytes; 1504 StructMemberAlignment = midlAlignEightBytes;
1491 break; 1505 break;
1492 default: 1506 default:
1493 return FALSE; 1507 found = FALSE;
1494 } 1508 }
1495 break; 1509 break;
1496 case 0x0359e82: // /char {ascii7|signed|unsigned} 1510 case 0x0359e82: // /char {ascii7|signed|unsigned}
1497 switch( *(option+6) ) { 1511 switch( *(option+6) ) {
1498 case 'a': 1512 case 'a':
1499 DefaultCharType = midlCharAscii7; 1513 DefaultCharType = midlCharAscii7;
1500 break; 1514 break;
1501 case 's': 1515 case 's':
1502 DefaultCharType = midlCharSigned; 1516 DefaultCharType = midlCharSigned;
1503 break; 1517 break;
1504 case 'u': 1518 case 'u':
1505 DefaultCharType = midlCharUnsigned; 1519 DefaultCharType = midlCharUnsigned;
1506 break; 1520 break;
1507 default: 1521 default:
1508 return FALSE; 1522 found = FALSE;
1509 } 1523 }
1510 break; 1524 break;
1511 case 0xa766524: // /cpp_opt options 1525 case 0xa766524: // /cpp_opt options
1512 CPreprocessOptions += option+9; 1526 CPreprocessOptions += option+9;
1513 break; 1527 break;
1514 case 0xb32abf1: // /dlldata filename 1528 case 0xb32abf1: // /dlldata filename
1515 DLLDataFileName = option + 9; 1529 DLLDataFileName = option + 9;
1516 break; 1530 break;
1517 case 0x0035c56: // /env {win32|win64} 1531 case 0x0035c56: // /env {win32|win64}
1518 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32; 1532 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32;
1519 break; 1533 break;
1520 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data} 1534 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
1521 EnableErrorChecks = midlEnableCustom; 1535 EnableErrorChecks = midlEnableCustom;
1522 switch ( *(option+7) ) { 1536 switch ( *(option+7) ) {
1523 case 'a': 1537 case 'a':
1524 if ( *(option+10) == '\0' ) 1538 if ( *(option+10) == '\0' )
1525 EnableErrorChecks = midlEnableAll; 1539 EnableErrorChecks = midlEnableAll;
1526 else 1540 else
1527 ErrorCheckAllocations = _True; 1541 ErrorCheckAllocations = _True;
1528 break; 1542 break;
1529 case 'b': 1543 case 'b':
1530 ErrorCheckBounds = _True; 1544 ErrorCheckBounds = _True;
1531 break; 1545 break;
1532 case 'e': 1546 case 'e':
1533 ErrorCheckEnumRange = _True; 1547 ErrorCheckEnumRange = _True;
1534 break; 1548 break;
1535 case 'n': 1549 case 'n':
1536 EnableErrorChecks = midlDisableAll; 1550 EnableErrorChecks = midlDisableAll;
1537 break; 1551 break;
1538 case 'r': 1552 case 'r':
1539 break;
1540 ErrorCheckRefPointers = _True; 1553 ErrorCheckRefPointers = _True;
1541 case 's':
1542 break; 1554 break;
1555 case 's':
1543 ErrorCheckStubData = _True; 1556 ErrorCheckStubData = _True;
1557 break;
1544 default: 1558 default:
1545 return FALSE; 1559 found = FALSE;
1546 } 1560 }
1547 break; 1561 break;
1548 case 0x5eb7af2: // /header filename 1562 case 0x5eb7af2: // /header filename
1549 offset = 5; 1563 offset = 5;
1550 case 0x0000358: // /h filename 1564 case 0x0000358: // /h filename
1551 HeaderFileName = option + offset + 3; 1565 HeaderFileName = option + offset + 3;
1552 break; 1566 break;
1553 case 0x0035ff4: // /iid filename 1567 case 0x0035ff4: // /iid filename
1554 InterfaceIdentifierFileName = option+5; 1568 InterfaceIdentifierFileName = option+5;
1555 break; 1569 break;
1556 case 0x64b7933: // /mktyplib203 1570 case 0x64b7933: // /mktyplib203
1557 MkTypLibCompatible = _True; 1571 MkTypLibCompatible = _True;
1558 break; 1572 break;
1559 case 0x8e0b0a2: // /no_def_idir 1573 case 0x8e0b0a2: // /no_def_idir
1560 IgnoreStandardIncludePath = _True; 1574 IgnoreStandardIncludePath = _True;
1561 break; 1575 break;
1562 case 0x65635ef: // /nologo 1576 case 0x65635ef: // /nologo
1563 SuppressStartupBanner = _True; 1577 SuppressStartupBanner = _True;
1564 break; 1578 break;
1565 case 0x3656b22: // /notlb 1579 case 0x3656b22: // /notlb
1566 GenerateTypeLibrary = _True; 1580 GenerateTypeLibrary = _True;
1567 break; 1581 break;
1568 case 0x000035f: // /o filename 1582 case 0x000035f: // /o filename
1569 RedirectOutputAndErrors = option+3; 1583 RedirectOutputAndErrors = option+3;
@@ -1626,116 +1640,118 @@ bool VCMIDLTool::parseOption( const char* option )
1626 case 0xce9b12b: // /syntax_check 1640 case 0xce9b12b: // /syntax_check
1627 case 0xc9b5f16: // /use_epv 1641 case 0xc9b5f16: // /use_epv
1628 AdditionalOptions += option; 1642 AdditionalOptions += option;
1629 break; 1643 break;
1630 default: 1644 default:
1631 // /W{0|1|2|3|4} case 1645 // /W{0|1|2|3|4} case
1632 if ( *(option+1) == 'W' ) { 1646 if ( *(option+1) == 'W' ) {
1633 switch ( *(option+2) ) { 1647 switch ( *(option+2) ) {
1634 case '0': 1648 case '0':
1635 WarningLevel = midlWarningLevel_0; 1649 WarningLevel = midlWarningLevel_0;
1636 break; 1650 break;
1637 case '1': 1651 case '1':
1638 WarningLevel = midlWarningLevel_1; 1652 WarningLevel = midlWarningLevel_1;
1639 break; 1653 break;
1640 case '2': 1654 case '2':
1641 WarningLevel = midlWarningLevel_2; 1655 WarningLevel = midlWarningLevel_2;
1642 break; 1656 break;
1643 case '3': 1657 case '3':
1644 WarningLevel = midlWarningLevel_3; 1658 WarningLevel = midlWarningLevel_3;
1645 break; 1659 break;
1646 case '4': 1660 case '4':
1647 WarningLevel = midlWarningLevel_4; 1661 WarningLevel = midlWarningLevel_4;
1648 break; 1662 break;
1649 default: 1663 default:
1650 return FALSE; 1664 found = FALSE;
1651 } 1665 }
1652 } 1666 }
1653 break; 1667 break;
1654 } 1668 }
1669 if( !found )
1670 warn_msg( WarnLogic, "Could not parse MIDL option: %s", option );
1655 return TRUE; 1671 return TRUE;
1656} 1672}
1657 1673
1658// VCLibrarianTool -------------------------------------------------- 1674// VCLibrarianTool --------------------------------------------------
1659VCLibrarianTool::VCLibrarianTool() 1675VCLibrarianTool::VCLibrarianTool()
1660 :IgnoreAllDefaultLibraries( unset ), 1676 :IgnoreAllDefaultLibraries( unset ),
1661 SuppressStartupBanner( _True ) 1677 SuppressStartupBanner( _True )
1662{ 1678{
1663} 1679}
1664 1680
1665QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool ) 1681QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool )
1666{ 1682{
1667 strm << _begTool3; 1683 strm << _begTool3;
1668 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) ); 1684 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) );
1669 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies ); 1685 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies );
1670 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); 1686 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
1671 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1687 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1672 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions ); 1688 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions );
1673 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); 1689 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
1674 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); 1690 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
1675 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); 1691 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
1676 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); 1692 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1677 strm << SPair( _OutputFile, tool.OutputFile ); 1693 strm << SPair( _OutputFile, tool.OutputFile );
1678 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); 1694 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1679 strm << "/>"; 1695 strm << "/>";
1680 return strm; 1696 return strm;
1681} 1697}
1682 1698
1683// VCCustomBuildTool ------------------------------------------------ 1699// VCCustomBuildTool ------------------------------------------------
1684VCCustomBuildTool::VCCustomBuildTool() 1700VCCustomBuildTool::VCCustomBuildTool()
1685{ 1701{
1686 ToolName = "VCCustomBuildTool"; 1702 ToolName = "VCCustomBuildTool";
1687} 1703}
1688 1704
1689QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool ) 1705QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
1690{ 1706{
1691 strm << _begTool3; 1707 strm << _begTool3;
1692 strm << SPair( _ToolName, tool.ToolName ); 1708 strm << SPair( _ToolName, tool.ToolName );
1693 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" ); 1709 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
1694 strm << SPair( _CommandLine4, tool.CommandLine ); 1710 strm << SPair( _CommandLine4, tool.CommandLine );
1695 strm << SPair( _Description4, tool.Description ); 1711 strm << SPair( _Description4, tool.Description );
1696 strm << SPair( _Outputs4, tool.Outputs ); 1712 strm << SPair( _Outputs4, tool.Outputs );
1697 strm << SPair( _ToolPath, tool.ToolPath ); 1713 strm << SPair( _ToolPath, tool.ToolPath );
1698 strm << "/>"; 1714 strm << "/>";
1699 return strm; 1715 return strm;
1700} 1716}
1701 1717
1702// VCResourceCompilerTool ------------------------------------------- 1718// VCResourceCompilerTool -------------------------------------------
1703VCResourceCompilerTool::VCResourceCompilerTool() 1719VCResourceCompilerTool::VCResourceCompilerTool()
1704 : Culture( rcUseDefault ), 1720 : Culture( rcUseDefault ),
1705 IgnoreStandardIncludePath( unset ), 1721 IgnoreStandardIncludePath( unset ),
1706 ShowProgress( linkProgressNotSet ) 1722 ShowProgress( linkProgressNotSet )
1707{ 1723{
1708 PreprocessorDefinitions = "NDEBUG"; 1724 PreprocessorDefinitions = "NDEBUG";
1709} 1725}
1710 1726
1711QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool ) 1727QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool )
1712{ 1728{
1713 strm << _begTool3; 1729 strm << _begTool3;
1714 strm << _VCResourceCompilerToolName; 1730 strm << _VCResourceCompilerToolName;
1715 strm << SPair( _ToolPath, tool.ToolPath ); 1731 strm << SPair( _ToolPath, tool.ToolPath );
1716 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); 1732 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1717 strm << XPair( _AdditionalOptions, tool.AdditionalOptions ); 1733 strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " );
1718 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture ); 1734 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture );
1719 strm << XPair( _FullIncludePath, tool.FullIncludePath ); 1735 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1720 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); 1736 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1721 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); 1737 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1722 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName ); 1738 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName );
1723 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); 1739 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1724 strm << "/>"; 1740 strm << "/>";
1725 return strm; 1741 return strm;
1726} 1742}
1727 1743
1728// VCEventTool ------------------------------------------------- 1744// VCEventTool -------------------------------------------------
1729QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool ) 1745QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool )
1730{ 1746{
1731 strm << _begTool3; 1747 strm << _begTool3;
1732 strm << SPair( _ToolName, tool.ToolName ); 1748 strm << SPair( _ToolName, tool.ToolName );
1733 strm << SPair( _ToolPath, tool.ToolPath ); 1749 strm << SPair( _ToolPath, tool.ToolPath );
1734 strm << SPair( _CommandLine4, tool.CommandLine ); 1750 strm << SPair( _CommandLine4, tool.CommandLine );
1735 strm << SPair( _Description4, tool.Description ); 1751 strm << SPair( _Description4, tool.Description );
1736 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild ); 1752 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild );
1737 strm << "/>"; 1753 strm << "/>";
1738 return strm; 1754 return strm;
1739} 1755}
1740 1756
1741// VCPostBuildEventTool --------------------------------------------- 1757// VCPostBuildEventTool ---------------------------------------------
@@ -1830,106 +1846,127 @@ void VCFilter::generateMOC( QTextStream &strm, QString str ) const
1830 strm << _Name5; 1846 strm << _Name5;
1831 strm << Config->Name; 1847 strm << Config->Name;
1832 strm << "\">"; 1848 strm << "\">";
1833 strm << _begTool5; 1849 strm << _begTool5;
1834 strm << _VCCustomBuildTool; 1850 strm << _VCCustomBuildTool;
1835 strm << _Description6; 1851 strm << _Description6;
1836 strm << "Moc'ing " << str << "...\""; 1852 strm << "Moc'ing " << str << "...\"";
1837 strm << _CommandLine6; 1853 strm << _CommandLine6;
1838 strm << mocApp; 1854 strm << mocApp;
1839 strm << " " << str << " -o " << mocOutput << "\""; 1855 strm << " " << str << " -o " << mocOutput << "\"";
1840 strm << _AdditionalDependencies6; 1856 strm << _AdditionalDependencies6;
1841 strm << mocApp << "\""; 1857 strm << mocApp << "\"";
1842 strm << _Outputs6; 1858 strm << _Outputs6;
1843 strm << mocOutput << "\""; 1859 strm << mocOutput << "\"";
1844 strm << "/>"; 1860 strm << "/>";
1845 strm << _endFileConfiguration; 1861 strm << _endFileConfiguration;
1846} 1862}
1847 1863
1848void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const 1864void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const
1849{ 1865{
1850 QString uicApp = Project->var("QMAKE_UIC"); 1866 QString uicApp = Project->var("QMAKE_UIC");
1851 QString mocApp = Project->var( "QMAKE_MOC" ); 1867 QString mocApp = Project->var( "QMAKE_MOC" );
1852 QString fname = str.section( '\\', -1 ); 1868 QString fname = str.section( '\\', -1 );
1853 QString mocDir = Project->var( "MOC_DIR" ); 1869 QString mocDir = Project->var( "MOC_DIR" );
1870 QString uiDir = Project->var( "UI_DIR" );
1871 QString uiHeaders;
1872 QString uiSources;
1873
1874 // Determining the paths for the output files.
1875 int slash = str.findRev( '\\' );
1876 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString( ".\\" );
1877 if( !uiDir.isEmpty() ) {
1878 uiHeaders = uiDir;
1879 uiSources = uiDir;
1880 } else {
1881 uiHeaders = Project->var( "UI_HEADERS_DIR" );
1882 uiSources = Project->var( "UI_SOURCES_DIR" );
1883 if( uiHeaders.isEmpty() )
1884 uiHeaders = pname;
1885 if( uiSources.isEmpty() )
1886 uiSources = pname;
1887 }
1888 if( !uiHeaders.endsWith( "\\" ) )
1889 uiHeaders += "\\";
1890 if( !uiSources.endsWith( "\\" ) )
1891 uiSources += "\\";
1892
1893 // Determine the file name.
1854 int dot = fname.findRev( '.' ); 1894 int dot = fname.findRev( '.' );
1855 if( dot != -1 ) 1895 if( dot != -1 )
1856 fname.truncate( dot ); 1896 fname.truncate( dot );
1857 1897
1858 int slash = str.findRev( '\\' );
1859 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\");
1860
1861 strm << _begFileConfiguration; 1898 strm << _begFileConfiguration;
1862 strm << _Name5; 1899 strm << _Name5;
1863 strm << Config->Name; 1900 strm << Config->Name;
1864 strm << "\">"; 1901 strm << "\">";
1865 strm << _begTool5; 1902 strm << _begTool5;
1866 strm << _VCCustomBuildTool; 1903 strm << _VCCustomBuildTool;
1867 strm << _Description6; 1904 strm << _Description6;
1868 strm << "Uic'ing " << str << "...\""; 1905 strm << "Uic'ing " << str << "...\"";
1869 strm << _CommandLine6; 1906 strm << _CommandLine6;
1870 strm << uicApp << " " << str << " -o " << pname << fname << ".h &amp;&amp; "; // Create .h from .ui file 1907 strm << uicApp << " " << str << " -o " << uiHeaders << fname << ".h &amp;&amp; "; // Create .h from .ui file
1871 strm << uicApp << " " << str << " -i " << fname << ".h -o " << pname << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file 1908 strm << uicApp << " " << str << " -i " << fname << ".h -o " << uiSources << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file
1872 strm << mocApp << " " << pname << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\""; 1909 strm << mocApp << " " << uiHeaders << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\"";
1873 strm << _AdditionalDependencies6; 1910 strm << _AdditionalDependencies6;
1874 strm << mocApp << ";" << uicApp << "\""; 1911 strm << mocApp << ";" << uicApp << "\"";
1875 strm << _Outputs6; 1912 strm << _Outputs6;
1876 strm << pname << fname << ".h;" << pname << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\""; 1913 strm << uiHeaders << fname << ".h;" << uiSources << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\"";
1877 strm << "/>"; 1914 strm << "/>";
1878 strm << _endFileConfiguration; 1915 strm << _endFileConfiguration;
1879} 1916}
1880 1917
1881QTextStream &operator<<( QTextStream &strm, const VCFilter &tool ) 1918QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1882{ 1919{
1883 if ( tool.Files.count() == 0 ) 1920 if ( tool.Files.count() == 0 )
1884 return strm; 1921 return strm;
1885 1922
1886 strm << _begFilter; 1923 strm << _begFilter;
1887 strm << SPair( _Name3, tool.Name ); 1924 strm << SPair( _Name3, tool.Name );
1888 strm << TPair( _ParseFiles, tool.ParseFiles ); 1925 strm << TPair( _ParseFiles, tool.ParseFiles );
1889 strm << SPair( _Filter, tool.Filter ); 1926 strm << SPair( _Filter, tool.Filter );
1890 strm << ">"; 1927 strm << ">";
1891 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) { 1928 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
1892 strm << _begFile; 1929 strm << _begFile;
1893 strm << SPair( _RelativePath, *it ); 1930 strm << SPair( _RelativePath, *it );
1894 strm << ">"; 1931 strm << ">";
1895 if ( tool.CustomBuild == moc ) 1932 if ( tool.CustomBuild == moc )
1896 tool.generateMOC( strm, *it ); 1933 tool.generateMOC( strm, *it );
1897 else if ( tool.CustomBuild == uic ) 1934 else if ( tool.CustomBuild == uic )
1898 tool.generateUIC( strm, *it ); 1935 tool.generateUIC( strm, *it );
1899 strm << _endFile; 1936 strm << _endFile;
1900 } 1937 }
1901 1938
1902 strm << _endFilter; 1939 strm << _endFilter;
1903 return strm; 1940 return strm;
1904} 1941}
1905 1942
1906// VCProject -------------------------------------------------------- 1943// VCProject --------------------------------------------------------
1907VCProject::VCProject() 1944VCProject::VCProject()
1908{ 1945{
1909 QUuid uniqueId;
1910#if defined(Q_WS_WIN32) 1946#if defined(Q_WS_WIN32)
1911 GUID guid; 1947 GUID guid;
1948 QUuid uniqueId;
1912 HRESULT h = CoCreateGuid( &guid ); 1949 HRESULT h = CoCreateGuid( &guid );
1913 if ( h == S_OK ) 1950 if ( h == S_OK )
1914 uniqueId = QUuid( guid ); 1951 uniqueId = QUuid( guid );
1915 ProjectGUID = uniqueId.toString(); 1952 ProjectGUID = uniqueId.toString();
1916#else 1953#else
1917 // Qt doesn't support GUID on other platforms yet 1954 // Qt doesn't support GUID on other platforms yet
1918 ProjectGUID = ""; 1955 ProjectGUID = "";
1919#endif 1956#endif
1920} 1957}
1921 1958
1922QTextStream &operator<<( QTextStream &strm, const VCProject &tool ) 1959QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
1923{ 1960{
1924 strm << _xmlInit; 1961 strm << _xmlInit;
1925 strm << _begVisualStudioProject; 1962 strm << _begVisualStudioProject;
1926 strm << _ProjectType; 1963 strm << _ProjectType;
1927 strm << SPair( _Version1, tool.Version ); 1964 strm << SPair( _Version1, tool.Version );
1928 strm << SPair( _Name1, tool.Name ); 1965 strm << SPair( _Name1, tool.Name );
1929 strm << SPair( _ProjectGUID, tool.ProjectGUID ); 1966 strm << SPair( _ProjectGUID, tool.ProjectGUID );
1930 strm << SPair( _SccProjectName, tool.SccProjectName ); 1967 strm << SPair( _SccProjectName, tool.SccProjectName );
1931 strm << SPair( _SccLocalPath, tool.SccLocalPath ); 1968 strm << SPair( _SccLocalPath, tool.SccLocalPath );
1932 strm << ">"; 1969 strm << ">";
1933 strm << _begPlatforms; 1970 strm << _begPlatforms;
1934 strm << _begPlatform; 1971 strm << _begPlatform;
1935 strm << SPair( _Name3, tool.PlatformName ); 1972 strm << SPair( _Name3, tool.PlatformName );
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index 2d09280..1dca68d 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -19,133 +19,133 @@
19** Licensees holding valid Qt Enterprise Edition licenses may use this 19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided 20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software. 21** with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35#ifndef __MSVC_OBJECTMODEL_H__ 35#ifndef __MSVC_OBJECTMODEL_H__
36#define __MSVC_OBJECTMODEL_H__ 36#define __MSVC_OBJECTMODEL_H__
37 37
38#include "project.h" 38#include "project.h"
39#include <qstring.h> 39#include <qstring.h>
40#include <qstringlist.h> 40#include <qstringlist.h>
41 41
42/* 42/*
43 This Object model is of course VERY simplyfied, 43 This Object model is of course VERY simplyfied,
44 and does not actually follow the original MSVC 44 and does not actually follow the original MSVC
45 object model. However, it fulfilles the basic 45 object model. However, it fulfilles the basic
46 needs for qmake 46 needs for qmake
47*/ 47*/
48 48
49/* 49/*
50 If a triState value is 'unset' then the 50 If a triState value is 'unset' then the
51 corresponding property is not in the output, 51 corresponding property is not in the output,
52 forcing the tool to utilize default values. 52 forcing the tool to utilize default values.
53 False/True values will be in the output... 53 False/True values will be in the output...
54*/ 54*/
55enum customBuildCheck { 55enum customBuildCheck {
56 none, 56 none,
57 moc, 57 moc,
58 uic, 58 uic,
59 lexyacc 59 lexyacc
60}; 60};
61enum triState { 61enum triState {
62 unset = -1, 62 unset = -1,
63 _False = 0, 63 _False = 0,
64 _True = 1 64 _True = 1
65}; 65};
66enum addressAwarenessType { 66enum addressAwarenessType {
67 addrAwareDefault, 67 addrAwareDefault,
68 addrAwareNoLarge, 68 addrAwareNoLarge,
69 addrAwareLarge 69 addrAwareLarge
70}; 70};
71enum asmListingOption { 71enum asmListingOption {
72 asmListingNone, 72 asmListingNone,
73 asmListingAssemblyOnly, 73 asmListingAssemblyOnly,
74 asmListingAsmMachineSrc, 74 asmListingAsmMachineSrc,
75 asmListingAsmMachine, 75 asmListingAsmMachine,
76 asmListingAsmSrc 76 asmListingAsmSrc
77}; 77};
78enum basicRuntimeCheckOption { 78enum basicRuntimeCheckOption {
79 runtimeBasicCheckNone, 79 runtimeBasicCheckNone,
80 runtimeCheckStackFrame, 80 runtimeCheckStackFrame,
81 runtimeCheckUninitVariables, 81 runtimeCheckUninitVariables,
82 runtimeBasicCheckAll 82 runtimeBasicCheckAll
83}; 83};
84enum browseInfoOption { 84enum browseInfoOption {
85 brInfoNone, 85 brInfoNone,
86 brAllInfo, 86 brAllInfo,
87 brNoLocalSymbols 87 brNoLocalSymbols
88}; 88};
89enum callingConventionOption { 89enum callingConventionOption {
90 callConventionDefault = -1, 90 callConventionDefault = -1,
91 callConventionCDecl, 91 callConventionCDecl,
92 callConventionFastCall, 92 callConventionFastCall,
93 callConventionStdCall 93 callConventionStdCall
94}; 94};
95enum charSet { 95enum charSet {
96 charSetNotSet, 96 charSetNotSet,
97 charSetUnicode, 97 charSetUnicode,
98 charSetMBCS 98 charSetMBCS
99}; 99};
100enum compileAsManagedOptions { 100enum compileAsManagedOptions {
101 managedDefault = -1, 101 managedDefault = -1,
102 managedAssembly = 2 102 managedAssembly = 2
103}; 103};
104enum CompileAsOptions{ 104enum CompileAsOptions{
105 compileAsDefault, 105 compileAsDefault,
106 compileAsC, 106 compileAsC,
107 compileAsCPlusPlus 107 compileAsCPlusPlus
108}; 108};
109enum ConfigurationTypes { 109enum ConfigurationTypes {
110 typeUnknown = 0, 110 typeUnknown = 0,
111 typeApplication = 1, 111 typeApplication = 1,
112 typeDynamicLibrary = 2, 112 typeDynamicLibrary = 2,
113 typeStaticLibrary = 4, 113 typeStaticLibrary = 4,
114 typeGeneric = 10 114 typeGeneric = 10
115}; 115};
116enum debugOption { 116enum debugOption {
117 debugDisabled, 117 debugDisabled,
118 debugOldStyleInfo, 118 debugOldStyleInfo,
119 debugLineInfoOnly, 119 debugLineInfoOnly,
120 debugEnabled, 120 debugEnabled,
121 debugEditAndContinue 121 debugEditAndContinue
122}; 122};
123enum eAppProtectionOption { 123enum eAppProtectionOption {
124 eAppProtectUnchanged, 124 eAppProtectUnchanged,
125 eAppProtectLow, 125 eAppProtectLow,
126 eAppProtectMedium, 126 eAppProtectMedium,
127 eAppProtectHigh 127 eAppProtectHigh
128}; 128};
129enum enumResourceLangID { 129enum enumResourceLangID {
130 rcUseDefault = 0, 130 rcUseDefault = 0,
131 rcAfrikaans = 1078, 131 rcAfrikaans = 1078,
132 rcAlbanian = 1052, 132 rcAlbanian = 1052,
133 rcArabicAlgeria = 5121, 133 rcArabicAlgeria = 5121,
134 rcArabicBahrain = 15361, 134 rcArabicBahrain = 15361,
135 rcArabicEgypt = 3073, 135 rcArabicEgypt = 3073,
136 rcArabicIraq = 2049, 136 rcArabicIraq = 2049,
137 rcArabicJordan = 11265, 137 rcArabicJordan = 11265,
138 rcArabicKuwait = 13313, 138 rcArabicKuwait = 13313,
139 rcArabicLebanon = 12289, 139 rcArabicLebanon = 12289,
140 rcArabicLibya = 4097, 140 rcArabicLibya = 4097,
141 rcArabicMorocco = 6145, 141 rcArabicMorocco = 6145,
142 rcArabicOman = 8193, 142 rcArabicOman = 8193,
143 rcArabicQatar = 16385, 143 rcArabicQatar = 16385,
144 rcArabicSaudi = 1025, 144 rcArabicSaudi = 1025,
145 rcArabicSyria = 10241, 145 rcArabicSyria = 10241,
146 rcArabicTunisia = 7169, 146 rcArabicTunisia = 7169,
147 rcArabicUnitedArabEmirates= 14337, 147 rcArabicUnitedArabEmirates= 14337,
148 rcArabicYemen = 9217, 148 rcArabicYemen = 9217,
149 rcBasque = 1069, 149 rcBasque = 1069,
150 rcBulgarian = 1026, 150 rcBulgarian = 1026,
151 rcByelorussian = 1059, 151 rcByelorussian = 1059,
@@ -210,229 +210,227 @@ enum enumResourceLangID {
210 rcSpanishDominicanRepublic= 7178, 210 rcSpanishDominicanRepublic= 7178,
211 rcSpanishEcuador = 12298, 211 rcSpanishEcuador = 12298,
212 rcSpanishGuatemala = 4106, 212 rcSpanishGuatemala = 4106,
213 rcSpanishMexico = 2058, 213 rcSpanishMexico = 2058,
214 rcSpanishModern = 3082, 214 rcSpanishModern = 3082,
215 rcSpanishPanama = 6154, 215 rcSpanishPanama = 6154,
216 rcSpanishParaguay = 15370, 216 rcSpanishParaguay = 15370,
217 rcSpanishPeru = 10250, 217 rcSpanishPeru = 10250,
218 rcSpanishTraditional= 1034, 218 rcSpanishTraditional= 1034,
219 rcSpanishUruguay = 14346, 219 rcSpanishUruguay = 14346,
220 rcSpanishVenezuela = 8202, 220 rcSpanishVenezuela = 8202,
221 rcSwedish = 1053, 221 rcSwedish = 1053,
222 rcThai = 1054, 222 rcThai = 1054,
223 rcTurkish = 1055, 223 rcTurkish = 1055,
224 rcUkrainian = 1058, 224 rcUkrainian = 1058,
225 rcUrdu = 1056 225 rcUrdu = 1056
226}; 226};
227enum enumSccEvent { 227enum enumSccEvent {
228 eProjectInScc, 228 eProjectInScc,
229 ePreDirtyNotification 229 ePreDirtyNotification
230}; 230};
231enum favorSizeOrSpeedOption { 231enum favorSizeOrSpeedOption {
232 favorNone, 232 favorNone,
233 favorSpeed, 233 favorSpeed,
234 favorSize 234 favorSize
235}; 235};
236enum genProxyLanguage { 236enum genProxyLanguage {
237 genProxyNative, 237 genProxyNative,
238 genProxyManaged 238 genProxyManaged
239}; 239};
240enum inlineExpansionOption { 240enum inlineExpansionOption {
241 expandDisable, 241 expandDisable,
242 expandOnlyInline, 242 expandOnlyInline,
243 expandAnySuitable 243 expandAnySuitable
244}; 244};
245enum linkIncrementalType { 245enum linkIncrementalType {
246 linkIncrementalDefault, 246 linkIncrementalDefault,
247 linkIncrementalNo, 247 linkIncrementalNo,
248 linkIncrementalYes 248 linkIncrementalYes
249}; 249};
250enum linkProgressOption { 250enum linkProgressOption {
251 linkProgressNotSet, 251 linkProgressNotSet,
252 linkProgressAll, 252 linkProgressAll,
253 linkProgressLibs 253 linkProgressLibs
254}; 254};
255enum machineTypeOption { 255enum machineTypeOption {
256 machineNotSet, 256 machineNotSet,
257 machineX86 257 machineX86
258}; 258};
259enum midlCharOption { 259enum midlCharOption {
260 midlCharUnsigned, 260 midlCharUnsigned,
261 midlCharSigned, 261 midlCharSigned,
262 midlCharAscii7 262 midlCharAscii7
263}; 263};
264enum midlErrorCheckOption { 264enum midlErrorCheckOption {
265 midlEnableCustom, 265 midlEnableCustom,
266 midlDisableAll, 266 midlDisableAll,
267 midlEnableAll 267 midlEnableAll
268}; 268};
269enum midlStructMemberAlignOption { 269enum midlStructMemberAlignOption {
270 midlAlignNotSet, 270 midlAlignNotSet,
271 midlAlignSingleByte, 271 midlAlignSingleByte,
272 midlAlignTwoBytes, 272 midlAlignTwoBytes,
273 midlAlignFourBytes, 273 midlAlignFourBytes,
274 midlAlignEightBytes, 274 midlAlignEightBytes,
275 midlAlignSixteenBytes 275 midlAlignSixteenBytes
276}; 276};
277enum midlTargetEnvironment { 277enum midlTargetEnvironment {
278 midlTargetNotSet, 278 midlTargetNotSet,
279 midlTargetWin32, 279 midlTargetWin32,
280 midlTargetWin64 280 midlTargetWin64
281}; 281};
282enum midlWarningLevelOption { 282enum midlWarningLevelOption {
283 midlWarningLevel_0, 283 midlWarningLevel_0,
284 midlWarningLevel_1, 284 midlWarningLevel_1,
285 midlWarningLevel_2, 285 midlWarningLevel_2,
286 midlWarningLevel_3, 286 midlWarningLevel_3,
287 midlWarningLevel_4 287 midlWarningLevel_4
288}; 288};
289enum optFoldingType { 289enum optFoldingType {
290 optFoldingDefault, 290 optFoldingDefault,
291 optNoFolding, 291 optNoFolding,
292 optFolding 292 optFolding
293}; 293};
294enum optimizeOption { 294enum optimizeOption {
295 optimizeDisabled, 295 optimizeDisabled,
296 optimizeMinSpace, 296 optimizeMinSpace,
297 optimizeMaxSpeed, 297 optimizeMaxSpeed,
298 optimizeFull, 298 optimizeFull,
299 optimizeCustom 299 optimizeCustom
300}; 300};
301enum optRefType { 301enum optRefType {
302 optReferencesDefault, 302 optReferencesDefault,
303 optNoReferences, 303 optNoReferences,
304 optReferences 304 optReferences
305}; 305};
306enum optWin98Type { 306enum optWin98Type {
307 optWin98Default, 307 optWin98Default,
308 optWin98No, 308 optWin98No,
309 optWin98Yes 309 optWin98Yes
310}; 310};
311enum pchOption { 311enum pchOption {
312 pchNone, 312 pchNone,
313 pchCreateUsingSpecific, 313 pchCreateUsingSpecific,
314 pchGenerateAuto, 314 pchGenerateAuto,
315 pchUseUsingSpecific 315 pchUseUsingSpecific
316}; 316};
317enum preprocessOption { 317enum preprocessOption {
318 preprocessNo, 318 preprocessNo,
319 preprocessYes, 319 preprocessYes,
320 preprocessNoLineNumbers 320 preprocessNoLineNumbers
321}; 321};
322enum ProcessorOptimizeOption { 322enum ProcessorOptimizeOption {
323 procOptimizeBlended, 323 procOptimizeBlended,
324 procOptimizePentium, 324 procOptimizePentium,
325 procOptimizePentiumProAndAbove 325 procOptimizePentiumProAndAbove
326}; 326};
327enum RemoteDebuggerType { 327enum RemoteDebuggerType {
328 DbgLocal, 328 DbgLocal,
329 DbgRemote, 329 DbgRemote,
330 DbgRemoteTCPIP 330 DbgRemoteTCPIP
331}; 331};
332enum runtimeLibraryOption { 332enum runtimeLibraryOption {
333 rtMultiThreaded, 333 rtMultiThreaded,
334 rtMultiThreadedDebug, 334 rtMultiThreadedDebug,
335 rtMultiThreadedDLL, 335 rtMultiThreadedDLL,
336 rtMultiThreadedDebugDLL, 336 rtMultiThreadedDebugDLL,
337 rtSingleThreaded, 337 rtSingleThreaded,
338 rtSingleThreadedDebug 338 rtSingleThreadedDebug
339}; 339};
340enum structMemberAlignOption { 340enum structMemberAlignOption {
341 alignNotSet, 341 alignNotSet,
342 alignSingleByte, 342 alignSingleByte,
343 alignTwoBytes, 343 alignTwoBytes,
344 alignFourBytes, 344 alignFourBytes,
345 alignEightBytes, 345 alignEightBytes,
346 alignSixteenBytes 346 alignSixteenBytes
347}; 347};
348enum subSystemOption { 348enum subSystemOption {
349 subSystemNotSet, 349 subSystemNotSet,
350 subSystemConsole, 350 subSystemConsole,
351 subSystemWindows 351 subSystemWindows
352}; 352};
353enum termSvrAwarenessType { 353enum termSvrAwarenessType {
354 termSvrAwareDefault, 354 termSvrAwareDefault,
355 termSvrAwareNo, 355 termSvrAwareNo,
356 termSvrAwareYes 356 termSvrAwareYes
357}; 357};
358enum toolSetType { 358enum toolSetType {
359 toolSetUtility, 359 toolSetUtility,
360 toolSetMakefile, 360 toolSetMakefile,
361 toolSetLinker, 361 toolSetLinker,
362 toolSetLibrarian, 362 toolSetLibrarian,
363 toolSetAll 363 toolSetAll
364}; 364};
365enum TypeOfDebugger { 365enum TypeOfDebugger {
366 DbgNativeOnly, 366 DbgNativeOnly,
367 DbgManagedOnly, 367 DbgManagedOnly,
368 DbgMixed, 368 DbgMixed,
369 DbgAuto 369 DbgAuto
370}; 370};
371enum useOfATL { 371enum useOfATL {
372 useATLNotSet, 372 useATLNotSet,
373 useATLStatic, 373 useATLStatic,
374 useATLDynamic 374 useATLDynamic
375}; 375};
376enum useOfMfc { 376enum useOfMfc {
377 useMfcStdWin, 377 useMfcStdWin,
378 useMfcStatic, 378 useMfcStatic,
379 useMfcDynamic 379 useMfcDynamic
380}; 380};
381enum warningLevelOption { 381enum warningLevelOption {
382 warningLevel_0, 382 warningLevel_0,
383 warningLevel_1, 383 warningLevel_1,
384 warningLevel_2, 384 warningLevel_2,
385 warningLevel_3, 385 warningLevel_3,
386 warningLevel_4 386 warningLevel_4
387}; 387};
388 388
389class VCToolBase { 389class VCToolBase {
390protected: 390protected:
391 // Functions 391 // Functions
392 VCToolBase(){}; 392 VCToolBase(){};
393 ~VCToolBase(){}; 393 virtual ~VCToolBase(){}
394 virtual bool parseOption( const char* option ) = 0; 394 virtual bool parseOption( const char* option ) = 0;
395public: 395public:
396 bool parseOptions( QStringList& options ) { 396 void parseOptions( QStringList& options ) {
397 bool result = TRUE; 397 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()); it++ )
398 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()) && result; it++ ) 398 parseOption( (*it).latin1() );
399 result = parseOption( (*it).latin1() );
400 return result;
401 } 399 }
402}; 400};
403 401
404class VCConfiguration; 402class VCConfiguration;
405class VCProject; 403class VCProject;
406 404
407class VCCLCompilerTool : public VCToolBase 405class VCCLCompilerTool : public VCToolBase
408{ 406{
409public: 407public:
410 // Functions 408 // Functions
411 VCCLCompilerTool(); 409 VCCLCompilerTool();
412 ~VCCLCompilerTool(){}; 410 virtual ~VCCLCompilerTool(){}
413 virtual bool parseOption( const char* option ); 411 bool parseOption( const char* option );
414 412
415 // Variables 413 // Variables
416 QStringList AdditionalIncludeDirectories; 414 QStringList AdditionalIncludeDirectories;
417 QStringList AdditionalOptions; 415 QStringList AdditionalOptions;
418 QStringList AdditionalUsingDirectories; 416 QStringList AdditionalUsingDirectories;
419 QString AssemblerListingLocation; 417 QString AssemblerListingLocation;
420 asmListingOption AssemblerOutput; 418 asmListingOption AssemblerOutput;
421 basicRuntimeCheckOption BasicRuntimeChecks; 419 basicRuntimeCheckOption BasicRuntimeChecks;
422 browseInfoOption BrowseInformation; 420 browseInfoOption BrowseInformation;
423 QString BrowseInformationFile; 421 QString BrowseInformationFile;
424 triState BufferSecurityCheck; 422 triState BufferSecurityCheck;
425 callingConventionOption CallingConvention; 423 callingConventionOption CallingConvention;
426 CompileAsOptions CompileAs; 424 CompileAsOptions CompileAs;
427 compileAsManagedOptions CompileAsManaged; 425 compileAsManagedOptions CompileAsManaged;
428 triState CompileOnly; 426 triState CompileOnly;
429 debugOption DebugInformationFormat; 427 debugOption DebugInformationFormat;
430 triState DefaultCharIsUnsigned; 428 triState DefaultCharIsUnsigned;
431 triState Detect64BitPortabilityProblems; 429 triState Detect64BitPortabilityProblems;
432 triState DisableLanguageExtensions; 430 triState DisableLanguageExtensions;
433 QStringList DisableSpecificWarnings; 431 QStringList DisableSpecificWarnings;
434 triState EnableFiberSafeOptimizations; 432 triState EnableFiberSafeOptimizations;
435 triState EnableFunctionLevelLinking; 433 triState EnableFunctionLevelLinking;
436 triState EnableIntrinsicFunctions; 434 triState EnableIntrinsicFunctions;
437 triState ExceptionHandling; 435 triState ExceptionHandling;
438 triState ExpandAttributedSource; 436 triState ExpandAttributedSource;
@@ -459,50 +457,50 @@ public:
459 QString ProgramDataBaseFileName; 457 QString ProgramDataBaseFileName;
460 runtimeLibraryOption RuntimeLibrary; 458 runtimeLibraryOption RuntimeLibrary;
461 triState RuntimeTypeInfo; 459 triState RuntimeTypeInfo;
462 triState ShowIncludes; 460 triState ShowIncludes;
463 triState SmallerTypeCheck; 461 triState SmallerTypeCheck;
464 triState StringPooling; 462 triState StringPooling;
465 structMemberAlignOption StructMemberAlignment; 463 structMemberAlignOption StructMemberAlignment;
466 triState SuppressStartupBanner; 464 triState SuppressStartupBanner;
467 triState TreatWChar_tAsBuiltInType; 465 triState TreatWChar_tAsBuiltInType;
468 triState TurnOffAssemblyGeneration; 466 triState TurnOffAssemblyGeneration;
469 triState UndefineAllPreprocessorDefinitions; 467 triState UndefineAllPreprocessorDefinitions;
470 QStringList UndefinePreprocessorDefinitions; 468 QStringList UndefinePreprocessorDefinitions;
471 pchOption UsePrecompiledHeader; 469 pchOption UsePrecompiledHeader;
472 triState WarnAsError; 470 triState WarnAsError;
473 warningLevelOption WarningLevel; 471 warningLevelOption WarningLevel;
474 triState WholeProgramOptimization; 472 triState WholeProgramOptimization;
475 VCConfiguration* config; 473 VCConfiguration* config;
476}; 474};
477 475
478class VCLinkerTool : public VCToolBase 476class VCLinkerTool : public VCToolBase
479{ 477{
480public: 478public:
481 // Functions 479 // Functions
482 VCLinkerTool(); 480 VCLinkerTool();
483 ~VCLinkerTool(){}; 481 virtual ~VCLinkerTool(){}
484 virtual bool parseOption( const char* option ); 482 bool parseOption( const char* option );
485 483
486 // Variables 484 // Variables
487 QStringList AdditionalDependencies; 485 QStringList AdditionalDependencies;
488 QStringList AdditionalLibraryDirectories; 486 QStringList AdditionalLibraryDirectories;
489 QStringList AdditionalOptions; 487 QStringList AdditionalOptions;
490 QStringList AddModuleNamesToAssembly; 488 QStringList AddModuleNamesToAssembly;
491 QString BaseAddress; 489 QString BaseAddress;
492 QStringList DelayLoadDLLs; 490 QStringList DelayLoadDLLs;
493 optFoldingType EnableCOMDATFolding; 491 optFoldingType EnableCOMDATFolding;
494 QString EntryPointSymbol; 492 QString EntryPointSymbol;
495 QStringList ForceSymbolReferences; 493 QStringList ForceSymbolReferences;
496 QString FunctionOrder; 494 QString FunctionOrder;
497 triState GenerateDebugInformation; 495 triState GenerateDebugInformation;
498 triState GenerateMapFile; 496 triState GenerateMapFile;
499 long HeapCommitSize; 497 long HeapCommitSize;
500 long HeapReserveSize; 498 long HeapReserveSize;
501 triState IgnoreAllDefaultLibraries; 499 triState IgnoreAllDefaultLibraries;
502 QStringList IgnoreDefaultLibraryNames; 500 QStringList IgnoreDefaultLibraryNames;
503 triState IgnoreEmbeddedIDL; 501 triState IgnoreEmbeddedIDL;
504 triState IgnoreImportLibrary; 502 triState IgnoreImportLibrary;
505 QString ImportLibrary; 503 QString ImportLibrary;
506 addressAwarenessType LargeAddressAware; 504 addressAwarenessType LargeAddressAware;
507 triState LinkDLL; 505 triState LinkDLL;
508 linkIncrementalType LinkIncremental; 506 linkIncrementalType LinkIncremental;
@@ -524,243 +522,243 @@ public:
524 triState SetChecksum; 522 triState SetChecksum;
525 linkProgressOption ShowProgress; 523 linkProgressOption ShowProgress;
526 long StackCommitSize; 524 long StackCommitSize;
527 long StackReserveSize; 525 long StackReserveSize;
528 QString StripPrivateSymbols; // Should be list? 526 QString StripPrivateSymbols; // Should be list?
529 subSystemOption SubSystem; 527 subSystemOption SubSystem;
530 triState SupportUnloadOfDelayLoadedDLL; 528 triState SupportUnloadOfDelayLoadedDLL;
531 triState SuppressStartupBanner; 529 triState SuppressStartupBanner;
532 triState SwapRunFromCD; 530 triState SwapRunFromCD;
533 triState SwapRunFromNet; 531 triState SwapRunFromNet;
534 machineTypeOption TargetMachine; 532 machineTypeOption TargetMachine;
535 termSvrAwarenessType TerminalServerAware; 533 termSvrAwarenessType TerminalServerAware;
536 triState TurnOffAssemblyGeneration; 534 triState TurnOffAssemblyGeneration;
537 QString TypeLibraryFile; 535 QString TypeLibraryFile;
538 long TypeLibraryResourceID; 536 long TypeLibraryResourceID;
539 QString Version; 537 QString Version;
540 VCConfiguration* config; 538 VCConfiguration* config;
541}; 539};
542 540
543class VCMIDLTool : public VCToolBase 541class VCMIDLTool : public VCToolBase
544{ 542{
545public: 543public:
546 // Functions 544 // Functions
547 VCMIDLTool(); 545 VCMIDLTool();
548 ~VCMIDLTool(){}; 546 virtual ~VCMIDLTool(){}
549 virtual bool parseOption( const char* option ); 547 bool parseOption( const char* option );
550 548
551 // Variables 549 // Variables
552 QStringList AdditionalIncludeDirectories; 550 QStringList AdditionalIncludeDirectories;
553 QStringList AdditionalOptions; 551 QStringList AdditionalOptions;
554 QStringList CPreprocessOptions; 552 QStringList CPreprocessOptions;
555 midlCharOption DefaultCharType; 553 midlCharOption DefaultCharType;
556 QString DLLDataFileName; // Should be list? 554 QString DLLDataFileName; // Should be list?
557 midlErrorCheckOption EnableErrorChecks; 555 midlErrorCheckOption EnableErrorChecks;
558 triState ErrorCheckAllocations; 556 triState ErrorCheckAllocations;
559 triState ErrorCheckBounds; 557 triState ErrorCheckBounds;
560 triState ErrorCheckEnumRange; 558 triState ErrorCheckEnumRange;
561 triState ErrorCheckRefPointers; 559 triState ErrorCheckRefPointers;
562 triState ErrorCheckStubData; 560 triState ErrorCheckStubData;
563 QStringList FullIncludePath; 561 QStringList FullIncludePath;
564 triState GenerateStublessProxies; 562 triState GenerateStublessProxies;
565 triState GenerateTypeLibrary; 563 triState GenerateTypeLibrary;
566 QString HeaderFileName; 564 QString HeaderFileName;
567 triState IgnoreStandardIncludePath; 565 triState IgnoreStandardIncludePath;
568 QString InterfaceIdentifierFileName; 566 QString InterfaceIdentifierFileName;
569 triState MkTypLibCompatible; 567 triState MkTypLibCompatible;
570 QString OutputDirectory; 568 QString OutputDirectory;
571 QStringList PreprocessorDefinitions; 569 QStringList PreprocessorDefinitions;
572 QString ProxyFileName; 570 QString ProxyFileName;
573 QString RedirectOutputAndErrors; 571 QString RedirectOutputAndErrors;
574 midlStructMemberAlignOption StructMemberAlignment; 572 midlStructMemberAlignOption StructMemberAlignment;
575 triState SuppressStartupBanner; 573 triState SuppressStartupBanner;
576 midlTargetEnvironment TargetEnvironment; 574 midlTargetEnvironment TargetEnvironment;
577 QString TypeLibraryName; 575 QString TypeLibraryName;
578 QStringList UndefinePreprocessorDefinitions; 576 QStringList UndefinePreprocessorDefinitions;
579 triState ValidateParameters; 577 triState ValidateParameters;
580 triState WarnAsError; 578 triState WarnAsError;
581 midlWarningLevelOption WarningLevel; 579 midlWarningLevelOption WarningLevel;
582 VCConfiguration* config; 580 VCConfiguration* config;
583}; 581};
584 582
585class VCLibrarianTool : public VCToolBase 583class VCLibrarianTool : public VCToolBase
586{ 584{
587public: 585public:
588 // Functions 586 // Functions
589 VCLibrarianTool(); 587 VCLibrarianTool();
590 ~VCLibrarianTool(){}; 588 virtual ~VCLibrarianTool(){}
591 virtual bool parseOption( const char* option ){ return FALSE; }; 589 bool parseOption( const char* ){ return FALSE; };
592 590
593 // Variables 591 // Variables
594 QStringList AdditionalDependencies; 592 QStringList AdditionalDependencies;
595 QStringList AdditionalLibraryDirectories; 593 QStringList AdditionalLibraryDirectories;
596 QStringList AdditionalOptions; 594 QStringList AdditionalOptions;
597 QStringList ExportNamedFunctions; 595 QStringList ExportNamedFunctions;
598 QStringList ForceSymbolReferences; 596 QStringList ForceSymbolReferences;
599 triState IgnoreAllDefaultLibraries; 597 triState IgnoreAllDefaultLibraries;
600 QStringList IgnoreDefaultLibraryNames; 598 QStringList IgnoreDefaultLibraryNames;
601 QString ModuleDefinitionFile; 599 QString ModuleDefinitionFile;
602 QString OutputFile; 600 QString OutputFile;
603 triState SuppressStartupBanner; 601 triState SuppressStartupBanner;
604}; 602};
605 603
606class VCCustomBuildTool : public VCToolBase 604class VCCustomBuildTool : public VCToolBase
607{ 605{
608public: 606public:
609 // Functions 607 // Functions
610 VCCustomBuildTool(); 608 VCCustomBuildTool();
611 ~VCCustomBuildTool(){}; 609 virtual ~VCCustomBuildTool(){}
612 virtual bool parseOption( const char* option ){ return FALSE; }; 610 bool parseOption( const char* ){ return FALSE; };
613 611
614 // Variables 612 // Variables
615 QStringList AdditionalDependencies; 613 QStringList AdditionalDependencies;
616 QString CommandLine; 614 QString CommandLine;
617 QString Description; 615 QString Description;
618 QString Outputs; 616 QString Outputs;
619 QString ToolName; 617 QString ToolName;
620 QString ToolPath; 618 QString ToolPath;
621}; 619};
622 620
623class VCResourceCompilerTool : public VCToolBase 621class VCResourceCompilerTool : public VCToolBase
624{ 622{
625public: 623public:
626 // Functions 624 // Functions
627 VCResourceCompilerTool(); 625 VCResourceCompilerTool();
628 ~VCResourceCompilerTool(){}; 626 virtual ~VCResourceCompilerTool(){}
629 virtual bool parseOption( const char* option ){ return FALSE; }; 627 bool parseOption( const char* ){ return FALSE; };
630 628
631 // Variables 629 // Variables
632 QStringList AdditionalIncludeDirectories; 630 QStringList AdditionalIncludeDirectories;
633 QStringList AdditionalOptions; 631 QStringList AdditionalOptions;
634 enumResourceLangID Culture; 632 enumResourceLangID Culture;
635 QStringList FullIncludePath; 633 QStringList FullIncludePath;
636 triState IgnoreStandardIncludePath; 634 triState IgnoreStandardIncludePath;
637 QStringList PreprocessorDefinitions; 635 QStringList PreprocessorDefinitions;
638 QString ResourceOutputFileName; 636 QString ResourceOutputFileName;
639 linkProgressOption ShowProgress; 637 linkProgressOption ShowProgress;
640 QString ToolPath; 638 QString ToolPath;
641}; 639};
642 640
643class VCEventTool : public VCToolBase 641class VCEventTool : public VCToolBase
644{ 642{
645protected: 643protected:
646 // Functions 644 // Functions
647 VCEventTool() : ExcludedFromBuild( unset ){}; 645 VCEventTool() : ExcludedFromBuild( unset ){};
648 ~VCEventTool(){}; 646 virtual ~VCEventTool(){}
649 virtual bool parseOption( const char* option ){ return FALSE; }; 647 bool parseOption( const char* ){ return FALSE; };
650 648
651public: 649public:
652 // Variables 650 // Variables
653 QString CommandLine; 651 QString CommandLine;
654 QString Description; 652 QString Description;
655 triState ExcludedFromBuild; 653 triState ExcludedFromBuild;
656 QString ToolName; 654 QString ToolName;
657 QString ToolPath; 655 QString ToolPath;
658}; 656};
659 657
660class VCPostBuildEventTool : public VCEventTool 658class VCPostBuildEventTool : public VCEventTool
661{ 659{
662public: 660public:
663 VCPostBuildEventTool(); 661 VCPostBuildEventTool();
664 ~VCPostBuildEventTool(){}; 662 ~VCPostBuildEventTool(){}
665}; 663};
666 664
667class VCPreBuildEventTool : public VCEventTool 665class VCPreBuildEventTool : public VCEventTool
668{ 666{
669public: 667public:
670 VCPreBuildEventTool(); 668 VCPreBuildEventTool();
671 ~VCPreBuildEventTool(){}; 669 ~VCPreBuildEventTool(){}
672}; 670};
673 671
674class VCPreLinkEventTool : public VCEventTool 672class VCPreLinkEventTool : public VCEventTool
675{ 673{
676public: 674public:
677 VCPreLinkEventTool(); 675 VCPreLinkEventTool();
678 ~VCPreLinkEventTool(){}; 676 ~VCPreLinkEventTool(){}
679}; 677};
680 678
681class VCConfiguration 679class VCConfiguration
682{ 680{
683public: 681public:
684 // Functions 682 // Functions
685 VCConfiguration(); 683 VCConfiguration();
686 ~VCConfiguration(){}; 684 ~VCConfiguration(){}
687 685
688 // Variables 686 // Variables
689 triState ATLMinimizesCRunTimeLibraryUsage; 687 triState ATLMinimizesCRunTimeLibraryUsage;
690 triState BuildBrowserInformation; 688 triState BuildBrowserInformation;
691 charSet CharacterSet; 689 charSet CharacterSet;
692 ConfigurationTypesConfigurationType; 690 ConfigurationTypesConfigurationType;
693 QString DeleteExtensionsOnClean; 691 QString DeleteExtensionsOnClean;
694 QString ImportLibrary; 692 QString ImportLibrary;
695 QString IntermediateDirectory; 693 QString IntermediateDirectory;
696 QString Name; 694 QString Name;
697 QString OutputDirectory; 695 QString OutputDirectory;
698 QString PrimaryOutput; 696 QString PrimaryOutput;
699 QString ProgramDatabase; 697 QString ProgramDatabase;
700 triState RegisterOutput; 698 triState RegisterOutput;
701 useOfATL UseOfATL; 699 useOfATL UseOfATL;
702 useOfMfc UseOfMfc; 700 useOfMfc UseOfMfc;
703 triState WholeProgramOptimization; 701 triState WholeProgramOptimization;
704 702
705 // XML sub-parts 703 // XML sub-parts
706 VCCLCompilerTool compiler; 704 VCCLCompilerTool compiler;
707 VCLinkerTool linker; 705 VCLinkerTool linker;
708 VCLibrarianTool librarian; 706 VCLibrarianTool librarian;
709 VCCustomBuildTool custom; 707 VCCustomBuildTool custom;
710 VCMIDLTool idl; 708 VCMIDLTool idl;
711 VCPostBuildEventTool postBuild; 709 VCPostBuildEventTool postBuild;
712 VCPreBuildEventTool preBuild; 710 VCPreBuildEventTool preBuild;
713 VCPreLinkEventTool preLink; 711 VCPreLinkEventTool preLink;
714 VCResourceCompilerTool resource; 712 VCResourceCompilerTool resource;
715}; 713};
716 714
717class VcprojGenerator; 715class VcprojGenerator;
718class VCFilter 716class VCFilter
719{ 717{
720public: 718public:
721 // Functions 719 // Functions
722 VCFilter(); 720 VCFilter();
723 ~VCFilter(){}; 721 ~VCFilter(){}
724 void generateMOC( QTextStream &strm, QString str ) const; 722 void generateMOC( QTextStream &strm, QString str ) const;
725 void generateUIC( QTextStream &strm, const QString& str ) const; 723 void generateUIC( QTextStream &strm, const QString& str ) const;
726 724
727 // Variables 725 // Variables
728 QString Name; 726 QString Name;
729 QString Filter; 727 QString Filter;
730 triState ParseFiles; 728 triState ParseFiles;
731 QStringList Files; 729 QStringList Files;
732 VcprojGenerator*Project; 730 VcprojGenerator*Project;
733 VCConfiguration*Config; 731 VCConfiguration*Config;
734 customBuildCheckCustomBuild; 732 customBuildCheckCustomBuild;
735}; 733};
736 734
737class VCProject 735class VCProject
738{ 736{
739public: 737public:
740 // Functions 738 // Functions
741 VCProject(); 739 VCProject();
742 ~VCProject(){}; 740 ~VCProject(){}
743 741
744 // Variables 742 // Variables
745 QString Name; 743 QString Name;
746 QString Version; 744 QString Version;
747 QString ProjectGUID; 745 QString ProjectGUID;
748 QString SccProjectName; 746 QString SccProjectName;
749 QString SccLocalPath; 747 QString SccLocalPath;
750 QString PlatformName; 748 QString PlatformName;
751 749
752 // XML sub-parts 750 // XML sub-parts
753 VCConfigurationConfiguration; 751 VCConfigurationConfiguration;
754 VCFilter SourceFiles; 752 VCFilter SourceFiles;
755 VCFilter HeaderFiles; 753 VCFilter HeaderFiles;
756 VCFilter MOCFiles; 754 VCFilter MOCFiles;
757 VCFilter UICFiles; 755 VCFilter UICFiles;
758 VCFilter FormFiles; 756 VCFilter FormFiles;
759 VCFilter TranslationFiles; 757 VCFilter TranslationFiles;
760 VCFilter LexYaccFiles; 758 VCFilter LexYaccFiles;
761 VCFilter ResourceFiles; 759 VCFilter ResourceFiles;
762}; 760};
763 761
764QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & ); 762QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & );
765QTextStream &operator<<( QTextStream &, const VCLinkerTool & ); 763QTextStream &operator<<( QTextStream &, const VCLinkerTool & );
766QTextStream &operator<<( QTextStream &, const VCMIDLTool & ); 764QTextStream &operator<<( QTextStream &, const VCMIDLTool & );
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index a2bb6e9..d2cbc31 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1,208 +1,324 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of VcprojGenerator class. 4** Definition of VcprojGenerator class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "msvc_vcproj.h" 38#include "msvc_vcproj.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <stdlib.h>
42#include <qregexp.h> 41#include <qregexp.h>
42#include <qdict.h>
43#include <quuid.h>
44#include <stdlib.h>
43 45
44#if defined(Q_OS_WIN32) 46#if defined(Q_OS_WIN32)
45#include <objbase.h> 47#include <objbase.h>
48#ifndef GUID_DEFINED
49#define GUID_DEFINED
50typedef struct _GUID
51{
52 ulong Data1;
53 ushort Data2;
54 ushort Data3;
55 uchar Data4[8];
56} GUID;
57#endif
46#endif 58#endif
47 59
60// Flatfile Tags ----------------------------------------------------
61 const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version 7.00";
62 // The following UUID _may_ change for later servicepacks...
63 // If so we need to search through the registry at
64 // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
65 // to find the subkey that contains a "PossibleProjectExtension"
66 // containing "vcproj"...
67 // Use the hardcoded value for now so projects generated on other
68 // platforms are actually usable.
69const char* _snlMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
70 const char* _snlProjectBeg= "\nProject(\"";
71 const char* _snlProjectMid= "\") = ";
72 const char* _snlProjectEnd= "\nEndProject";
73 const char* _snlGlobalBeg= "\nGlobal";
74 const char* _snlGlobalEnd= "\nEndGlobal";
75 const char* _snlSolutionConf= "\n\tGlobalSection(SolutionConfiguration) = preSolution"
76 "\n\t\tConfigName.0 = Release"
77 "\n\tEndGlobalSection";
78 const char* _snlProjDepBeg= "\n\tGlobalSection(ProjectDependencies) = postSolution";
79 const char* _snlProjDepEnd= "\n\tEndGlobalSection";
80 const char* _snlProjConfBeg= "\n\tGlobalSection(ProjectConfiguration) = postSolution";
81 const char* _snlProjConfTag1= ".Release.ActiveCfg = Release|Win32";
82 const char* _snlProjConfTag2= ".Release.Build.0 = Release|Win32";
83 const char* _snlProjConfEnd= "\n\tEndGlobalSection";
84 const char* _snlExtSections= "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"
85 "\n\tEndGlobalSection"
86 "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"
87 "\n\tEndGlobalSection";
88// ------------------------------------------------------------------
89
48VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 90VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
49{ 91{
50} 92}
51 93
52/* \internal 94/* \internal
53 Generates a project file for the given profile. 95 Generates a project file for the given profile.
54 Options are either a Visual Studio projectfiles, or 96 Options are either a Visual Studio projectfiles, or
55 recursive projectfiles.. Maybe we can make .sln files 97 solutionfiles by parsing recursive projectdirectories.
56 someday?
57*/ 98*/
58bool VcprojGenerator::writeMakefile(QTextStream &t) 99bool VcprojGenerator::writeMakefile(QTextStream &t)
59{ 100{
60 // Check if all requirements are fullfilled 101 // Check if all requirements are fullfilled
61 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 102 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
62 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", 103 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
63 var("QMAKE_FAILED_REQUIREMENTS").latin1()); 104 var("QMAKE_FAILED_REQUIREMENTS").latin1());
64 return TRUE; 105 return TRUE;
65 } 106 }
66 107
67 // Generate full project file 108 // Generate project file
68 if(project->first("TEMPLATE") == "vcapp" || 109 if(project->first("TEMPLATE") == "vcapp" ||
69 project->first("TEMPLATE") == "vclib") { 110 project->first("TEMPLATE") == "vclib") {
70 debug_msg(1, "Generator: MSVC.NET: Writing project file" ); 111 debug_msg(1, "Generator: MSVC.NET: Writing project file" );
71 t << vcProject; 112 t << vcProject;
72 return TRUE; 113 return TRUE;
73 } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project 114 }
115 // Generate solution file
116 else if(project->first("TEMPLATE") == "vcsubdirs") {
74 debug_msg(1, "Generator: MSVC.NET: Writing solution file" ); 117 debug_msg(1, "Generator: MSVC.NET: Writing solution file" );
75 writeSubDirs(t); 118 writeSubDirs(t);
76 return TRUE; 119 return TRUE;
77 } 120 }
78 return FALSE; 121 return FALSE;
79 122
80} 123}
81 124
82struct VcsolutionDepend { 125struct VcsolutionDepend {
126 QString uuid;
83 QString vcprojFile, orig_target, target; 127 QString vcprojFile, orig_target, target;
128 ::target targetType;
84 QStringList dependencies; 129 QStringList dependencies;
85}; 130};
86 131
132QUuid VcprojGenerator::increaseUUID( const QUuid &id )
133{
134 QUuid result( id );
135 Q_LONG dataFirst = (result.data4[0] << 24) +
136 (result.data4[1] << 16) +
137 (result.data4[2] << 8) +
138 result.data4[3];
139 Q_LONG dataLast = (result.data4[4] << 24) +
140 (result.data4[5] << 16) +
141 (result.data4[6] << 8) +
142 result.data4[7];
143
144 if ( !(dataLast++) )
145 dataFirst++;
146
147 result.data4[0] = uchar((dataFirst >> 24) & 0xff);
148 result.data4[1] = uchar((dataFirst >> 16) & 0xff);
149 result.data4[2] = uchar((dataFirst >> 8) & 0xff);
150 result.data4[3] = uchar( dataFirst & 0xff);
151 result.data4[4] = uchar((dataLast >> 24) & 0xff);
152 result.data4[5] = uchar((dataLast >> 16) & 0xff);
153 result.data4[6] = uchar((dataLast >> 8) & 0xff);
154 result.data4[7] = uchar( dataLast & 0xff);
155 return result;
156}
157
87void VcprojGenerator::writeSubDirs(QTextStream &t) 158void VcprojGenerator::writeSubDirs(QTextStream &t)
88{ 159{
89 if(project->first("TEMPLATE") == "subdirs") { 160 if(project->first("TEMPLATE") == "subdirs") {
90 writeHeader(t); 161 writeHeader(t);
91 Win32MakefileGenerator::writeSubDirs(t); 162 Win32MakefileGenerator::writeSubDirs(t);
92 return; 163 return;
93 } 164 }
94 165
95 QPtrList<VcsolutionDepend> solution_depends; 166 t << _snlHeader;
96 solution_depends.setAutoDelete(TRUE); 167 QUuid solutionGUID;
168#if defined(Q_WS_WIN32)
169 GUID guid;
170 HRESULT h = CoCreateGuid( &guid );
171 if ( h == S_OK )
172 solutionGUID = QUuid( guid );
173#else
174 // Qt doesn't support GUID on other platforms yet,
175 // so we use the all-zero uuid, and increase that.
176#endif
177
178
179 QDict<VcsolutionDepend> solution_depends;
180 QPtrList<VcsolutionDepend> solution_cleanup;
181 solution_cleanup.setAutoDelete(TRUE);
97 QStringList subdirs = project->variables()["SUBDIRS"]; 182 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath(); 183 QString oldpwd = QDir::currentDirPath();
99 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { 184 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
100 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); 185 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
101 if(fi.exists()) { 186 if(fi.exists()) {
102 if(fi.isDir()) { 187 if(fi.isDir()) {
103 QString profile = (*it); 188 QString profile = (*it);
104 if(!profile.endsWith(Option::dir_sep)) 189 if(!profile.endsWith(Option::dir_sep))
105 profile += Option::dir_sep; 190 profile += Option::dir_sep;
106 profile += fi.baseName() + ".pro"; 191 profile += fi.baseName() + ".pro";
107 subdirs.append(profile); 192 subdirs.append(profile);
108 } else { 193 } else {
109 QMakeProject tmp_proj; 194 QMakeProject tmp_proj;
110 QString dir = fi.dirPath(), fn = fi.fileName(); 195 QString dir = fi.dirPath(), fn = fi.fileName();
111 if(!dir.isEmpty()) { 196 if(!dir.isEmpty()) {
112 if(!QDir::setCurrent(dir)) 197 if(!QDir::setCurrent(dir))
113 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1()); 198 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
114 } 199 }
115 if(tmp_proj.read(fn, oldpwd)) { 200 if(tmp_proj.read(fn, oldpwd)) {
116 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { 201 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
117 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); 202 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]);
118 subdirs += tmp_subdirs; 203 subdirs += tmp_subdirs;
119 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || 204 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") {
120 tmp_proj.first("TEMPLATE") == "vclib") { 205 // Initialize a 'fake' project to get the correct variables
121 QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION"); 206 // and to be able to extract all the dependencies
122 if(QFile::exists(vcproj) || 1) { 207 VcprojGenerator tmp_vcproj(&tmp_proj);
123 VcprojGenerator tmp_dsp(&tmp_proj); 208 tmp_vcproj.setNoIO(TRUE);
124 tmp_dsp.setNoIO(TRUE); 209 tmp_vcproj.init();
125 tmp_dsp.init(); 210 if(Option::debug_level) {
126 if(Option::debug_level) { 211 QMap<QString, QStringList> &vars = tmp_proj.variables();
127 QMap<QString, QStringList> &vars = tmp_proj.variables(); 212 for(QMap<QString, QStringList>::Iterator it = vars.begin();
128 for(QMap<QString, QStringList>::Iterator it = vars.begin(); 213 it != vars.end(); ++it) {
129 it != vars.end(); ++it) { 214 if(it.key().left(1) != "." && !it.data().isEmpty())
130 if(it.key().left(1) != "." && !it.data().isEmpty()) 215 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
131 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(), 216 it.data().join(" :: ").latin1());
132 it.data().join(" :: ").latin1());
133 }
134 } 217 }
135 VcsolutionDepend *newDep = new VcsolutionDepend; 218 }
136 newDep->vcprojFile = fileFixify(vcproj); 219
137 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); 220 // We assume project filename is [QMAKE_ORIG_TARGET].vcproj
138 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); 221 QString vcproj = fixFilename(tmp_vcproj.project->first("QMAKE_ORIG_TARGET")) + project->first("VCPROJ_EXTENSION");
139 if(newDep->target.endsWith(".dll")) 222
140 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; 223 // If file doesn't exsist, then maybe the users configuration
141 if(!tmp_proj.isEmpty("FORMS")) 224 // doesn't allow it to be created. Skip to next...
142 newDep->dependencies << "uic.exe"; 225 if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) {
143 { 226 qDebug( "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() );
144 QStringList where("QMAKE_LIBS"); 227 goto nextfile; // # Dirty!
145 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 228 }
146 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; 229
147 for(QStringList::iterator wit = where.begin(); 230 VcsolutionDepend *newDep = new VcsolutionDepend;
148 wit != where.end(); ++wit) { 231 newDep->vcprojFile = fileFixify(vcproj);
149 QStringList &l = tmp_proj.variables()[(*wit)]; 232 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
150 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 233 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1);
151 QString opt = (*it); 234 newDep->targetType = tmp_vcproj.projectTarget;
152 if(!opt.startsWith("/")) //Not a switch 235 {
153 newDep->dependencies << opt.section(Option::dir_sep, -1); 236 static QUuid uuid = solutionGUID;
154 } 237 uuid = increaseUUID( uuid );
238 newDep->uuid = uuid.toString().upper();
239 }
240 if(newDep->target.endsWith(".dll"))
241 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
242 if(!tmp_proj.isEmpty("FORMS"))
243 newDep->dependencies << "uic.exe";
244 {
245 QStringList where("QMAKE_LIBS");
246 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
247 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
248 for(QStringList::iterator wit = where.begin();
249 wit != where.end(); ++wit) {
250 QStringList &l = tmp_proj.variables()[(*wit)];
251 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
252 QString opt = (*it);
253 if(!opt.startsWith("/")) //Not a switch
254 newDep->dependencies << opt.section(Option::dir_sep, -1);
155 } 255 }
156 } 256 }
157 solution_depends.append(newDep);
158 } 257 }
258 solution_cleanup.append(newDep);
259 solution_depends.insert(newDep->target, newDep);
260 {
261 QRegExp libVersion("[0-9]{3,3}\\.lib$");
262 if(libVersion.search(newDep->target) != -1)
263 solution_depends.insert(newDep->target.left(newDep->target.length() -
264 libVersion.matchedLength()) + ".lib", newDep);
265 }
266 t << _snlProjectBeg << _snlMSVCvcprojGUID << _snlProjectMid
267 << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile
268 << "\", \"" << newDep->uuid << "\"";
269 t << _snlProjectEnd;
159 } 270 }
160 } 271 }
272nextfile:
161 QDir::setCurrent(oldpwd); 273 QDir::setCurrent(oldpwd);
162 } 274 }
163 } 275 }
164 } 276 }
165 277 t << _snlGlobalBeg;
166 VcsolutionDepend *vc; 278 t << _snlSolutionConf;
167 QMap<QString, int> uuids; 279 t << _snlProjDepBeg;
168 QRegExp libVersion("[0-9]{3,3}\\.lib$"); 280 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
169 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) { 281 int cnt = 0;
170 static int uuid = 666; 282 for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin();
171 uuids.insert(vc->target, uuid); 283 dit != solution_cleanup.current()->dependencies.end();
172 if(libVersion.match(vc->target) != -1) 284 ++dit) {
173 uuids.insert(vc->target.left(vc->target.length() - libVersion.matchedLength()) + ".lib", 285 VcsolutionDepend *vc;
174 uuid); 286 if((vc=solution_depends[*dit])) {
175 t << "\"" << vc->orig_target << "\" \"" << vc->vcprojFile << "\" { " << uuid << " }" << endl; 287 if(solution_cleanup.current()->targetType != StaticLib || vc->targetType == Application)
176 uuid++; 288 t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid;
177 } 289 }
178 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) {
179 int uuid = uuids[vc->target], cnt = 0;
180 for(QStringList::iterator dit = vc->dependencies.begin(); dit != vc->dependencies.end(); ++dit) {
181 if(uuids.contains((*dit)))
182 t << uuid << "." << cnt++ << " = " << uuids[(*dit)] << endl;
183 } 290 }
184 } 291 }
292 t << _snlProjDepEnd;
293 t << _snlProjConfBeg;
294 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
295 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag1;
296 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag2;
297 }
298 t << _snlProjConfEnd;
299 t << _snlExtSections;
300 t << _snlGlobalEnd;
185} 301}
186 302
187// ------------------------------------------------------------------------------------------------ 303// ------------------------------------------------------------------------------------------------
188// ------------------------------------------------------------------------------------------------ 304// ------------------------------------------------------------------------------------------------
189 305
190void VcprojGenerator::init() 306void VcprojGenerator::init()
191{ 307{
192 if( init_flag ) 308 if( init_flag )
193 return; 309 return;
194 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs 310 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs
195 init_flag = TRUE; 311 init_flag = TRUE;
196 return; 312 return;
197 } 313 }
198 314
199 debug_msg(1, "Generator: MSVC.NET: Initializing variables" ); 315 debug_msg(1, "Generator: MSVC.NET: Initializing variables" );
200 316
201/* 317/*
202 // Once to be nice and clean code... 318 // Once to be nice and clean code...
203 // Wouldn't life be great? 319 // Wouldn't life be great?
204 320
205 // Are we building Qt? 321 // Are we building Qt?
206 bool is_qt = 322 bool is_qt =
207 ( project->first("TARGET") == "qt"QTDLL_POSTFIX || 323 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
208 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); 324 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
@@ -285,219 +401,238 @@ void VcprojGenerator::initConfiguration()
285 // Initialize XML sub elements 401 // Initialize XML sub elements
286 // - Do this first since main configuration elements may need 402 // - Do this first since main configuration elements may need
287 // - to know of certain compiler/linker options 403 // - to know of certain compiler/linker options
288 initCompilerTool(); 404 initCompilerTool();
289 if ( projectTarget == StaticLib ) 405 if ( projectTarget == StaticLib )
290 initLibrarianTool(); 406 initLibrarianTool();
291 else 407 else
292 initLinkerTool(); 408 initLinkerTool();
293 initIDLTool(); 409 initIDLTool();
294 410
295 // Own elements ----------------------------- 411 // Own elements -----------------------------
296 QString temp = project->first("BuildBrowserInformation"); 412 QString temp = project->first("BuildBrowserInformation");
297 switch ( projectTarget ) { 413 switch ( projectTarget ) {
298 case SharedLib: 414 case SharedLib:
299 vcProject.Configuration.ConfigurationType = typeDynamicLibrary; 415 vcProject.Configuration.ConfigurationType = typeDynamicLibrary;
300 break; 416 break;
301 case StaticLib: 417 case StaticLib:
302 vcProject.Configuration.ConfigurationType = typeStaticLibrary; 418 vcProject.Configuration.ConfigurationType = typeStaticLibrary;
303 break; 419 break;
304 case Application: 420 case Application:
305 default: 421 default:
306 vcProject.Configuration.ConfigurationType = typeApplication; 422 vcProject.Configuration.ConfigurationType = typeApplication;
307 break; 423 break;
308 } 424 }
309 vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" ); 425 vcProject.Configuration.Name = ( project->isActiveConfig( "debug" ) ? "Debug|" : "Release|" );
310 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); 426 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
311 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); 427 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
312 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() ); 428 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() );
313 temp = project->first("CharacterSet"); 429 temp = project->first("CharacterSet");
314 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() ); 430 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() );
315 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); 431 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
316 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; 432 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary;
317 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); 433 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR");
318// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR"); 434// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR");
319 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp ); 435 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp );
320 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput"); 436 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput");
321 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization; 437 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization;
322 temp = project->first("UseOfATL"); 438 temp = project->first("UseOfATL");
323 if ( !temp.isEmpty() ) 439 if ( !temp.isEmpty() )
324 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() ); 440 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() );
325 temp = project->first("UseOfMfc"); 441 temp = project->first("UseOfMfc");
326 if ( !temp.isEmpty() ) 442 if ( !temp.isEmpty() )
327 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() ); 443 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() );
328 444
329 // Configuration does not need parameters from 445 // Configuration does not need parameters from
330 // these sub XML items; 446 // these sub XML items;
331 initCustomBuildTool(); 447 initCustomBuildTool();
332 initPreBuildEventTools(); 448 initPreBuildEventTools();
333 initPostBuildEventTools(); 449 initPostBuildEventTools();
334 initPreLinkEventTools(); 450 initPreLinkEventTools();
335} 451}
336 452
337void VcprojGenerator::initCompilerTool() 453void VcprojGenerator::initCompilerTool()
338{ 454{
339 QString placement = project->first("OBJECTS_DIR"); 455 QString placement = project->first("OBJECTS_DIR");
340 if ( placement.isEmpty() ) 456 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\"; 457 placement = ".\\";
342 458
343 vcProject.Configuration.compiler.AssemblerListingLocation = placement ; 459 vcProject.Configuration.compiler.AssemblerListingLocation = placement ;
344 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; 460 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ;
345 vcProject.Configuration.compiler.ObjectFile = placement ; 461 vcProject.Configuration.compiler.ObjectFile = placement ;
346 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch"; 462 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch";
347 463
348 if ( project->isActiveConfig("debug") ){ 464 if ( project->isActiveConfig("debug") ){
349 // Debug version 465 // Debug version
350 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 466 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
351 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); 467 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] );
352 if ( project->isActiveConfig("thread") ) { 468 if ( project->isActiveConfig("thread") ) {
353 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 469 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
354 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); 470 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
355 else 471 else
356 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); 472 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] );
357 } else { 473 } else {
358 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] ); 474 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] );
359 } 475 }
360 } else { 476 } else {
361 // Release version 477 // Release version
362 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 478 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
363 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); 479 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
364 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; 480 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
481 vcProject.Configuration.compiler.PreprocessorDefinitions += "NDEBUG";
365 if ( project->isActiveConfig("thread") ) { 482 if ( project->isActiveConfig("thread") ) {
366 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 483 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
367 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); 484 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
368 else 485 else
369 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); 486 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] );
370 } else { 487 } else {
371 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] ); 488 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] );
372 } 489 }
373 } 490 }
374 491
375 // Common for both release and debug 492 // Common for both release and debug
376 if ( project->isActiveConfig("warn_off") ) 493 if ( project->isActiveConfig("warn_off") )
377 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); 494 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
378 else 495 else if ( project->isActiveConfig("warn_on") )
379 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); 496 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
380 if ( project->isActiveConfig("windows") ) 497 if ( project->isActiveConfig("windows") )
381 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; 498 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
382 499
383 // Can this be set for ALL configs? 500 // Can this be set for ALL configs?
384 // If so, use qmake.conf! 501 // If so, use qmake.conf!
385 if ( projectTarget == SharedLib ) 502 if ( projectTarget == SharedLib )
386 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS"; 503 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS";
387 504
388 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; 505 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"];
389 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; 506 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
390 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); 507 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
391} 508}
392 509
393void VcprojGenerator::initLibrarianTool() 510void VcprojGenerator::initLibrarianTool()
394{ 511{
395 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" ); 512 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" );
396 if( vcProject.Configuration.librarian.OutputFile.isEmpty() ) 513 if( vcProject.Configuration.librarian.OutputFile.isEmpty() )
397 vcProject.Configuration.librarian.OutputFile = ".\\"; 514 vcProject.Configuration.librarian.OutputFile = ".\\";
398 515
399 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") ) 516 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") )
400 vcProject.Configuration.librarian.OutputFile += '\\'; 517 vcProject.Configuration.librarian.OutputFile += '\\';
401 518
402 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); 519 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
403} 520}
404 521
405void VcprojGenerator::initLinkerTool() 522void VcprojGenerator::initLinkerTool()
406{ 523{
407 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); 524 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] );
408 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; 525 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
409 526
410 switch ( projectTarget ) { 527 switch ( projectTarget ) {
411 case Application: 528 case Application:
412 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); 529 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" );
413 break; 530 break;
414 case SharedLib: 531 case SharedLib:
415 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); 532 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
416 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); 533 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" );
417 break; 534 break;
535 case StaticLib: //unhandled - added to remove warnings..
536 break;
418 } 537 }
419 538
420 if( vcProject.Configuration.linker.OutputFile.isEmpty() ) 539 if( vcProject.Configuration.linker.OutputFile.isEmpty() )
421 vcProject.Configuration.linker.OutputFile = ".\\"; 540 vcProject.Configuration.linker.OutputFile = ".\\";
422 541
423 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") ) 542 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") )
424 vcProject.Configuration.linker.OutputFile += '\\'; 543 vcProject.Configuration.linker.OutputFile += '\\';
425 544
426 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET"); 545 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET");
427 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb"; 546 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb";
428 547
429 if ( project->isActiveConfig("debug") ){ 548 if ( project->isActiveConfig("debug") ){
430 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); 549 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] );
431 } else { 550 } else {
432 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); 551 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] );
433 } 552 }
434 553
435 if ( project->isActiveConfig("dll") ){ 554 if ( project->isActiveConfig("dll") ){
436 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); 555 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] );
437 } 556 }
438 557
439 if ( project->isActiveConfig("console") ){ 558 if ( project->isActiveConfig("console") ){
440 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); 559 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] );
441 } else { 560 } else {
442 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); 561 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] );
443 } 562 }
444 563
445} 564}
446 565
447void VcprojGenerator::initIDLTool() 566void VcprojGenerator::initIDLTool()
448{ 567{
449} 568}
450 569
451void VcprojGenerator::initCustomBuildTool() 570void VcprojGenerator::initCustomBuildTool()
452{ 571{
453} 572}
454 573
455void VcprojGenerator::initPreBuildEventTools() 574void VcprojGenerator::initPreBuildEventTools()
456{ 575{
457 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION"); 576 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION");
458 if( !collectionName.isEmpty() ) { 577 if( !collectionName.isEmpty() ) {
459 QStringList& list = project->variables()["IMAGES"]; 578 QStringList& list = project->variables()["IMAGES"];
460 vcProject.Configuration.preBuild.Description = "Generate imagecollection"; 579 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
461 //vcProject.Configuration.preBuild.AdditionalDependencies += list; 580 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
462 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName; 581
582 QFile imgs( ".imgcol" );
583 imgs.open( IO_WriteOnly );
584 QTextStream s( &imgs );
585 QStringList::ConstIterator it = list.begin();
586 while( it!=list.end() ) {
587 s << *it << " ";
588 it++;
589 }
590
591 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " -f .imgcol -o " + collectionName;
463 //vcProject.Configuration.preBuild.Outputs = collectionName; 592 //vcProject.Configuration.preBuild.Outputs = collectionName;
464 593
465 } 594 }
466} 595}
467 596
468void VcprojGenerator::initPostBuildEventTools() 597void VcprojGenerator::initPostBuildEventTools()
469{ 598{
599 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) {
600 vcProject.Configuration.postBuild.Description = var("QMAKE_POST_LINK");
601 vcProject.Configuration.postBuild.CommandLine = var("QMAKE_POST_LINK");
602 }
470 if( project->isActiveConfig( "activeqt" ) ) { 603 if( project->isActiveConfig( "activeqt" ) ) {
471 QString name = project->first( "QMAKE_ORIG_TARGET" ); 604 QString name = project->first( "QMAKE_ORIG_TARGET" );
472 QString nameext = project->first( "TARGET" ); 605 QString nameext = project->first( "TARGET" );
473 QString objdir = project->first( "OBJECTS_DIR" ); 606 QString objdir = project->first( "OBJECTS_DIR" );
474 QString idc = project->first( "QMAKE_IDC" ); 607 QString idc = project->first( "QMAKE_IDC" );
475 608
476 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; 609 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server...";
610 if ( !vcProject.Configuration.postBuild.CommandLine.isEmpty() )
611 vcProject.Configuration.postBuild.CommandLine += " &amp;&amp; ";
477 612
478 if( project->isActiveConfig( "dll" ) ) { // In process 613 if( project->isActiveConfig( "dll" ) ) { // In process
479 vcProject.Configuration.postBuild.CommandLine = 614 vcProject.Configuration.postBuild.CommandLine +=
480 // call idc to generate .idl file from .dll 615 // call idc to generate .idl file from .dll
481 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 616 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
482 // call midl to create implementations of the .idl file 617 // call midl to create implementations of the .idl file
483 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 618 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
484 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + 619 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
485 objdir + "dump.midl &amp;&amp; " + 620 objdir + "dump.midl &amp;&amp; " +
486 // call idc to replace tlb... 621 // call idc to replace tlb...
487 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 622 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
488 // register server 623 // register server
489 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver"; 624 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver";
490 } else { // out of process 625 } else { // out of process
491 vcProject.Configuration.postBuild.CommandLine = 626 vcProject.Configuration.postBuild.CommandLine =
492 // call application to dump idl 627 // call application to dump idl
493 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 628 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
494 // call midl to create implementations of the .idl file 629 // call midl to create implementations of the .idl file
495 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + 630 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
496 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + 631 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
497 objdir + "dump.midl &amp;&amp; " + 632 objdir + "dump.midl &amp;&amp; " +
498 // call idc to replace tlb... 633 // call idc to replace tlb...
499 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " + 634 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
500 // call app to register 635 // call app to register
501 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; 636 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver";
502 } 637 }
503 } 638 }
@@ -581,75 +716,82 @@ void VcprojGenerator::initLexYaccFiles()
581 vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; 716 vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
582 vcProject.LexYaccFiles.ParseFiles = _False; 717 vcProject.LexYaccFiles.ParseFiles = _False;
583 vcProject.LexYaccFiles.Filter = "l;y"; 718 vcProject.LexYaccFiles.Filter = "l;y";
584 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"]; 719 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"];
585 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"]; 720 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"];
586 vcProject.LexYaccFiles.Files.sort(); 721 vcProject.LexYaccFiles.Files.sort();
587 vcProject.LexYaccFiles.Project = this; 722 vcProject.LexYaccFiles.Project = this;
588 vcProject.LexYaccFiles.CustomBuild = lexyacc; 723 vcProject.LexYaccFiles.CustomBuild = lexyacc;
589} 724}
590 725
591void VcprojGenerator::initResourceFiles() 726void VcprojGenerator::initResourceFiles()
592{ 727{
593 vcProject.ResourceFiles.Name = "Resources"; 728 vcProject.ResourceFiles.Name = "Resources";
594 vcProject.ResourceFiles.ParseFiles = _False; 729 vcProject.ResourceFiles.ParseFiles = _False;
595 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; 730 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts";
596 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"]; 731 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"];
597 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"]; 732 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"];
598 vcProject.ResourceFiles.Files += project->variables()["IMAGES"]; 733 vcProject.ResourceFiles.Files += project->variables()["IMAGES"];
599 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"]; 734 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"];
600 vcProject.ResourceFiles.Files.sort(); 735 vcProject.ResourceFiles.Files.sort();
601 vcProject.ResourceFiles.Project = this; 736 vcProject.ResourceFiles.Project = this;
602 vcProject.ResourceFiles.CustomBuild = none; 737 vcProject.ResourceFiles.CustomBuild = none;
603} 738}
604 739
605/*
606// $$MSVCPROJ_IDLSOURCES ---------------------------------------------
607void VcprojGenerator::writeIDLs( QTextStream &t )
608{
609 QStringList &l = project->variables()["MSVCPROJ_IDLSOURCES"];
610 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
611 t << "# Begin Source File" << endl << endl;
612 t << "SOURCE=" << (*it) << endl;
613 t << "# PROP Exclude_From_Build 1" << endl;
614 t << "# End Source File" << endl << endl;
615 }
616 debug_msg(3, "Generator: MSVC.NET: Added IDLs" );
617}
618*/
619
620/* \internal 740/* \internal
621 Sets up all needed variables from the environment and all the different caches and .conf files 741 Sets up all needed variables from the environment and all the different caches and .conf files
622*/ 742*/
623 743
624void VcprojGenerator::initOld() 744void VcprojGenerator::initOld()
625{ 745{
626 if( init_flag ) 746 if( init_flag )
627 return; 747 return;
628 748
629 init_flag = TRUE; 749 init_flag = TRUE;
630 QStringList::Iterator it; 750 QStringList::Iterator it;
631 751
752 if ( project->isActiveConfig("stl") ) {
753 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
754 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
755 } else {
756 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
757 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
758 }
759 if ( project->isActiveConfig("exceptions") ) {
760 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
761 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
762 } else {
763 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
764 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
765 }
766 if ( project->isActiveConfig("rtti") ) {
767 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
768 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
769 } else {
770 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
771 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
772 }
773
632 // this should probably not be here, but I'm using it to wrap the .t files 774 // this should probably not be here, but I'm using it to wrap the .t files
633 if(project->first("TEMPLATE") == "vcapp" ) 775 if(project->first("TEMPLATE") == "vcapp" )
634 project->variables()["QMAKE_APP_FLAG"].append("1"); 776 project->variables()["QMAKE_APP_FLAG"].append("1");
635 else if(project->first("TEMPLATE") == "vclib") 777 else if(project->first("TEMPLATE") == "vclib")
636 project->variables()["QMAKE_LIB_FLAG"].append("1"); 778 project->variables()["QMAKE_LIB_FLAG"].append("1");
637 if ( project->variables()["QMAKESPEC"].isEmpty() ) 779 if ( project->variables()["QMAKESPEC"].isEmpty() )
638 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); 780 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
639 781
640 bool is_qt = 782 bool is_qt =
641 ( project->first("TARGET") == "qt"QTDLL_POSTFIX || 783 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
642 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); 784 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
643 785
644 QStringList &configs = project->variables()["CONFIG"]; 786 QStringList &configs = project->variables()["CONFIG"];
645 787
646 if ( project->isActiveConfig( "shared" ) ) 788 if ( project->isActiveConfig( "shared" ) )
647 project->variables()["DEFINES"].append( "QT_DLL" ); 789 project->variables()["DEFINES"].append( "QT_DLL" );
648 790
649 if ( project->isActiveConfig( "qt_dll" ) && 791 if ( project->isActiveConfig( "qt_dll" ) &&
650 configs.findIndex("qt") == -1 ) 792 configs.findIndex("qt") == -1 )
651 configs.append("qt"); 793 configs.append("qt");
652 794
653 if ( project->isActiveConfig( "qt" ) ) { 795 if ( project->isActiveConfig( "qt" ) ) {
654 if ( project->isActiveConfig( "plugin" ) ) { 796 if ( project->isActiveConfig( "plugin" ) ) {
655 project->variables()["CONFIG"].append( "dll" ); 797 project->variables()["CONFIG"].append( "dll" );
@@ -767,156 +909,175 @@ void VcprojGenerator::initOld()
767 909
768 // DLL ----------------------------------------------------------- 910 // DLL -----------------------------------------------------------
769 if ( project->isActiveConfig("dll") ) { 911 if ( project->isActiveConfig("dll") ) {
770 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { 912 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
771 QString ver_xyz(project->first("VERSION")); 913 QString ver_xyz(project->first("VERSION"));
772 ver_xyz.replace(QRegExp("\\."), ""); 914 ver_xyz.replace(QRegExp("\\."), "");
773 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); 915 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll");
774 } else { 916 } else {
775 project->variables()["TARGET_EXT"].append(".dll"); 917 project->variables()["TARGET_EXT"].append(".dll");
776 } 918 }
777 } 919 }
778 // EXE / LIB ----------------------------------------------------- 920 // EXE / LIB -----------------------------------------------------
779 else { 921 else {
780 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) 922 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
781 project->variables()["TARGET_EXT"].append(".exe"); 923 project->variables()["TARGET_EXT"].append(".exe");
782 else 924 else
783 project->variables()["TARGET_EXT"].append(".lib"); 925 project->variables()["TARGET_EXT"].append(".lib");
784 } 926 }
785 927
786 project->variables()["MSVCPROJ_VER"] = "7.00"; 928 project->variables()["MSVCPROJ_VER"] = "7.00";
787 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI"; 929 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI";
788 930
789 // INCREMENTAL:NO ------------------------------------------------ 931 // INCREMENTAL:NO ------------------------------------------------
790 if(!project->isActiveConfig("incremental")) { 932 if(!project->isActiveConfig("incremental")) {
791 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 933 project->variables()["QMAKE_LFLAGS"].append(QString("/INCREMENTAL:no"));
792 if ( is_qt ) 934 if ( is_qt )
793 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi"; 935 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi";
794 } 936 }
795 937
796 // MOC ----------------------------------------------------------- 938 // MOC -----------------------------------------------------------
797 if ( project->isActiveConfig("moc") ) 939 if ( project->isActiveConfig("moc") )
798 setMocAware(TRUE); 940 setMocAware(TRUE);
799 941
800 942
801 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 943 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
944 // Update -lname to name.lib, and -Ldir to
945 QStringList &libList = project->variables()["QMAKE_LIBS"];
946 for( it = libList.begin(); it != libList.end(); ) {
947 QString s = *it;
948 if( s.startsWith( "-l" ) ) {
949 it = libList.remove( it );
950 it = libList.insert( it, s.mid( 2 ) + ".lib" );
951 } else if( s.startsWith( "-L" ) ) {
952 it = libList.remove( it );
953 } else {
954 it++;
955 }
956 }
802 957
803 // Run through all variables containing filepaths, and ----------- 958 // Run through all variables containing filepaths, and -----------
804 // slash-slosh them correctly depending on current OS ----------- 959 // slash-slosh them correctly depending on current OS -----------
805 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); 960 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
806 QStringList &l = project->variables()["QMAKE_FILETAGS"]; 961 QStringList &l = project->variables()["QMAKE_FILETAGS"];
807 for(it = l.begin(); it != l.end(); ++it) { 962 for(it = l.begin(); it != l.end(); ++it) {
808 QStringList &gdmf = project->variables()[(*it)]; 963 QStringList &gdmf = project->variables()[(*it)];
809 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) 964 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
810 (*inner) = Option::fixPathToTargetOS((*inner), FALSE); 965 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
811 } 966 }
812 967
813 // Get filename w/o extention ----------------------------------- 968 // Get filename w/o extention -----------------------------------
814 QString msvcproj_project = ""; 969 QString msvcproj_project = "";
815 QString targetfilename = ""; 970 QString targetfilename = "";
816 if ( project->variables()["TARGET"].count() ) { 971 if ( project->variables()["TARGET"].count() ) {
817 msvcproj_project = project->variables()["TARGET"].first(); 972 msvcproj_project = project->variables()["TARGET"].first();
818 targetfilename = msvcproj_project; 973 targetfilename = msvcproj_project;
819 } 974 }
820 975
821 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------ 976 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------
822 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 977 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
823 978
824 // TARGET (add extention to $$TARGET) ---------------------------- 979 // TARGET (add extention to $$TARGET)
825 project->variables()["TARGET"].first() += project->first("TARGET_EXT"); 980 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue(".first() += project->first("TARGET_EXT");
826 981
827 // Init base class too ------------------------------------------- 982 // Init base class too -------------------------------------------
828 MakefileGenerator::init(); 983 MakefileGenerator::init();
829 984
830 985
831 if ( msvcproj_project.isEmpty() ) 986 if ( msvcproj_project.isEmpty() )
832 msvcproj_project = Option::output.name(); 987 msvcproj_project = Option::output.name();
833 988
834 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 ); 989 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 );
835 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) ); 990 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) );
836 msvcproj_project.replace(QRegExp("-"), ""); 991 msvcproj_project.replace(QRegExp("-"), "");
837 992
838 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project); 993 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project);
839 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"]; 994 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"];
840 995
841 for(it = proj.begin(); it != proj.end(); ++it) 996 for(it = proj.begin(); it != proj.end(); ++it)
842 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); 997 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
843 998
844 // SUBSYSTEM ----------------------------------------------------- 999 // SUBSYSTEM -----------------------------------------------------
845 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1000 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
846 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) ); 1001 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) );
847 if ( project->isActiveConfig("console") ) { 1002 if ( project->isActiveConfig("console") ) {
848 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE"); 1003 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE");
849 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE"); 1004 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE");
850 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103"); 1005 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103");
851 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE"); 1006 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE");
852 } else { 1007 } else {
853 project->variables()["MSVCPROJ_CONSOLE"].clear(); 1008 project->variables()["MSVCPROJ_CONSOLE"].clear();
854 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS"); 1009 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS");
855 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101"); 1010 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101");
856 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS"); 1011 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS");
857 } 1012 }
858 } else { 1013 } else {
859 if ( project->isActiveConfig("dll") ) { 1014 if ( project->isActiveConfig("dll") ) {
860 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) ); 1015 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) );
861 } else { 1016 } else {
862 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) ); 1017 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) );
863 } 1018 }
864 } 1019 }
865 1020
866 // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- 1021 // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------
867 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"]; 1022 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"];
868 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 1023 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
869 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 1024 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
870 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 1025 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) {
871 project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:","")); 1026 QStringList strl = project->variables()["QMAKE_LIBDIR"];
1027 QStringList::iterator stri;
1028 for ( stri = strl.begin(); stri != strl.end(); ++stri ) {
1029 if ( !(*stri).startsWith("/LIBPATH:") )
1030 (*stri).prepend( "/LIBPATH:" );
1031 }
1032 project->variables()["MSVCPROJ_LFLAGS"] += strl;
1033 }
872 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; 1034 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
873 // We don't use this... Direct manipulation of compiler object 1035 // We don't use this... Direct manipulation of compiler object
874 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 1036 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
875 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); 1037 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
876 QStringList &incs = project->variables()["INCLUDEPATH"]; 1038 QStringList &incs = project->variables()["INCLUDEPATH"];
877 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 1039 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
878 QString inc = (*incit); 1040 QString inc = (*incit);
879 inc.replace(QRegExp("\""), ""); 1041 inc.replace(QRegExp("\""), "");
880 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc ); 1042 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc );
881 } 1043 }
882 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir()); 1044 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir());
883 1045
884 QString dest; 1046 QString dest;
885 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET"); 1047 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET");
886 if ( !project->variables()["DESTDIR"].isEmpty() ) { 1048 Option::fixPathToTargetOS(project->first("TARGET"));
887 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 1049 dest = project->first("TARGET") + project->first( "TARGET_EXT" );
888 Option::fixPathToTargetOS(project->first("TARGET")); 1050 if ( project->first("TARGET").startsWith("$(QTDIR)") )
889 dest = project->first("TARGET"); 1051 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
890 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 1052 project->variables()["MSVCPROJ_TARGET"] = dest;
891 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); 1053 if ( project->isActiveConfig("dll") ) {
892 project->variables()["MSVCPROJ_TARGET"].append( 1054 QString imp = project->first( "DESTDIR" );
893 QString("/OUT:") + dest ); 1055 if( !imp.isNull() && !imp.endsWith( "\\" ) )
894 if ( project->isActiveConfig("dll") ) { 1056 imp += "\\";
895 QString imp = dest; 1057 imp += dest;
896 imp.replace(QRegExp("\\.dll"), ".lib"); 1058 imp.replace(QRegExp("\\.dll"), ".lib");
897 project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp ); 1059 project->variables()["MSVCPROJ_LIBOPTIONS"] += QString("/IMPLIB:") + imp;
898 }
899 } 1060 }
900 1061
901 // DLL COPY ------------------------------------------------------ 1062 // DLL COPY ------------------------------------------------------
902 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { 1063 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
903 QStringList dlldirs = project->variables()["DLLDESTDIR"]; 1064 QStringList dlldirs = project->variables()["DLLDESTDIR"];
904 QString copydll = "# Begin Special Build Tool\n" 1065 QString copydll = "# Begin Special Build Tool\n"
905 "TargetPath=" + dest + "\n" 1066 "TargetPath=" + dest + "\n"
906 "SOURCE=$(InputPath)\n" 1067 "SOURCE=$(InputPath)\n"
907 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" 1068 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
908 "PostBuild_Cmds="; 1069 "PostBuild_Cmds=";
909 1070
910 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { 1071 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
911 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; 1072 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t";
912 } 1073 }
913 1074
914 copydll += "\n# End Special Build Tool"; 1075 copydll += "\n# End Special Build Tool";
915 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll ); 1076 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll );
916 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll ); 1077 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll );
917 } 1078 }
918 1079
919 // ACTIVEQT ------------------------------------------------------ 1080 // ACTIVEQT ------------------------------------------------------
920 if ( project->isActiveConfig("activeqt") ) { 1081 if ( project->isActiveConfig("activeqt") ) {
921 QString idl = project->variables()["QMAKE_IDL"].first(); 1082 QString idl = project->variables()["QMAKE_IDL"].first();
922 QString idc = project->variables()["QMAKE_IDC"].first(); 1083 QString idc = project->variables()["QMAKE_IDC"].first();
@@ -975,76 +1136,79 @@ void VcprojGenerator::initOld()
975 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS"; 1136 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS";
976 1137
977 // Verbose output if "-d -d"... 1138 // Verbose output if "-d -d"...
978 outputVariables(); 1139 outputVariables();
979} 1140}
980 1141
981// ------------------------------------------------------------------------------------------------ 1142// ------------------------------------------------------------------------------------------------
982// ------------------------------------------------------------------------------------------------ 1143// ------------------------------------------------------------------------------------------------
983 1144
984bool VcprojGenerator::openOutput(QFile &file) const 1145bool VcprojGenerator::openOutput(QFile &file) const
985{ 1146{
986 QString outdir; 1147 QString outdir;
987 if(!file.name().isEmpty()) { 1148 if(!file.name().isEmpty()) {
988 QFileInfo fi(file); 1149 QFileInfo fi(file);
989 if(fi.isDir()) 1150 if(fi.isDir())
990 outdir = file.name() + QDir::separator(); 1151 outdir = file.name() + QDir::separator();
991 } 1152 }
992 if(!outdir.isEmpty() || file.name().isEmpty()) { 1153 if(!outdir.isEmpty() || file.name().isEmpty()) {
993 QString ext = project->first("VCPROJ_EXTENSION"); 1154 QString ext = project->first("VCPROJ_EXTENSION");
994 if(project->first("TEMPLATE") == "vcsubdirs") 1155 if(project->first("TEMPLATE") == "vcsubdirs")
995 ext = project->first("VCSOLUTION_EXTENSION"); 1156 ext = project->first("VCSOLUTION_EXTENSION");
996 file.setName(outdir + project->first("TARGET") + ext); 1157 file.setName(outdir + project->first("TARGET") + ext);
997 } 1158 }
998 if(QDir::isRelativePath(file.name())) { 1159 if(QDir::isRelativePath(file.name())) {
999 QString ofile; 1160 file.setName( Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + fixFilename(file.name())) );
1000 ofile = file.name();
1001 int slashfind = ofile.findRev('\\');
1002 if (slashfind == -1) {
1003 ofile = ofile.replace("-", "_");
1004 } else {
1005 int hypenfind = ofile.find('-', slashfind);
1006 while (hypenfind != -1 && slashfind < hypenfind) {
1007 ofile = ofile.replace(hypenfind, 1, "_");
1008 hypenfind = ofile.find('-', hypenfind + 1);
1009 }
1010 }
1011 file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
1012 } 1161 }
1013 return Win32MakefileGenerator::openOutput(file); 1162 return Win32MakefileGenerator::openOutput(file);
1014} 1163}
1015 1164
1165QString VcprojGenerator::fixFilename(QString ofile) const
1166{
1167 int slashfind = ofile.findRev('\\');
1168 if (slashfind == -1) {
1169 ofile = ofile.replace('-', '_');
1170 } else {
1171 int hypenfind = ofile.find('-', slashfind);
1172 while (hypenfind != -1 && slashfind < hypenfind) {
1173 ofile = ofile.replace(hypenfind, 1, '_');
1174 hypenfind = ofile.find('-', hypenfind + 1);
1175 }
1176 }
1177 return ofile;
1178}
1179
1016QString VcprojGenerator::findTemplate(QString file) 1180QString VcprojGenerator::findTemplate(QString file)
1017{ 1181{
1018 QString ret; 1182 QString ret;
1019 if(!QFile::exists((ret = file)) && 1183 if(!QFile::exists((ret = file)) &&
1020 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && 1184 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
1021 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) && 1185 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) &&
1022 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) 1186 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
1023 return ""; 1187 return "";
1024 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() ); 1188 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() );
1025 return ret; 1189 return ret;
1026} 1190}
1027 1191
1028 1192
1029void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l) 1193void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l)
1030{ 1194{
1031 if(var == "QMAKE_PRL_DEFINES") { 1195 if(var == "QMAKE_PRL_DEFINES") {
1032 QStringList &out = project->variables()["MSVCPROJ_DEFINES"]; 1196 QStringList &out = project->variables()["MSVCPROJ_DEFINES"];
1033 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { 1197 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
1034 if(out.findIndex((*it)) == -1) 1198 if(out.findIndex((*it)) == -1)
1035 out.append((" /D " + *it )); 1199 out.append((" /D " + *it ));
1036 } 1200 }
1037 } else { 1201 } else {
1038 MakefileGenerator::processPrlVariable(var, l); 1202 MakefileGenerator::processPrlVariable(var, l);
1039 } 1203 }
1040} 1204}
1041 1205
1042void VcprojGenerator::outputVariables() 1206void VcprojGenerator::outputVariables()
1043{ 1207{
1044#if 0 1208#if 0
1045 debug_msg(3, "Generator: MSVC.NET: List of current variables:" ); 1209 qDebug( "Generator: MSVC.NET: List of current variables:" );
1046 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) { 1210 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) {
1047 debug_msg(3, "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() ); 1211 qDebug( "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() );
1048 } 1212 }
1049#endif 1213#endif
1050} 1214}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 583b164..69e0c02 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -1,129 +1,115 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of VcprojGenerator class. 4** Definition of VcprojGenerator class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __VCPROJMAKE_H__ 37#ifndef __MSVC_VCPROJ_H__
38#define __VCPROJMAKE_H__ 38#define __MSVC_VCPROJ_H__
39 39
40#include "winmakefile.h" 40#include "winmakefile.h"
41#include "msvc_objectmodel.h" 41#include "msvc_objectmodel.h"
42 42
43enum target { 43enum target {
44 Application, 44 Application,
45 SharedLib, 45 SharedLib,
46 StaticLib 46 StaticLib
47}; 47};
48 48
49struct QUuid;
49class VcprojGenerator : public Win32MakefileGenerator 50class VcprojGenerator : public Win32MakefileGenerator
50{ 51{
51 bool init_flag; 52 bool init_flag;
52 bool writeVcprojParts(QTextStream &); 53 bool writeVcprojParts(QTextStream &);
53 54
54 bool writeMakefile(QTextStream &); 55 bool writeMakefile(QTextStream &);
55 virtual void writeSubDirs(QTextStream &t); 56 virtual void writeSubDirs(QTextStream &t);
56 QString findTemplate(QString file); 57 QString findTemplate(QString file);
57 void init(); 58 void init();
58 59
59public: 60public:
60 VcprojGenerator(QMakeProject *p); 61 VcprojGenerator(QMakeProject *p);
61 ~VcprojGenerator(); 62 ~VcprojGenerator();
62 63
63 QString defaultMakefile() const; 64 QString defaultMakefile() const;
64 virtual bool doDepends() const { return FALSE; } //never necesary 65 virtual bool doDepends() const { return FALSE; } //never necesary
65 66
66protected: 67protected:
67 virtual bool openOutput(QFile &file) const; 68 virtual bool openOutput(QFile &file) const;
68 virtual void processPrlVariable(const QString &, const QStringList &); 69 virtual void processPrlVariable(const QString &, const QStringList &);
69 virtual bool findLibraries(); 70 virtual bool findLibraries();
70 virtual void outputVariables(); 71 virtual void outputVariables();
72 QString fixFilename(QString ofile) const;
71 73
72 void initOld(); 74 void initOld();
73 void initProject(); 75 void initProject();
74 void initConfiguration(); 76 void initConfiguration();
75 void initCompilerTool(); 77 void initCompilerTool();
76 void initLinkerTool(); 78 void initLinkerTool();
77 void initLibrarianTool(); 79 void initLibrarianTool();
78 void initIDLTool(); 80 void initIDLTool();
79 void initCustomBuildTool(); 81 void initCustomBuildTool();
80 void initPreBuildEventTools(); 82 void initPreBuildEventTools();
81 void initPostBuildEventTools(); 83 void initPostBuildEventTools();
82 void initPreLinkEventTools(); 84 void initPreLinkEventTools();
83 void initSourceFiles(); 85 void initSourceFiles();
84 void initHeaderFiles(); 86 void initHeaderFiles();
85 void initMOCFiles(); 87 void initMOCFiles();
86 void initUICFiles(); 88 void initUICFiles();
87 void initFormsFiles(); 89 void initFormsFiles();
88 void initTranslationFiles(); 90 void initTranslationFiles();
89 void initLexYaccFiles(); 91 void initLexYaccFiles();
90 void initResourceFiles(); 92 void initResourceFiles();
91 93
92 /*
93 void writeGuid( QTextStream &t );
94 void writeAdditionalOptions( QTextStream &t );
95 void writeHeaders( QTextStream &t );
96 void writeSources( QTextStream &t );
97 void writeMocs( QTextStream &t );
98 void writeLexs( QTextStream &t );
99 void writeYaccs( QTextStream &t );
100 void writePictures( QTextStream &t );
101 void writeImages( QTextStream &t );
102 void writeIDLs( QTextStream &t );
103
104 void writeForms( QTextStream &t );
105 void writeFormsSourceHeaders( QString &variable, QTextStream &t );
106 void writeTranslations( QTextStream &t );
107 void writeStrippedTranslations( QTextStream &t );
108 */
109
110 VCProject vcProject; 94 VCProject vcProject;
111 target projectTarget; 95 target projectTarget;
112 96
97private:
98 QUuid increaseUUID(const QUuid &id);
113 friend class VCFilter; 99 friend class VCFilter;
114}; 100};
115 101
116inline VcprojGenerator::~VcprojGenerator() 102inline VcprojGenerator::~VcprojGenerator()
117{ } 103{ }
118 104
119inline QString VcprojGenerator::defaultMakefile() const 105inline QString VcprojGenerator::defaultMakefile() const
120{ 106{
121 return project->first("TARGET") + project->first("VCPROJ_EXTENSION"); 107 return project->first("TARGET") + project->first("VCPROJ_EXTENSION");
122} 108}
123 109
124inline bool VcprojGenerator::findLibraries() 110inline bool VcprojGenerator::findLibraries()
125{ 111{
126 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS"); 112 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS");
127} 113}
128 114
129#endif /* __VCPROJMAKE_H__ */ 115#endif /* __MSVC_VCPROJ_H__ */
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index a07c921..bc3fed9 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -80,272 +80,312 @@ Win32MakefileGenerator::writeSubDirs(QTextStream &t)
80 } else { 80 } else {
81 sd->directory = file; 81 sd->directory = file;
82 } 82 }
83 while(sd->directory.right(1) == Option::dir_sep) 83 while(sd->directory.right(1) == Option::dir_sep)
84 sd->directory = sd->directory.left(sd->directory.length() - 1); 84 sd->directory = sd->directory.left(sd->directory.length() - 1);
85 if(!sd->profile.isEmpty()) { 85 if(!sd->profile.isEmpty()) {
86 QString basename = sd->directory; 86 QString basename = sd->directory;
87 int new_slsh = basename.findRev(Option::dir_sep); 87 int new_slsh = basename.findRev(Option::dir_sep);
88 if(new_slsh != -1) 88 if(new_slsh != -1)
89 basename = basename.mid(new_slsh+1); 89 basename = basename.mid(new_slsh+1);
90 if(sd->profile != basename + ".pro") 90 if(sd->profile != basename + ".pro")
91 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro 91 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro
92 } 92 }
93 sd->target = "sub-" + (*it); 93 sd->target = "sub-" + (*it);
94 sd->target.replace('/', '-'); 94 sd->target.replace('/', '-');
95 sd->target.replace('.', '_'); 95 sd->target.replace('.', '_');
96 } 96 }
97 } 97 }
98 QPtrListIterator<SubDir> it(subdirs); 98 QPtrListIterator<SubDir> it(subdirs);
99 99
100 if(!project->isEmpty("MAKEFILE")) 100 if(!project->isEmpty("MAKEFILE"))
101 t << "MAKEFILE=" << var("MAKEFILE") << endl; 101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; 102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
103 t << "SUBTARGETS= "; 103 t << "SUBTARGETS= ";
104 for( it.toFirst(); it.current(); ++it) 104 for( it.toFirst(); it.current(); ++it)
105 t << " \\\n\t\t" << it.current()->target; 105 t << " \\\n\t\t" << it.current()->target;
106 t << endl << endl; 106 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl; 107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl;
108 108
109 for( it.toFirst(); it.current(); ++it) { 109 for( it.toFirst(); it.current(); ++it) {
110 bool have_dir = !(*it)->directory.isEmpty(); 110 bool have_dir = !(*it)->directory.isEmpty();
111 111
112 //make the makefile 112 //make the makefile
113 QString mkfile = (*it)->makefile; 113 QString mkfile = (*it)->makefile;
114 if(have_dir) 114 if(have_dir)
115 mkfile.prepend((*it)->directory + Option::dir_sep); 115 mkfile.prepend((*it)->directory + Option::dir_sep);
116 t << mkfile << ":"; 116 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
118 t << " FORCE"; 118 t << " FORCE";
119 if(have_dir) 119 if(have_dir)
120 t << "\n\t" << "cd " << (*it)->directory; 120 t << "\n\t" << "cd " << (*it)->directory;
121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); 121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();
122 if((*it)->makefile != "$(MAKEFILE)") 122 t << " -o " << (*it)->makefile;
123 t << " -o " << (*it)->makefile;
124 if(have_dir) { 123 if(have_dir) {
125 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 124 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
126 t << "\n\t" << "@cd .."; 125 t << "\n\t" << "@cd ..";
127 for(int i = 1; i < subLevels; i++ ) 126 for(int i = 1; i < subLevels; i++ )
128 t << Option::dir_sep << ".."; 127 t << Option::dir_sep << "..";
129 } 128 }
130 t << endl; 129 t << endl;
131 130
132 //now actually build 131 //now actually build
133 t << (*it)->target << ": " << mkfile; 132 t << (*it)->target << ": " << mkfile;
134 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 133 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
135 t << " FORCE"; 134 t << " FORCE";
136 if(have_dir) 135 if(have_dir)
137 t << "\n\t" << "cd " << (*it)->directory; 136 t << "\n\t" << "cd " << (*it)->directory;
138 t << "\n\t" << "$(MAKE)"; 137 t << "\n\t" << "$(MAKE)";
139 if((*it)->makefile != "$(MAKEFILE)") 138 t << " -f " << (*it)->makefile;
140 t << " -f " << (*it)->makefile;
141 if(have_dir) { 139 if(have_dir) {
142 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; 140 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
143 t << "\n\t" << "@cd .."; 141 t << "\n\t" << "@cd ..";
144 for(int i = 1; i < subLevels; i++ ) 142 for(int i = 1; i < subLevels; i++ )
145 t << Option::dir_sep << ".."; 143 t << Option::dir_sep << "..";
146 } 144 }
147 t << endl << endl; 145 t << endl << endl;
148 } 146 }
149 147
150 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) 148 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
151 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); 149 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
152 writeMakeQmake(t); 150 writeMakeQmake(t);
153 151
154 t << "qmake_all:"; 152 t << "qmake_all:";
155 if ( !subdirs.isEmpty() ) { 153 if ( !subdirs.isEmpty() ) {
156 for( it.toFirst(); it.current(); ++it) { 154 for( it.toFirst(); it.current(); ++it) {
157 QString subdir = (*it)->directory; 155 QString subdir = (*it)->directory;
156 QString profile = (*it)->profile;
158 int subLevels = subdir.contains(Option::dir_sep) + 1; 157 int subLevels = subdir.contains(Option::dir_sep) + 1;
159 t << "\n\t" 158 t << "\n\t"
160 << "cd " << subdir << "\n\t"; 159 << "cd " << subdir << "\n\t";
161 int lastSlash = subdir.findRev(Option::dir_sep); 160 int lastSlash = subdir.findRev(Option::dir_sep);
162 if(lastSlash != -1) 161 if(lastSlash != -1)
163 subdir = subdir.mid( lastSlash + 1 ); 162 subdir = subdir.mid( lastSlash + 1 );
164 t << "$(QMAKE) " << subdir << ".pro" 163 t << "$(QMAKE) "
165 << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString("")) 164 << ( !profile.isEmpty() ? profile : subdir + ".pro" )
165 << " -o " << (*it)->makefile
166 << " " << buildArgs() << "\n\t" 166 << " " << buildArgs() << "\n\t"
167 << "@cd .."; 167 << "@cd ..";
168 for(int i = 1; i < subLevels; i++ ) 168 for(int i = 1; i < subLevels; i++ )
169 t << Option::dir_sep << ".."; 169 t << Option::dir_sep << "..";
170 } 170 }
171 } else { 171 } else {
172 // Borland make does not like empty an empty command section, so insert 172 // Borland make does not like empty an empty command section, so insert
173 // a dummy command. 173 // a dummy command.
174 t << "\n\t" << "@cd ."; 174 t << "\n\t" << "@cd .";
175 } 175 }
176 t << endl << endl; 176 t << endl << endl;
177 177
178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null }; 178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null };
179 for(int x = 0; targs[x] != QString::null; x++) { 179 for(int x = 0; targs[x] != QString::null; x++) {
180 t << targs[x] << ": qmake_all"; 180 t << targs[x] << ": qmake_all";
181 if(targs[x] == "clean") 181 if(targs[x] == "clean")
182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", ""); 182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", "");
183 if (!subdirs.isEmpty()) { 183 if (!subdirs.isEmpty()) {
184 for( it.toFirst(); it.current(); ++it) { 184 for( it.toFirst(); it.current(); ++it) {
185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; 185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;
186 bool have_dir = !(*it)->directory.isEmpty(); 186 bool have_dir = !(*it)->directory.isEmpty();
187 if(have_dir) 187 if(have_dir)
188 t << "\n\t" << "cd " << (*it)->directory; 188 t << "\n\t" << "cd " << (*it)->directory;
189 QString in_file; 189 QString in_file = " -f " + (*it)->makefile;
190 if((*it)->makefile != "$(MAKEFILE)")
191 in_file = " -f " + (*it)->makefile;
192 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x]; 190 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x];
193 if(have_dir) { 191 if(have_dir) {
194 t << "\n\t" << "@cd .."; 192 t << "\n\t" << "@cd ..";
195 for(int i = 1; i < subLevels; i++ ) 193 for(int i = 1; i < subLevels; i++ )
196 t << Option::dir_sep << ".."; 194 t << Option::dir_sep << "..";
197 } 195 }
198 } 196 }
199 } else { 197 } else {
200 // Borland make does not like empty an empty command section, so 198 // Borland make does not like empty an empty command section, so
201 // insert a dummy command. 199 // insert a dummy command.
202 t << "\n\t" << "@cd ."; 200 t << "\n\t" << "@cd .";
203 } 201 }
204 t << endl << endl; 202 t << endl << endl;
205 } 203 }
206 204
207 if(project->variables()["QMAKE_NOFORCE"].isEmpty()) 205 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
208 t << "FORCE:" << endl << endl; 206 t << "FORCE:" << endl << endl;
209} 207}
210 208
211 209
212int 210int
213Win32MakefileGenerator::findHighestVersion(const QString &d, const 211Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem)
214 QString &stem)
215{ 212{
216 if(!QFile::exists(Option::fixPathToLocalOS(d))) 213 QString bd = Option::fixPathToLocalOS(d, TRUE);
214 if(!QFile::exists(bd))
217 return -1; 215 return -1;
218 if(!project->variables()["QMAKE_" + stem.upper() + 216 if(!project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].isEmpty())
219 "_VERSION_OVERRIDE"].isEmpty()) 217 return project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].first().toInt();
220 return project->variables()["QMAKE_" + stem.upper() + 218
221 "_VERSION_OVERRIDE"].first().toInt();
222 QString bd = d;
223 fixEnvVariables(bd);
224 QDir dir(bd); 219 QDir dir(bd);
225 int biggest=-1; 220 int biggest=-1;
226 QStringList entries = dir.entryList(); 221 QStringList entries = dir.entryList();
227 QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE ); 222 QString dllStem = stem + QTDLL_POSTFIX;
228 for(QStringList::Iterator it = entries.begin(); it != entries.end(); 223 QRegExp regx( "(" + dllStem + "([0-9]*)).lib", FALSE );
229 ++it) { 224 for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
230 if(regx.exactMatch((*it))) 225 if(regx.exactMatch((*it)))
231 biggest = QMAX(biggest, (regx.cap(1) == stem || 226 biggest = QMAX(biggest, (regx.cap(1) == dllStem ||
232 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); 227 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
228 }
229 if(dir.exists(dllStem + Option::prl_ext)) {
230 QMakeProject proj;
231 if(proj.read(bd + dllStem + Option::prl_ext, QDir::currentDirPath(), TRUE)) {
232 if(!proj.isEmpty("QMAKE_PRL_VERSION"))
233 biggest = QMAX(biggest, proj.first("QMAKE_PRL_VERSION").replace(".", "").toInt());
234 }
233 } 235 }
234 return biggest; 236 return biggest;
235} 237}
236 238
237 239
238bool 240bool
239Win32MakefileGenerator::findLibraries(const QString &where) 241Win32MakefileGenerator::findLibraries(const QString &where)
240{ 242{
241 243
242 QStringList &l = project->variables()[where]; 244 QStringList &l = project->variables()[where];
243 QPtrList<MakefileDependDir> dirs; 245 QPtrList<MakefileDependDir> dirs;
246 {
247 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
248 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
249 QString r = (*libpathit), l = r;
250 fixEnvVariables(l);
251 dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"","")));
252 }
253 }
244 dirs.setAutoDelete(TRUE); 254 dirs.setAutoDelete(TRUE);
245 for(QStringList::Iterator it = l.begin(); it != l.end(); ) { 255 for(QStringList::Iterator it = l.begin(); it != l.end(); ) {
246 QString opt = (*it); 256 QChar quote;
247 bool remove = FALSE; 257 bool modified_opt = FALSE, remove = FALSE;
248 if(opt.startsWith("-L") || opt.startsWith("/L")) { 258 QString opt = (*it).stripWhiteSpace();
249 QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r); 259 if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) {
260 quote = opt[0];
261 opt = opt.mid(1, opt.length()-2);
262 }
263 if(opt.startsWith("/LIBPATH:")) {
264 QString r = opt.mid(9), l = Option::fixPathToLocalOS(r);
265 dirs.append(new MakefileDependDir(r.replace("\"",""),
266 l.replace("\"","")));
267 } else if(opt.startsWith("-L") || opt.startsWith("/L")) {
268 QString r = opt.mid(2), l = Option::fixPathToLocalOS(r);
250 dirs.append(new MakefileDependDir(r.replace("\"",""), 269 dirs.append(new MakefileDependDir(r.replace("\"",""),
251 l.replace("\"",""))); 270 l.replace("\"","")));
252 remove = TRUE; 271 remove = TRUE; //we eat this switch
253 } else if(opt.startsWith("-l") || opt.startsWith("/l")) { 272 } else if(opt.startsWith("-l") || opt.startsWith("/l")) {
254 QString lib = opt.right(opt.length() - 2), out; 273 QString lib = opt.right(opt.length() - 2), out;
255 if(!lib.isEmpty()) { 274 if(!lib.isEmpty()) {
256 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { 275 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
276 QString extension;
257 int ver = findHighestVersion(mdd->local_dir, lib); 277 int ver = findHighestVersion(mdd->local_dir, lib);
258 if(ver > 0) 278 if(ver > 0)
259 lib += QString::number(ver); 279 extension += QString::number(ver);
260 lib += ".lib"; 280 extension += ".lib";
261 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) { 281 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib + Option::prl_ext) ||
262 out = mdd->real_dir + Option::dir_sep + lib; 282 QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) {
283 out = mdd->real_dir + Option::dir_sep + lib + extension;
263 break; 284 break;
264 } 285 }
265 } 286 }
266 } 287 }
267 if(out.isEmpty()) 288 if(out.isEmpty()) {
268 remove = TRUE; 289 remove = TRUE; //just eat it since we cannot find one..
269 else 290 } else {
291 modified_opt = TRUE;
270 (*it) = out; 292 (*it) = out;
293 }
271 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { 294 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) {
272 QString dir, file = opt; 295 QPtrList<MakefileDependDir> lib_dirs;
296 QString file = opt;
273 int slsh = file.findRev(Option::dir_sep); 297 int slsh = file.findRev(Option::dir_sep);
274 if(slsh != -1) { 298 if(slsh != -1) {
275 dir = file.left(slsh+1); 299 QString r = file.left(slsh+1), l = r;
300 fixEnvVariables(l);
301 lib_dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"","")));
276 file = file.right(file.length() - slsh - 1); 302 file = file.right(file.length() - slsh - 1);
277 } 303 } else {
278 if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) { 304 lib_dirs = dirs;
279 if(file.endsWith(".lib")) { 305 }
280 file = file.left(file.length() - 4); 306 if(file.endsWith(".lib")) {
281 if(!file.at(file.length()-1).isNumber()) { 307 file = file.left(file.length() - 4);
282 int ver = findHighestVersion(dir, file); 308 if(!file.at(file.length()-1).isNumber()) {
309 for(MakefileDependDir *mdd = lib_dirs.first(); mdd; mdd = lib_dirs.next() ) {
310 QString lib_tmpl(file + "%1" + ".lib");
311 int ver = findHighestVersion(mdd->local_dir, file);
283 if(ver != -1) { 312 if(ver != -1) {
284 file = QString(dir + file + "%1" + ".lib");
285 if(ver) 313 if(ver)
286 (*it) = file.arg(ver); 314 lib_tmpl = lib_tmpl.arg(ver);
287 else 315 else
288 (*it) = file.arg(""); 316 lib_tmpl = lib_tmpl.arg("");
317 if(slsh != -1) {
318 QString dir = mdd->real_dir;
319 if(!dir.endsWith(Option::dir_sep))
320 dir += Option::dir_sep;
321 lib_tmpl.prepend(dir);
322 }
323 modified_opt = TRUE;
324 (*it) = lib_tmpl;
325 break;
289 } 326 }
290 } 327 }
291 } 328 }
292 } 329 }
293 } 330 }
294 if(remove) 331 if(remove) {
295 it = l.remove(it); 332 it = l.remove(it);
296 else 333 } else {
334 if(!quote.isNull() && modified_opt)
335 (*it) = quote + (*it) + quote;
297 ++it; 336 ++it;
337 }
298 } 338 }
299 return TRUE; 339 return TRUE;
300} 340}
301 341
302void 342void
303Win32MakefileGenerator::processPrlFiles() 343Win32MakefileGenerator::processPrlFiles()
304{ 344{
305 QDict<void> processed; 345 QDict<void> processed;
306 QPtrList<MakefileDependDir> libdirs; 346 QPtrList<MakefileDependDir> libdirs;
307 libdirs.setAutoDelete(TRUE); 347 libdirs.setAutoDelete(TRUE);
308 { 348 {
309 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; 349 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
310 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { 350 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
311 QString r = (*libpathit), l = r; 351 QString r = (*libpathit), l = r;
312 fixEnvVariables(l); 352 fixEnvVariables(l);
313 libdirs.append(new MakefileDependDir(r.replace("\"",""), 353 libdirs.append(new MakefileDependDir(r.replace("\"",""),
314 l.replace("\"",""))); 354 l.replace("\"","")));
315 } 355 }
316 } 356 }
317 for(bool ret = FALSE; TRUE; ret = FALSE) { 357 for(bool ret = FALSE; TRUE; ret = FALSE) {
318 //read in any prl files included.. 358 //read in any prl files included..
319 QStringList l_out; 359 QStringList l_out;
320 QString where = "QMAKE_LIBS"; 360 QString where = "QMAKE_LIBS";
321 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 361 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
322 where = project->first("QMAKE_INTERNAL_PRL_LIBS"); 362 where = project->first("QMAKE_INTERNAL_PRL_LIBS");
323 QStringList &l = project->variables()[where]; 363 QStringList &l = project->variables()[where];
324 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 364 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
325 QString opt = (*it); 365 QString opt = (*it);
326 if(opt.left(1) == "/") { 366 if(opt.startsWith("/")) {
327 if(opt.left(9) == "/LIBPATH:") { 367 if(opt.startsWith("/LIBPATH:")) {
328 QString r = opt.mid(9), l = r; 368 QString r = opt.mid(9), l = r;
329 fixEnvVariables(l); 369 fixEnvVariables(l);
330 libdirs.append(new MakefileDependDir(r.replace("\"",""), 370 libdirs.append(new MakefileDependDir(r.replace("\"",""),
331 l.replace("\"",""))); 371 l.replace("\"","")));
332 } 372 }
333 } else { 373 } else {
334 if(!processed[opt]) { 374 if(!processed[opt]) {
335 if(processPrlFile(opt)) { 375 if(processPrlFile(opt)) {
336 processed.insert(opt, (void*)1); 376 processed.insert(opt, (void*)1);
337 ret = TRUE; 377 ret = TRUE;
338 } else { 378 } else {
339 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { 379 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
340 QString prl = mdd->local_dir + Option::dir_sep + opt; 380 QString prl = mdd->local_dir + Option::dir_sep + opt;
341 if(processed[prl]) { 381 if(processed[prl]) {
342 break; 382 break;
343 } else if(processPrlFile(prl)) { 383 } else if(processPrlFile(prl)) {
344 processed.insert(prl, (void*)1); 384 processed.insert(prl, (void*)1);
345 ret = TRUE; 385 ret = TRUE;
346 break; 386 break;
347 } 387 }
348 } 388 }
349 } 389 }
350 } 390 }
351 } 391 }
diff --git a/qmake/include/private/qapplication_p.h b/qmake/include/private/qapplication_p.h
index 6fab6b3..280992e 100644
--- a/qmake/include/private/qapplication_p.h
+++ b/qmake/include/private/qapplication_p.h
@@ -52,36 +52,37 @@
52// 52//
53// 53//
54 54
55#ifndef QT_H 55#ifndef QT_H
56#endif // QT_H 56#endif // QT_H
57 57
58class QWidget; 58class QWidget;
59class QObject; 59class QObject;
60class QClipboard; 60class QClipboard;
61class QKeyEvent; 61class QKeyEvent;
62class QMouseEvent; 62class QMouseEvent;
63class QWheelEvent; 63class QWheelEvent;
64 64
65extern Q_EXPORT bool qt_modal_state(); 65extern Q_EXPORT bool qt_modal_state();
66extern Q_EXPORT void qt_enter_modal( QWidget* ); 66extern Q_EXPORT void qt_enter_modal( QWidget* );
67extern Q_EXPORT void qt_leave_modal( QWidget* ); 67extern Q_EXPORT void qt_leave_modal( QWidget* );
68 68
69extern bool qt_is_gui_used; 69extern bool qt_is_gui_used;
70#ifndef QT_NO_CLIPBOARD 70#ifndef QT_NO_CLIPBOARD
71extern QClipboard *qt_clipboard; 71extern QClipboard *qt_clipboard;
72#endif 72#endif
73 73
74#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) 74#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN)
75extern Qt::WindowsVersion qt_winver; 75extern Qt::WindowsVersion qt_winver;
76#elif defined (Q_OS_MAC)
77extern Qt::MacintoshVersion qt_macver;
76#endif 78#endif
77 79
78#if defined (Q_WS_X11) 80#if defined (Q_WS_X11)
79extern int qt_ncols_option; 81extern int qt_ncols_option;
80#endif 82#endif
81 83
82 84
83extern void qt_dispatchEnterLeave( QWidget*, QWidget* ); 85extern void qt_dispatchEnterLeave( QWidget*, QWidget* );
84 86extern bool qt_tryModalHelper( QWidget *, QWidget ** = 0 );
85
86 87
87#endif 88#endif
diff --git a/qmake/include/private/qcom_p.h b/qmake/include/private/qcom_p.h
index 6e7e1c8..5bed8c8c 100644
--- a/qmake/include/private/qcom_p.h
+++ b/qmake/include/private/qcom_p.h
@@ -12,50 +12,50 @@
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QCOM_H 36#ifndef QCOM_P_H
37#define QCOM_H 37#define QCOM_P_H
38 38
39// 39//
40// W A R N I N G 40// W A R N I N G
41// ------------- 41// -------------
42// 42//
43// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
44// of a number of Qt sources files. This header file may change from 44// of a number of Qt sources files. This header file may change from
45// version to version without notice, or even be removed. 45// version to version without notice, or even be removed.
46// 46//
47// We mean it. 47// We mean it.
48// 48//
49// 49//
50 50
51#ifndef QT_H 51#ifndef QT_H
52#include "qstringlist.h" 52#include "qstringlist.h"
53#include "quuid.h" 53#include "quuid.h"
54#endif // QT_H 54#endif // QT_H
55 55
56#ifndef QT_NO_COMPONENT 56#ifndef QT_NO_COMPONENT
57 57
58class QObject; 58class QObject;
59struct QUInterfaceDescription; 59struct QUInterfaceDescription;
60struct QUObject; 60struct QUObject;
61 61
@@ -313,25 +313,25 @@ public: \
313 { return qt_ucm_verification_data; } \ 313 { return qt_ucm_verification_data; } \
314 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* \ 314 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* \
315 __stdcall ucm_instantiate() 315 __stdcall ucm_instantiate()
316 #else 316 #else
317 # define Q_EXPORT_COMPONENT() \ 317 # define Q_EXPORT_COMPONENT() \
318 Q_UCM_VERIFICATION_DATA \ 318 Q_UCM_VERIFICATION_DATA \
319 Q_EXTERN_C __declspec(dllexport) \ 319 Q_EXTERN_C __declspec(dllexport) \
320 const char *qt_ucm_query_verification_data() \ 320 const char *qt_ucm_query_verification_data() \
321 { return qt_ucm_verification_data; } \ 321 { return qt_ucm_verification_data; } \
322 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* ucm_instantiate() 322 Q_EXTERN_C __declspec(dllexport) QUnknownInterface* ucm_instantiate()
323 #endif 323 #endif
324# else 324# else
325 #define Q_EXPORT_COMPONENT() \ 325 #define Q_EXPORT_COMPONENT() \
326 Q_UCM_VERIFICATION_DATA \ 326 Q_UCM_VERIFICATION_DATA \
327 Q_EXTERN_C \ 327 Q_EXTERN_C \
328 const char *qt_ucm_query_verification_data() \ 328 const char *qt_ucm_query_verification_data() \
329 { return qt_ucm_verification_data; } \ 329 { return qt_ucm_verification_data; } \
330 Q_EXTERN_C QUnknownInterface* ucm_instantiate() 330 Q_EXTERN_C QUnknownInterface* ucm_instantiate()
331# endif 331# endif
332# define Q_EXPORT_INTERFACE() Q_EXPORT_COMPONENT() 332# define Q_EXPORT_INTERFACE() Q_EXPORT_COMPONENT()
333#endif 333#endif
334 334
335#endif //QT_NO_COMPONENT 335#endif //QT_NO_COMPONENT
336 336
337#endif //QCOM_H 337#endif //QCOM_P_H
diff --git a/qmake/include/private/qcomlibrary_p.h b/qmake/include/private/qcomlibrary_p.h
index f52f679..3f440c0 100644
--- a/qmake/include/private/qcomlibrary_p.h
+++ b/qmake/include/private/qcomlibrary_p.h
@@ -12,68 +12,68 @@
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QUCOMLIBRARY_H 36#ifndef QCOMLIBRARY_P_H
37#define QUCOMLIBRARY_H 37#define QCOMLIBRARY_P_H
38 38
39// 39//
40// W A R N I N G 40// W A R N I N G
41// ------------- 41// -------------
42// 42//
43// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
44// of a number of Qt sources files. This header file may change from 44// of a number of Qt sources files. This header file may change from
45// version to version without notice, or even be removed. 45// version to version without notice, or even be removed.
46// 46//
47// We mean it. 47// We mean it.
48// 48//
49// 49//
50 50
51#ifndef QT_H 51#ifndef QT_H
52#include "qcom_p.h" 52#include "qcom_p.h"
53#include "qlibrary.h" 53#include "qlibrary.h"
54#endif // QT_H 54#endif // QT_H
55 55
56#ifndef QT_NO_COMPONENT 56#ifndef QT_NO_COMPONENT
57 57
58class Q_EXPORT QComLibrary : public QLibrary 58class Q_EXPORT QComLibrary : public QLibrary
59{ 59{
60public: 60public:
61 QComLibrary( const QString &filename ); 61 QComLibrary( const QString &filename );
62 ~QComLibrary(); 62 ~QComLibrary();
63 63
64 bool unload(); 64 bool unload();
65 QRESULT queryInterface( const QUuid &iid, QUnknownInterface **iface ); 65 QRESULT queryInterface( const QUuid &iid, QUnknownInterface **iface );
66 uint qtVersion(); 66 uint qtVersion();
67 67
68private: 68private:
69 void createInstanceInternal(); 69 void createInstanceInternal();
70 70
71 QUnknownInterface *entry; 71 QUnknownInterface *entry;
72 QLibraryInterface *libiface; 72 QLibraryInterface *libiface;
73 uint qt_version; 73 uint qt_version;
74 74
75}; 75};
76 76
77#endif //QT_NO_COMPONENT 77#endif //QT_NO_COMPONENT
78 78
79#endif // QUCOMLIBRARY_H 79#endif
diff --git a/qmake/include/private/qcomplextext_p.h b/qmake/include/private/qcomplextext_p.h
index 2132522..c3aeeb1 100644
--- a/qmake/include/private/qcomplextext_p.h
+++ b/qmake/include/private/qcomplextext_p.h
@@ -1,63 +1,61 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Internal header file. 4** Internal header file.
5** 5**
6** Created : 6** Copyright (C) 2001-2002 Trolltech AS. All rights reserved.
7**
8** Copyright (C) 2001 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the kernel module of the Qt GUI Toolkit. 8** This file is part of the kernel module of the Qt GUI Toolkit.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
15** 13**
16** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 17** packaging of this file.
20** 18**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 21** Agreement provided with the Software.
24** 22**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 25**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 30**
33** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 32** not clear to you.
35** 33**
36**********************************************************************/ 34**********************************************************************/
37 35
38#ifndef QCOMPLEXTEXT_H 36#ifndef QCOMPLEXTEXT_P_H
39#define QCOMPLEXTEXT_H 37#define QCOMPLEXTEXT_P_H
40 38
41// 39//
42// W A R N I N G 40// W A R N I N G
43// ------------- 41// -------------
44// 42//
45// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
46// of Qt Remote Control. This header file may change from version to 44// of Qt Remote Control. This header file may change from version to
47// version without notice, or even be removed. 45// version without notice, or even be removed.
48// 46//
49// We mean it. 47// We mean it.
50// 48//
51// 49//
52 50
53#ifndef QT_H 51#ifndef QT_H
54#include <qstring.h> 52#include <qstring.h>
55#include <qpointarray.h> 53#include <qpointarray.h>
56#include <qfont.h> 54#include <qfont.h>
57#include <qpainter.h> 55#include <qpainter.h>
58#include <qptrlist.h> 56#include <qptrlist.h>
59#include <qshared.h> 57#include <qshared.h>
60#endif // QT_H 58#endif // QT_H
61 59
62#ifndef QT_NO_COMPLEXTEXT 60#ifndef QT_NO_COMPLEXTEXT
63 61
diff --git a/qmake/include/private/qcomponentfactory_p.h b/qmake/include/private/qcomponentfactory_p.h
index 1ac973f..d5c1743 100644
--- a/qmake/include/private/qcomponentfactory_p.h
+++ b/qmake/include/private/qcomponentfactory_p.h
@@ -14,60 +14,60 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QCOMPONENTFACTORY_H 38#ifndef QCOMPONENTFACTORY_P_H
39#define QCOMPONENTFACTORY_H 39#define QCOMPONENTFACTORY_P_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include "qcom_p.h" 42#include "qcom_p.h"
43#endif // QT_H 43#endif // QT_H
44 44
45// 45//
46// W A R N I N G 46// W A R N I N G
47// ------------- 47// -------------
48// 48//
49// This file is not part of the Qt API. It exists for the convenience 49// This file is not part of the Qt API. It exists for the convenience
50// of a number of Qt sources files. This header file may change from 50// of a number of Qt sources files. This header file may change from
51// version to version without notice, or even be removed. 51// version to version without notice, or even be removed.
52// 52//
53// We mean it. 53// We mean it.
54// 54//
55// 55//
56 56
57#ifndef QT_NO_COMPONENT 57#ifndef QT_NO_COMPONENT
58 58
59class Q_EXPORT QComponentFactory 59class Q_EXPORT QComponentFactory
60{ 60{
61public: 61public:
62 static QRESULT createInstance( const QString &cid, const QUuid &iid, QUnknownInterface** instance, QUnknownInterface *outer = 0 ); 62 static QRESULT createInstance( const QString &cid, const QUuid &iid, QUnknownInterface** instance, QUnknownInterface *outer = 0 );
63 static QRESULT registerServer( const QString &filename ); 63 static QRESULT registerServer( const QString &filename );
64 static QRESULT unregisterServer( const QString &filename ); 64 static QRESULT unregisterServer( const QString &filename );
65 65
66 static bool registerComponent( const QUuid &cid, const QString &filename, const QString &name = QString::null, 66 static bool registerComponent( const QUuid &cid, const QString &filename, const QString &name = QString::null,
67 int version = 0, const QString &description = QString::null ); 67 int version = 0, const QString &description = QString::null );
68 static bool unregisterComponent( const QUuid &cid ); 68 static bool unregisterComponent( const QUuid &cid );
69}; 69};
70 70
71#endif // QT_NO_COMPONENT 71#endif // QT_NO_COMPONENT
72 72
73#endif // QCOMPONENTFACTORY_H 73#endif // QCOMPONENTFACTORY_P_H
diff --git a/qmake/include/private/qcriticalsection_p.h b/qmake/include/private/qcriticalsection_p.h
index 7d9feca..8dacc62 100644
--- a/qmake/include/private/qcriticalsection_p.h
+++ b/qmake/include/private/qcriticalsection_p.h
@@ -12,50 +12,50 @@
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QCRITICALSECTION_H 36#ifndef QCRITICALSECTION_P_H
37#define QCRITICALSECTION_H 37#define QCRITICALSECTION_P_H
38 38
39#ifndef QT_H 39#ifndef QT_H
40#endif // QT_H 40#endif // QT_H
41 41
42// 42//
43// W A R N I N G 43// W A R N I N G
44// ------------- 44// -------------
45// 45//
46// This file is not part of the Qt API. It exists for the convenience 46// This file is not part of the Qt API. It exists for the convenience
47// of Qt Remote Control. This header file may change from version to 47// of Qt Remote Control. This header file may change from version to
48// version without notice, or even be removed. 48// version without notice, or even be removed.
49// 49//
50// We mean it. 50// We mean it.
51// 51//
52// 52//
53 53
54#if defined(QT_THREAD_SUPPORT) 54#if defined(QT_THREAD_SUPPORT)
55 55
56#if defined(Q_WS_WIN) 56#if defined(Q_WS_WIN)
57 57
58/* 58/*
59 QCriticalSection 59 QCriticalSection
60*/ 60*/
61 61
diff --git a/qmake/include/private/qdir_p.h b/qmake/include/private/qdir_p.h
index 35dba28..a6c7c91 100644
--- a/qmake/include/private/qdir_p.h
+++ b/qmake/include/private/qdir_p.h
@@ -1,78 +1,79 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of some private QDir functions. 4** Definition of some private QDir functions.
5** 5**
6** Created : 2000.11.06 6** Created : 001106
7** 7**
8** Copyright (C) 2000 Trolltech AS. All rights reserved. 8** Copyright (C) 2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QDIR_P_H 38#ifndef QDIR_P_H
39#define QDIR_P_H 39#define QDIR_P_H
40 40
41
42// 41//
43// W A R N I N G 42// W A R N I N G
44// ------------- 43// -------------
45// 44//
46// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
47// of qdir.cpp and qdir_*.cpp. 46// of qdir.cpp and qdir_*.cpp.
48// This header file may change from version to version without notice, 47// This header file may change from version to version without notice,
49// or even be removed. 48// or even be removed.
50// 49//
51// We mean it. 50// We mean it.
52// 51//
53// 52//
54 53
55#ifndef QT_H 54#ifndef QT_H
55#include "qregexp.h"
56#include "qvaluelist.h"
56#endif // QT_H 57#endif // QT_H
57 58
58extern QStringList qt_makeFilterList( const QString & ); 59extern QValueList<QRegExp> qt_makeFilterList( const QString & );
59 60extern bool qt_matchFilterList( const QValueList<QRegExp> &, const QString & );
60 61
61extern int qt_cmp_si_sortSpec; 62extern int qt_cmp_si_sortSpec;
62 63
63#if defined(Q_C_CALLBACKS) 64#if defined(Q_C_CALLBACKS)
64extern "C" { 65extern "C" {
65#endif 66#endif
66 67
67#ifdef Q_OS_TEMP 68#ifdef Q_OS_TEMP
68extern int __cdecl qt_cmp_si( const void *, const void * ); 69extern int __cdecl qt_cmp_si( const void *, const void * );
69#else 70#else
70extern int qt_cmp_si( const void *, const void * ); 71extern int qt_cmp_si( const void *, const void * );
71#endif 72#endif
72 73
73#if defined(Q_C_CALLBACKS) 74#if defined(Q_C_CALLBACKS)
74} 75}
75#endif 76#endif
76 77
77 78
78#endif // QDIR_P_H 79#endif // QDIR_P_H
diff --git a/qmake/include/private/qeffects_p.h b/qmake/include/private/qeffects_p.h
index 4178b6f..3b6c212 100644
--- a/qmake/include/private/qeffects_p.h
+++ b/qmake/include/private/qeffects_p.h
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QEffects functions 4** Definition of QEffects functions
5** 5**
6** Created : 2000.06.21 6** Created : 000621
7** 7**
8** Copyright (C) 2000 Trolltech AS. All rights reserved. 8** Copyright (C) 2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the widgets module of the Qt GUI Toolkit. 10** This file is part of the widgets module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
diff --git a/qmake/include/private/qeventloop_p.h b/qmake/include/private/qeventloop_p.h
index b64d0df..3a5350e 100644
--- a/qmake/include/private/qeventloop_p.h
+++ b/qmake/include/private/qeventloop_p.h
@@ -1,74 +1,138 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of QEventLoop class
5**
6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of the kernel module of the Qt GUI Toolkit.
9**
10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
15** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
16** licenses for Qt/Embedded may use this file in accordance with the
17** Qt Embedded Commercial License Agreement provided with the Software.
18**
19** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21**
22** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
23** information about Qt Commercial License Agreements.
24** See http://www.trolltech.com/gpl/ for GPL licensing information.
25**
26** Contact info@trolltech.com if any conditions of this licensing are
27** not clear to you.
28**
29**********************************************************************/
30
1#ifndef QEVENTLOOP_P_H 31#ifndef QEVENTLOOP_P_H
2#define QEVENTLOOP_P_H 32#define QEVENTLOOP_P_H
3 33
34//
35// W A R N I N G
36// -------------
37//
38// This file is not part of the Qt API. This header file may
39// change from version to version without notice, or even be
40// removed.
41//
42// We mean it.
43//
44//
45
4#include "qplatformdefs.h" 46#include "qplatformdefs.h"
47
48// SCO OpenServer redefines raise -> kill
49#if defined(raise)
50# undef raise
51#endif
52
5#include "qwindowdefs.h" 53#include "qwindowdefs.h"
6 54
7class QSocketNotifier; 55class QSocketNotifier;
8 56
9#if defined(Q_OS_UNIX) 57#if defined(Q_OS_UNIX) || defined (Q_WS_WIN)
10#include <qptrlist.h> 58#include <qptrlist.h>
59#endif // Q_OS_UNIX || Q_WS_WIN
11 60
61#if defined(Q_OS_UNIX)
12struct QSockNot 62struct QSockNot
13{ 63{
14 QSocketNotifier *obj; 64 QSocketNotifier *obj;
15 int fd; 65 int fd;
16 fd_set *queue; 66 fd_set *queue;
17}; 67};
18 68
19class QSockNotType 69class QSockNotType
20{ 70{
21public: 71public:
22 QSockNotType(); 72 QSockNotType();
23 ~QSockNotType(); 73 ~QSockNotType();
24 74
25 QPtrList<QSockNot> *list; 75 QPtrList<QSockNot> *list;
26 fd_set select_fds; 76 fd_set select_fds;
27 fd_set enabled_fds; 77 fd_set enabled_fds;
28 fd_set pending_fds; 78 fd_set pending_fds;
29 79
30}; 80};
31#endif // Q_OS_UNIX 81#endif // Q_OS_UNIX
32 82
83#if defined(Q_WS_WIN)
84struct QSockNot {
85 QSocketNotifier *obj;
86 int fd;
87};
88#endif // Q_WS_WIN
33 89
34class QEventLoopPrivate 90class QEventLoopPrivate
35{ 91{
36public: 92public:
37 QEventLoopPrivate() 93 QEventLoopPrivate()
38 { 94 {
39 reset(); 95 reset();
40 } 96 }
41 97
42 void reset() { 98 void reset() {
43 looplevel = 0; 99 looplevel = 0;
44 quitcode = 0; 100 quitcode = 0;
45 quitnow = FALSE; 101 quitnow = FALSE;
46 exitloop = FALSE; 102 exitloop = FALSE;
103 shortcut = FALSE;
47 } 104 }
48 105
49 int looplevel; 106 int looplevel;
50 int quitcode; 107 int quitcode;
51 bool quitnow; 108 unsigned int quitnow : 1;
52 bool exitloop; 109 unsigned int exitloop : 1;
110 unsigned int shortcut : 1;
53 111
54#if defined(Q_WS_MAC) 112#if defined(Q_WS_MAC)
55 EventLoopTimerRef select_timer; 113 EventLoopTimerRef select_timer;
56#endif 114#endif
57 115
58#if defined(Q_WS_X11) 116#if defined(Q_WS_X11)
59 int xfd; 117 int xfd;
60#endif // Q_WS_X11 118#endif // Q_WS_X11
61 119
62#if defined(Q_OS_UNIX) 120#if defined(Q_OS_UNIX)
63 int thread_pipe[2]; 121 int thread_pipe[2];
64 122
65 // pending socket notifiers list 123 // pending socket notifiers list
66 QPtrList<QSockNot> sn_pending_list; 124 QPtrList<QSockNot> sn_pending_list;
67 // highest fd for all socket notifiers 125 // highest fd for all socket notifiers
68 int sn_highest; 126 int sn_highest;
69 // 3 socket notifier types - read, write and exception 127 // 3 socket notifier types - read, write and exception
70 QSockNotType sn_vec[3]; 128 QSockNotType sn_vec[3];
71#endif 129#endif
130
131#ifdef Q_WS_WIN
132 // pending socket notifiers list
133 QPtrList<QSockNot> sn_pending_list;
134#endif // Q_WS_WIN
135
72}; 136};
73 137
74#endif // QEVENTLOOP_P_H 138#endif // QEVENTLOOP_P_H
diff --git a/qmake/include/private/qfontcodecs_p.h b/qmake/include/private/qfontcodecs_p.h
index 8222f98..54b0ac1 100644
--- a/qmake/include/private/qfontcodecs_p.h
+++ b/qmake/include/private/qfontcodecs_p.h
@@ -30,50 +30,50 @@
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QFONTCODECS_P_H 38#ifndef QFONTCODECS_P_H
39#define QFONTCODECS_P_H 39#define QFONTCODECS_P_H
40 40
41// 41//
42// W A R N I N G 42// W A R N I N G
43// ------------- 43// -------------
44// 44//
45// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
46// of qfontencodings_x11.cpp and qfont_x11.cpp. This header file may 46// of qfontencodings_x11.cpp and qfont_x11.cpp. This header file may
47// change from version to version without notice, or even be removed. 47// change from version to version without notice, or even be removed.
48// 48//
49// We mean it. 49// We mean it.
50// 50//
51// 51//
52 52
53#ifndef QT_H 53#ifndef QT_H
54#include <qglobal.h> 54#include "qglobal.h"
55#include <qtextcodec.h> 55#include "qtextcodec.h"
56#endif // QT_H 56#endif // QT_H
57 57
58 58
59#ifndef QT_NO_CODECS 59#ifndef QT_NO_CODECS
60#ifndef QT_NO_BIG_CODECS 60#ifndef QT_NO_BIG_CODECS
61 61
62 62
63class QJpUnicodeConv; 63class QJpUnicodeConv;
64 64
65 65
66class QFontJis0201Codec : public QTextCodec 66class QFontJis0201Codec : public QTextCodec
67{ 67{
68public: 68public:
69 QFontJis0201Codec(); 69 QFontJis0201Codec();
70 70
71 const char *name() const; 71 const char *name() const;
72 72
73 int mibEnum() const; 73 int mibEnum() const;
74 74
75#if !defined(Q_NO_USING_KEYWORD) 75#if !defined(Q_NO_USING_KEYWORD)
76 using QTextCodec::fromUnicode; 76 using QTextCodec::fromUnicode;
77#endif 77#endif
78 QCString fromUnicode(const QString& uc, int& lenInOut ) const; 78 QCString fromUnicode(const QString& uc, int& lenInOut ) const;
79 79
diff --git a/qmake/include/private/qfontdata_p.h b/qmake/include/private/qfontdata_p.h
index 917d14f..1eaf80c 100644
--- a/qmake/include/private/qfontdata_p.h
+++ b/qmake/include/private/qfontdata_p.h
@@ -141,48 +141,49 @@ public:
141 141
142#endif // Q_WS_X11 142#endif // Q_WS_X11
143 143
144 144
145#ifdef Q_WS_WIN 145#ifdef Q_WS_WIN
146 146
147class QFontStruct : public QShared 147class QFontStruct : public QShared
148{ 148{
149public: 149public:
150 QFontStruct( const QString &key ); 150 QFontStruct( const QString &key );
151 ~QFontStruct() { reset(); } 151 ~QFontStruct() { reset(); }
152 bool dirty() const { return hfont == 0; } 152 bool dirty() const { return hfont == 0; }
153 HDC dc() const; 153 HDC dc() const;
154 HFONT font() const { return hfont; } 154 HFONT font() const { return hfont; }
155 const TEXTMETRICA *textMetricA() const { return &tm.a; } 155 const TEXTMETRICA *textMetricA() const { return &tm.a; }
156 const TEXTMETRICW *textMetricW() const { return &tm.w; } 156 const TEXTMETRICW *textMetricW() const { return &tm.w; }
157 QString key() const { return k; } 157 QString key() const { return k; }
158 void reset(); 158 void reset();
159 159
160 QStringk; 160 QStringk;
161 HDC hdc; 161 HDC hdc;
162 HFONThfont; 162 HFONThfont;
163 uintstockFont:1; 163 uintstockFont:1;
164 uintpaintDevice:1; 164 uintpaintDevice:1;
165 uint useTextOutA:1;
165 union { 166 union {
166 TEXTMETRICWw; 167 TEXTMETRICWw;
167 TEXTMETRICAa; 168 TEXTMETRICAa;
168 } tm; 169 } tm;
169 int lw; 170 int lw;
170 int cache_cost; 171 int cache_cost;
171// friend void QFont::initFontInfo() const; 172// friend void QFont::initFontInfo() const;
172}; 173};
173 174
174#endif // Q_WS_WIN 175#endif // Q_WS_WIN
175 176
176#if defined( Q_WS_MAC ) 177#if defined( Q_WS_MAC )
177 178
178#if defined( Q_WS_MACX ) 179#if defined( Q_WS_MACX )
179# define QMAC_FONT_ATSUI 180# define QMAC_FONT_ATSUI
180#endif 181#endif
181#include "qt_mac.h" 182#include "qt_mac.h"
182class QMacFontInfo; 183class QMacFontInfo;
183 184
184class QFontStruct : public QShared 185class QFontStruct : public QShared
185{ 186{
186public: 187public:
187 inline QFontStruct() : QShared(), info(NULL), fnum(-1), cache_cost(0), internal_fi(NULL) { } 188 inline QFontStruct() : QShared(), info(NULL), fnum(-1), cache_cost(0), internal_fi(NULL) { }
188#if defined( QMAC_FONT_ATSUI ) && 0 189#if defined( QMAC_FONT_ATSUI ) && 0
@@ -392,49 +393,49 @@ public:
392 int x11Screen; 393 int x11Screen;
393#endif // Q_WS_X11 394#endif // Q_WS_X11
394 395
395 QPaintDevice *paintdevice; 396 QPaintDevice *paintdevice;
396 397
397#ifdef Q_WS_WIN 398#ifdef Q_WS_WIN
398 void load(); 399 void load();
399 void initFontInfo(); 400 void initFontInfo();
400 HFONT create( bool *stockFont, HDC hdc = 0, bool compatMode = FALSE ); 401 HFONT create( bool *stockFont, HDC hdc = 0, bool compatMode = FALSE );
401 QFontStruct *fin; 402 QFontStruct *fin;
402 403
403 void buildCache( HDC hdc, const QString &str, int pos, int len, TextRun *cache ); 404 void buildCache( HDC hdc, const QString &str, int pos, int len, TextRun *cache );
404 void drawText( HDC hdc, int x, int y, TextRun *cache ); 405 void drawText( HDC hdc, int x, int y, TextRun *cache );
405#endif // Q_WS_WIN 406#endif // Q_WS_WIN
406 407
407#ifdef Q_WS_QWS 408#ifdef Q_WS_QWS
408 void load(); 409 void load();
409 QFontStruct *fin; 410 QFontStruct *fin;
410 int textWidth( const QString &str, int pos, int len, TextRun *cache ); 411 int textWidth( const QString &str, int pos, int len, TextRun *cache );
411 void drawText( QGfx *gfx, int x, int y, const TextRun *cache ); 412 void drawText( QGfx *gfx, int x, int y, const TextRun *cache );
412#endif 413#endif
413 414
414#if defined( Q_WS_MAC ) 415#if defined( Q_WS_MAC )
415 void macSetFont(QPaintDevice *); 416 void macSetFont(QPaintDevice *);
416 void drawText(int x, int y, QString s, int len, QPaintDevice *dev, const QRegion *rgn); 417 void drawText(int x, int y, const QString &s, int from, int len, QPaintDevice *dev, const QRegion *rgn, int dir);
417 void computeLineWidth(); 418 void computeLineWidth();
418 void load(); 419 void load();
419 QFontStruct *fin; 420 QFontStruct *fin;
420#endif 421#endif
421 422
422}; 423};
423 424
424inline QFontPrivate::QFontPrivate() 425inline QFontPrivate::QFontPrivate()
425 : QShared(), exactMatch(FALSE), lineWidth(1) 426 : QShared(), exactMatch(FALSE), lineWidth(1)
426{ 427{
427 428
428#if defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_MAC) 429#if defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_MAC)
429 fin = 0; 430 fin = 0;
430#endif // Q_WS_WIN || Q_WS_QWS 431#endif // Q_WS_WIN || Q_WS_QWS
431#if defined(Q_WS_X11) 432#if defined(Q_WS_X11)
432 x11Screen = QPaintDevice::x11AppScreen(); 433 x11Screen = QPaintDevice::x11AppScreen();
433#endif // Q_WS_X11 434#endif // Q_WS_X11
434 paintdevice = 0; 435 paintdevice = 0;
435} 436}
436 437
437inline QFontPrivate::QFontPrivate(const QFontPrivate &fp) 438inline QFontPrivate::QFontPrivate(const QFontPrivate &fp)
438 : QShared(), request(fp.request), actual(fp.actual), 439 : QShared(), request(fp.request), actual(fp.actual),
439exactMatch(fp.exactMatch), lineWidth(1) 440exactMatch(fp.exactMatch), lineWidth(1)
440{ 441{
diff --git a/qmake/include/private/qgfxdriverinterface_p.h b/qmake/include/private/qgfxdriverinterface_p.h
index 1782ed4..e8259ac 100644
--- a/qmake/include/private/qgfxdriverinterface_p.h
+++ b/qmake/include/private/qgfxdriverinterface_p.h
@@ -9,48 +9,60 @@
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed and/or modified under the terms of the 12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software 13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the 14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file. 15** packaging of this file.
16** 16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses for Qt/Embedded may use this file in accordance with the 18** licenses for Qt/Embedded may use this file in accordance with the
19** Qt Embedded Commercial License Agreement provided with the Software. 19** Qt Embedded Commercial License Agreement provided with the Software.
20** 20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23** 23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements. 25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/gpl/ for GPL licensing information. 26** See http://www.trolltech.com/gpl/ for GPL licensing information.
27** 27**
28** Contact info@trolltech.com if any conditions of this licensing are 28** Contact info@trolltech.com if any conditions of this licensing are
29** not clear to you. 29** not clear to you.
30** 30**
31**********************************************************************/ 31**********************************************************************/
32 32
33#ifndef QGFXDRIVERINTERFACE_H 33#ifndef QGFXDRIVERINTERFACE_P_H
34#define QGFXDRIVERINTERFACE_H 34#define QGFXDRIVERINTERFACE_P_H
35
36//
37// W A R N I N G
38// -------------
39//
40// This file is not part of the Qt API. This header file may
41// change from version to version without notice, or even be
42// removed.
43//
44// We mean it.
45//
46//
35 47
36#ifndef QT_H 48#ifndef QT_H
37#include <private/qcom_p.h> 49#include <private/qcom_p.h>
38#endif // QT_H 50#endif // QT_H
39 51
40#ifndef QT_NO_COMPONENT 52#ifndef QT_NO_COMPONENT
41 53
42// {449EC6C6-DF3E-43E3-9E57-354A3D05AB34} 54// {449EC6C6-DF3E-43E3-9E57-354A3D05AB34}
43#ifndef IID_QGfxDriver 55#ifndef IID_QGfxDriver
44#define IID_QGfxDriver QUuid( 0x449ec6c6, 0xdf3e, 0x43e3, 0x9e, 0x57, 0x35, 0x4a, 0x3d, 0x05, 0xab, 0x34) 56#define IID_QGfxDriver QUuid( 0x449ec6c6, 0xdf3e, 0x43e3, 0x9e, 0x57, 0x35, 0x4a, 0x3d, 0x05, 0xab, 0x34)
45#endif 57#endif
46 58
47class QScreen; 59class QScreen;
48 60
49struct Q_EXPORT QGfxDriverInterface : public QFeatureListInterface 61struct Q_EXPORT QGfxDriverInterface : public QFeatureListInterface
50{ 62{
51 virtual QScreen* create( const QString& driver, int displayId ) = 0; 63 virtual QScreen* create( const QString& driver, int displayId ) = 0;
52}; 64};
53 65
54#endif // QT_NO_COMPONENT 66#endif // QT_NO_COMPONENT
55 67
56#endif // QGFXDRIVERINTERFACE_H 68#endif // QGFXDRIVERINTERFACE_P_H
diff --git a/qmake/include/private/qgpluginmanager_p.h b/qmake/include/private/qgpluginmanager_p.h
index e0c0e78..2e4e9c5 100644
--- a/qmake/include/private/qgpluginmanager_p.h
+++ b/qmake/include/private/qgpluginmanager_p.h
@@ -1,61 +1,61 @@
1/********************************************************************** 1/**********************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QGPluginManager class 4** Definition of QGPluginManager class
5** 5**
6** Copyright (C) 2000-2001 Trolltech AS. All rights reserved. 6** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
7** 7**
8** This file is part of the tools module of the Qt GUI Toolkit. 8** This file is part of the tools module of the Qt GUI Toolkit.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QGPLUGINMANAGER_H 36#ifndef QGPLUGINMANAGER_P_H
37#define QGPLUGINMANAGER_H 37#define QGPLUGINMANAGER_P_H
38 38
39#ifndef QT_H 39#ifndef QT_H
40#include "qdict.h" 40#include "qdict.h"
41#include "qlibrary.h" 41#include "qlibrary.h"
42#include "quuid.h" 42#include "quuid.h"
43#include "qstringlist.h" 43#include "qstringlist.h"
44#include "qcom_p.h" 44#include "qcom_p.h"
45#endif // QT_H 45#endif // QT_H
46 46
47// 47//
48// W A R N I N G 48// W A R N I N G
49// ------------- 49// -------------
50// 50//
51// This file is not part of the Qt API. It exists for the convenience 51// This file is not part of the Qt API. It exists for the convenience
52// of a number of Qt sources files. This header file may change from 52// of a number of Qt sources files. This header file may change from
53// version to version without notice, or even be removed. 53// version to version without notice, or even be removed.
54// 54//
55// We mean it. 55// We mean it.
56// 56//
57// 57//
58 58
59#ifndef QT_NO_COMPONENT 59#ifndef QT_NO_COMPONENT
60 60
61#if defined(Q_TEMPLATEDLL) 61#if defined(Q_TEMPLATEDLL)
@@ -83,25 +83,25 @@ protected:
83 83
84 QRESULT queryUnknownInterface(const QString& feature, QUnknownInterface** iface) const; 84 QRESULT queryUnknownInterface(const QString& feature, QUnknownInterface** iface) const;
85 85
86 QUuid interfaceId; 86 QUuid interfaceId;
87 QDict<QLibrary> plugDict; // Dict to match feature with library 87 QDict<QLibrary> plugDict; // Dict to match feature with library
88 QDict<QLibrary> libDict; // Dict to match library file with library 88 QDict<QLibrary> libDict; // Dict to match library file with library
89 QStringList libList; 89 QStringList libList;
90 90
91 uint casesens : 1; 91 uint casesens : 1;
92 uint autounload : 1; 92 uint autounload : 1;
93}; 93};
94 94
95inline void QGPluginManager::setAutoUnload( bool unload ) 95inline void QGPluginManager::setAutoUnload( bool unload )
96{ 96{
97 autounload = unload; 97 autounload = unload;
98} 98}
99 99
100inline bool QGPluginManager::autoUnload() const 100inline bool QGPluginManager::autoUnload() const
101{ 101{
102 return autounload; 102 return autounload;
103} 103}
104 104
105#endif 105#endif
106 106
107#endif //QGPLUGINMANAGER_H 107#endif //QGPLUGINMANAGER_P_H
diff --git a/qmake/include/private/qimageformatinterface_p.h b/qmake/include/private/qimageformatinterface_p.h
index 5f7601c..fd4c256 100644
--- a/qmake/include/private/qimageformatinterface_p.h
+++ b/qmake/include/private/qimageformatinterface_p.h
@@ -1,75 +1,75 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ??? 4** ...
5** 5**
6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
7** 7**
8** This file is part of the kernel module of the Qt GUI Toolkit. 8** This file is part of the kernel module of the Qt GUI Toolkit.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QIMAGEFORMATINTERFACE_H 36#ifndef QIMAGEFORMATINTERFACE_P_H
37#define QIMAGEFORMATINTERFACE_H 37#define QIMAGEFORMATINTERFACE_P_H
38 38
39#ifndef QT_H 39#ifndef QT_H
40#include <private/qcom_p.h> 40#include <private/qcom_p.h>
41#endif // QT_H 41#endif // QT_H
42 42
43 43
44// 44//
45// W A R N I N G 45// W A R N I N G
46// ------------- 46// -------------
47// 47//
48// This file is not part of the Qt API. It exists for the convenience 48// This file is not part of the Qt API. It exists for the convenience
49// of internal files. This header file may change from version to version 49// of internal files. This header file may change from version to version
50// without notice, or even be removed. 50// without notice, or even be removed.
51// 51//
52// We mean it. 52// We mean it.
53// 53//
54// 54//
55 55
56#ifndef QT_NO_COMPONENT 56#ifndef QT_NO_COMPONENT
57 57
58// {04903F05-54B1-4726-A849-FB5CB097CA87} 58// {04903F05-54B1-4726-A849-FB5CB097CA87}
59#ifndef IID_QImageFormat 59#ifndef IID_QImageFormat
60#define IID_QImageFormat QUuid( 0x04903f05, 0x54b1, 0x4726, 0xa8, 0x49, 0xfb, 0x5c, 0xb0, 0x97, 0xca, 0x87 ) 60#define IID_QImageFormat QUuid( 0x04903f05, 0x54b1, 0x4726, 0xa8, 0x49, 0xfb, 0x5c, 0xb0, 0x97, 0xca, 0x87 )
61#endif 61#endif
62 62
63class QImage; 63class QImage;
64 64
65struct Q_EXPORT QImageFormatInterface : public QFeatureListInterface 65struct Q_EXPORT QImageFormatInterface : public QFeatureListInterface
66{ 66{
67 virtual QRESULT loadImage( const QString &format, const QString &filename, QImage * ) = 0; 67 virtual QRESULT loadImage( const QString &format, const QString &filename, QImage * ) = 0;
68 virtual QRESULT saveImage( const QString &format, const QString &filename, const QImage & ) = 0; 68 virtual QRESULT saveImage( const QString &format, const QString &filename, const QImage & ) = 0;
69 69
70 virtual QRESULT installIOHandler( const QString & ) = 0; 70 virtual QRESULT installIOHandler( const QString & ) = 0;
71}; 71};
72 72
73#endif // QT_NO_COMPONENT 73#endif // QT_NO_COMPONENT
74 74
75#endif // QIMAGEFORMATINTERFACE_H 75#endif // QIMAGEFORMATINTERFACE_P_H
diff --git a/qmake/include/private/qinputcontext_p.h b/qmake/include/private/qinputcontext_p.h
index 9ac0d2b..4d94147 100644
--- a/qmake/include/private/qinputcontext_p.h
+++ b/qmake/include/private/qinputcontext_p.h
@@ -66,56 +66,59 @@ class QString;
66#ifdef Q_WS_WIN 66#ifdef Q_WS_WIN
67#include <qt_windows.h> 67#include <qt_windows.h>
68#endif 68#endif
69 69
70#ifdef Q_WS_QWS 70#ifdef Q_WS_QWS
71class QWSIMEvent; 71class QWSIMEvent;
72#endif 72#endif
73 73
74class QInputContext 74class QInputContext
75{ 75{
76public: 76public:
77#ifdef Q_WS_X11 77#ifdef Q_WS_X11
78 QInputContext(QWidget *); // should be a toplevel widget 78 QInputContext(QWidget *); // should be a toplevel widget
79 ~QInputContext(); 79 ~QInputContext();
80 80
81 void setFocus(); 81 void setFocus();
82 void setComposePosition(int, int); 82 void setComposePosition(int, int);
83 void setComposeArea(int, int, int, int); 83 void setComposeArea(int, int, int, int);
84 void reset(); 84 void reset();
85 85
86 int lookupString(XKeyEvent *, QCString &, KeySym *, Status *) const; 86 int lookupString(XKeyEvent *, QCString &, KeySym *, Status *) const;
87 void setXFontSet(const QFont &); 87 void setXFontSet(const QFont &);
88 88
89 void *ic; 89 void *ic;
90 QString text, lastcompose; 90 QString text;
91 QWidget *focusWidget; 91 QWidget *focusWidget;
92 bool composing; 92 bool composing;
93 QFont font; 93 QFont font;
94 XFontSet fontset; 94 XFontSet fontset;
95 QMemArray<bool> selectedChars; 95 QMemArray<bool> selectedChars;
96#endif // Q_WS_X11 96#endif // Q_WS_X11
97 97
98#ifdef Q_WS_QWS 98#ifdef Q_WS_QWS
99 static void translateIMEvent( QWSIMEvent *, QWidget * ); 99 static void translateIMEvent( QWSIMEvent *, QWidget * );
100 static void reset(); 100 static void reset();
101private: 101private:
102 static QWidget* focusWidget; 102 static QWidget* focusWidget;
103 static QString* composition; 103 static QString* composition;
104#endif //Q_WS_QWS 104#endif //Q_WS_QWS
105 105
106#ifdef Q_WS_WIN 106#ifdef Q_WS_WIN
107 static void init(); 107 static void init();
108 static void shutdown(); 108 static void shutdown();
109 109
110 static void TranslateMessage( const MSG *msg); 110 static void TranslateMessage( const MSG *msg);
111 static LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); 111 static LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );
112 112
113 static void setFont( const QWidget *w, const QFont & ); 113 static void setFont( const QWidget *w, const QFont & );
114 static void setFocusHint( int x, int y, int w, int h, const QWidget *widget ); 114 static void setFocusHint( int x, int y, int w, int h, const QWidget *widget );
115 static bool startComposition(); 115 static bool startComposition();
116 static bool endComposition( QWidget *fw = 0 ); 116 static bool endComposition( QWidget *fw = 0 );
117 static bool composition( LPARAM lparam ); 117 static bool composition( LPARAM lparam );
118
119 static void accept( QWidget *fw = 0 );
120 static void enable( bool );
118#endif 121#endif
119}; 122};
120 123
121#endif // QINPUTCONTEXT_P_H 124#endif // QINPUTCONTEXT_P_H
diff --git a/qmake/include/private/qkbddriverinterface_p.h b/qmake/include/private/qkbddriverinterface_p.h
index efc7ded..fe13487 100644
--- a/qmake/include/private/qkbddriverinterface_p.h
+++ b/qmake/include/private/qkbddriverinterface_p.h
@@ -9,48 +9,60 @@
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed and/or modified under the terms of the 12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software 13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the 14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file. 15** packaging of this file.
16** 16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses for Qt/Embedded may use this file in accordance with the 18** licenses for Qt/Embedded may use this file in accordance with the
19** Qt Embedded Commercial License Agreement provided with the Software. 19** Qt Embedded Commercial License Agreement provided with the Software.
20** 20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23** 23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements. 25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/gpl/ for GPL licensing information. 26** See http://www.trolltech.com/gpl/ for GPL licensing information.
27** 27**
28** Contact info@trolltech.com if any conditions of this licensing are 28** Contact info@trolltech.com if any conditions of this licensing are
29** not clear to you. 29** not clear to you.
30** 30**
31**********************************************************************/ 31**********************************************************************/
32 32
33#ifndef QKBDDRIVERINTERFACE_H 33#ifndef QKBDDRIVERINTERFACE_P_H
34#define QKBDDRIVERINTERFACE_H 34#define QKBDDRIVERINTERFACE_P_H
35
36//
37// W A R N I N G
38// -------------
39//
40// This file is not part of the Qt API. This header file may
41// change from version to version without notice, or even be
42// removed.
43//
44// We mean it.
45//
46//
35 47
36#ifndef QT_H 48#ifndef QT_H
37#include <private/qcom_p.h> 49#include <private/qcom_p.h>
38#endif // QT_H 50#endif // QT_H
39 51
40#ifndef QT_NO_COMPONENT 52#ifndef QT_NO_COMPONENT
41 53
42// {C7C838EA-FC3E-4905-92AD-F479E81F1D02} 54// {C7C838EA-FC3E-4905-92AD-F479E81F1D02}
43#ifndef IID_QKbdDriver 55#ifndef IID_QKbdDriver
44#define IID_QKbdDriver QUuid( 0xc7c838ea, 0xfc3e, 0x4905, 0x92, 0xad, 0xf4, 0x79, 0xe8, 0x1f, 0x1d, 0x02) 56#define IID_QKbdDriver QUuid( 0xc7c838ea, 0xfc3e, 0x4905, 0x92, 0xad, 0xf4, 0x79, 0xe8, 0x1f, 0x1d, 0x02)
45#endif 57#endif
46 58
47class QWSKeyboardHandler; 59class QWSKeyboardHandler;
48 60
49struct Q_EXPORT QKbdDriverInterface : public QFeatureListInterface 61struct Q_EXPORT QKbdDriverInterface : public QFeatureListInterface
50{ 62{
51 virtual QWSKeyboardHandler* create( const QString& driver, const QString& device ) = 0; 63 virtual QWSKeyboardHandler* create( const QString& driver, const QString& device ) = 0;
52}; 64};
53 65
54#endif // QT_NO_COMPONENT 66#endif // QT_NO_COMPONENT
55 67
56#endif // QKBDDRIVERINTERFACE_H 68#endif // QKBDDRIVERINTERFACE_P_H
diff --git a/qmake/include/private/qlibrary_p.h b/qmake/include/private/qlibrary_p.h
index c4dd565..1624ca5 100644
--- a/qmake/include/private/qlibrary_p.h
+++ b/qmake/include/private/qlibrary_p.h
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of an internal QLibrary class 4** Definition of an internal QLibrary class
5** 5**
6** Created : 2000-01-01 6** Created : 000101
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
@@ -34,51 +34,48 @@
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QLIBRARY_P_H 38#ifndef QLIBRARY_P_H
39#define QLIBRARY_P_H 39#define QLIBRARY_P_H
40 40
41// 41//
42// W A R N I N G 42// W A R N I N G
43// ------------- 43// -------------
44// 44//
45// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
46// of the QLibrary class. This header file may change from 46// of the QLibrary class. This header file may change from
47// version to version without notice, or even be removed. 47// version to version without notice, or even be removed.
48// 48//
49// We mean it. 49// We mean it.
50// 50//
51// 51//
52 52
53#include "qlibrary.h" 53#include "qlibrary.h"
54 54
55#ifndef QT_NO_LIBRARY 55#ifndef QT_NO_LIBRARY
56 56
57#ifndef QT_H 57#ifndef QT_H
58#if defined(Q_CC_GNU)
59#warning "avoid including header file \"qwindowdefs.h\" in directory 'tools'"
60#endif
61#include "qwindowdefs.h" 58#include "qwindowdefs.h"
62#endif // QT_H 59#endif // QT_H
63 60
64class QLibraryPrivate 61class QLibraryPrivate
65{ 62{
66public: 63public:
67 QLibraryPrivate( QLibrary *lib ); 64 QLibraryPrivate( QLibrary *lib );
68 65
69#ifdef Q_WS_WIN 66#ifdef Q_WS_WIN
70 HINSTANCE pHnd; 67 HINSTANCE pHnd;
71#else 68#else
72 void *pHnd; 69 void *pHnd;
73#endif 70#endif
74 71
75 bool loadLibrary(); 72 bool loadLibrary();
76 bool freeLibrary(); 73 bool freeLibrary();
77 void *resolveSymbol( const char * ); 74 void *resolveSymbol( const char * );
78 75
79private: 76private:
80 QLibrary *library; 77 QLibrary *library;
81}; 78};
82 79
83#endif // QT_NO_LIBRARY 80#endif // QT_NO_LIBRARY
84#endif // QLIBRARY_P_H 81#endif // QLIBRARY_P_H
diff --git a/qmake/include/private/qlock_p.h b/qmake/include/private/qlock_p.h
new file mode 100644
index 0000000..5c261aa
--- a/dev/null
+++ b/qmake/include/private/qlock_p.h
@@ -0,0 +1,93 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of QLock class. This manages interprocess locking
5**
6** Created : 20000406
7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the Qt GUI Toolkit.
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses for Qt/Embedded may use this file in accordance with the
19** Qt Embedded Commercial License Agreement provided with the Software.
20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/gpl/ for GPL licensing information.
27**
28** Contact info@trolltech.com if any conditions of this licensing are
29** not clear to you.
30**
31**********************************************************************/
32
33#ifndef QLOCK_P_H
34#define QLOCK_P_H
35
36//
37// W A R N I N G
38// -------------
39//
40// This file is not part of the Qt API. This header file may
41// change from version to version without notice, or even be
42// removed.
43//
44// We mean it.
45//
46//
47
48#ifndef QT_H
49#include <qstring.h>
50#endif // QT_H
51
52class QLockData;
53
54class QLock
55{
56public:
57 QLock( const QString &filename, char id, bool create = FALSE );
58 ~QLock();
59
60 enum Type { Read, Write };
61
62 bool isValid() const;
63 void lock( Type type );
64 void unlock();
65 bool locked() const;
66
67private:
68 Type type;
69 QLockData *data;
70};
71
72
73// Nice class for ensuring the lock is released.
74// Just create one on the stack and the lock is automatically released
75// when QLockHolder is destructed.
76class QLockHolder
77{
78public:
79 QLockHolder( QLock *l, QLock::Type type ) : qlock(l) {
80 qlock->lock( type );
81 }
82 ~QLockHolder() { if ( locked() ) qlock->unlock(); }
83
84 void lock( QLock::Type type ) { qlock->lock( type ); }
85 void unlock() { qlock->unlock(); }
86 bool locked() const { return qlock->locked(); }
87
88private:
89 QLock *qlock;
90};
91
92#endif
93
diff --git a/qmake/include/private/qmousedriverinterface_p.h b/qmake/include/private/qmousedriverinterface_p.h
index fd76308..42a2e3e 100644
--- a/qmake/include/private/qmousedriverinterface_p.h
+++ b/qmake/include/private/qmousedriverinterface_p.h
@@ -9,48 +9,60 @@
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed and/or modified under the terms of the 12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software 13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the 14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file. 15** packaging of this file.
16** 16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses for Qt/Embedded may use this file in accordance with the 18** licenses for Qt/Embedded may use this file in accordance with the
19** Qt Embedded Commercial License Agreement provided with the Software. 19** Qt Embedded Commercial License Agreement provided with the Software.
20** 20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23** 23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements. 25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/gpl/ for GPL licensing information. 26** See http://www.trolltech.com/gpl/ for GPL licensing information.
27** 27**
28** Contact info@trolltech.com if any conditions of this licensing are 28** Contact info@trolltech.com if any conditions of this licensing are
29** not clear to you. 29** not clear to you.
30** 30**
31**********************************************************************/ 31**********************************************************************/
32 32
33#ifndef QMOUSEDRIVERINTERFACE_H 33#ifndef QMOUSEDRIVERINTERFACE_P_H
34#define QMOUSEDRIVERINTERFACE_H 34#define QMOUSEDRIVERINTERFACE_P_H
35
36//
37// W A R N I N G
38// -------------
39//
40// This file is not part of the Qt API. This header file may
41// change from version to version without notice, or even be
42// removed.
43//
44// We mean it.
45//
46//
35 47
36#ifndef QT_H 48#ifndef QT_H
37#include <private/qcom_p.h> 49#include <private/qcom_p.h>
38#endif // QT_H 50#endif // QT_H
39 51
40#ifndef QT_NO_COMPONENT 52#ifndef QT_NO_COMPONENT
41 53
42// {4367CF5A-F7CE-407B-8BB6-DF19AEDA2EBB} 54// {4367CF5A-F7CE-407B-8BB6-DF19AEDA2EBB}
43#ifndef IID_QMouseDriver 55#ifndef IID_QMouseDriver
44#define IID_QMouseDriver QUuid( 0x4367cf5a, 0xf7ce, 0x407b, 0x8b, 0xb6, 0xdf, 0x19, 0xae, 0xda, 0x2e, 0xbb) 56#define IID_QMouseDriver QUuid( 0x4367cf5a, 0xf7ce, 0x407b, 0x8b, 0xb6, 0xdf, 0x19, 0xae, 0xda, 0x2e, 0xbb)
45#endif 57#endif
46 58
47class QWSMouseHandler; 59class QWSMouseHandler;
48 60
49struct Q_EXPORT QMouseDriverInterface : public QFeatureListInterface 61struct Q_EXPORT QMouseDriverInterface : public QFeatureListInterface
50{ 62{
51 virtual QWSMouseHandler* create( const QString& driver, const QString &device ) = 0; 63 virtual QWSMouseHandler* create( const QString& driver, const QString &device ) = 0;
52}; 64};
53 65
54#endif // QT_NO_COMPONENT 66#endif // QT_NO_COMPONENT
55 67
56#endif // QMOUSEDRIVERINTERFACE_H 68#endif // QMOUSEDRIVERINTERFACE_P_H
diff --git a/qmake/include/private/qmutexpool_p.h b/qmake/include/private/qmutexpool_p.h
index 3d9fef7..fb84157 100644
--- a/qmake/include/private/qmutexpool_p.h
+++ b/qmake/include/private/qmutexpool_p.h
@@ -1,39 +1,75 @@
1#ifndef QMUTEXPOOL_H 1/****************************************************************************
2#define QMUTEXPOOL_H 2** $Id$
3**
4** ...
5**
6** Copyright (C) 2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the tools module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#ifndef QMUTEXPOOL_P_H
37#define QMUTEXPOOL_P_H
3 38
4// 39//
5// W A R N I N G 40// W A R N I N G
6// ------------- 41// -------------
7// 42//
8// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
9// of QSettings. This header file may change from version to 44// of QSettings. This header file may change from version to
10// version without notice, or even be removed. 45// version without notice, or even be removed.
11// 46//
12// We mean it. 47// We mean it.
13// 48//
14// 49//
15 50
16#ifdef QT_THREAD_SUPPORT 51#ifdef QT_THREAD_SUPPORT
17 52
18#include "qmutex.h" 53#include "qmutex.h"
19#include "qmemarray.h" 54#include "qmemarray.h"
20 55
21class QMutexPool 56class QMutexPool
22{ 57{
23public: 58public:
24 QMutexPool( bool recursive = FALSE, int size = 17 ); 59 QMutexPool( bool recursive = FALSE, int size = 17 );
25 ~QMutexPool(); 60 ~QMutexPool();
26 61
27 QMutex *get( void *address ); 62 QMutex *get( void *address );
28 63
29private: 64private:
30 QMutex mutex; 65 QMutex mutex;
31 QMemArray<QMutex*> mutexes; 66 QMutex **mutexes;
67 int count;
32 bool recurs; 68 bool recurs;
33}; 69};
34 70
35extern QMutexPool *qt_global_mutexpool; 71extern QMutexPool *qt_global_mutexpool;
36 72
37#endif // QT_THREAD_SUPPORT 73#endif // QT_THREAD_SUPPORT
38 74
39#endif // QMUTEXPOOL_H 75#endif // QMUTEXPOOL_P_H
diff --git a/qmake/include/private/qpluginmanager_p.h b/qmake/include/private/qpluginmanager_p.h
index 4b64ba0..a8da10e 100644
--- a/qmake/include/private/qpluginmanager_p.h
+++ b/qmake/include/private/qpluginmanager_p.h
@@ -1,73 +1,73 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QPluginManager class 4** Definition of QPluginManager class
5** 5**
6** Created : 2000-01-01 6** Created : 000101
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QPLUGINMANAGER_H 38#ifndef QPLUGINMANAGER_P_H
39#define QPLUGINMANAGER_H 39#define QPLUGINMANAGER_P_H
40
41#ifndef QT_H
42#include "qgpluginmanager_p.h"
43#endif // QT_H
44 40
45// 41//
46// W A R N I N G 42// W A R N I N G
47// ------------- 43// -------------
48// 44//
49// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
50// of a number of Qt sources files. This header file may change from 46// of a number of Qt sources files. This header file may change from
51// version to version without notice, or even be removed. 47// version to version without notice, or even be removed.
52// 48//
53// We mean it. 49// We mean it.
54// 50//
55// 51//
56 52
53#ifndef QT_H
54#include "qgpluginmanager_p.h"
55#endif // QT_H
56
57#ifndef QT_NO_COMPONENT 57#ifndef QT_NO_COMPONENT
58 58
59template<class Type> 59template<class Type>
60class QPluginManager : public QGPluginManager 60class QPluginManager : public QGPluginManager
61{ 61{
62public: 62public:
63 QPluginManager( const QUuid& id, const QStringList& paths = QString::null, const QString &suffix = QString::null, bool cs = TRUE ) 63 QPluginManager( const QUuid& id, const QStringList& paths = QString::null, const QString &suffix = QString::null, bool cs = TRUE )
64 : QGPluginManager( id, paths, suffix, cs ) {} 64 : QGPluginManager( id, paths, suffix, cs ) {}
65 QRESULT queryInterface(const QString& feature, Type** iface) const 65 QRESULT queryInterface(const QString& feature, Type** iface) const
66 { 66 {
67 return queryUnknownInterface( feature, (QUnknownInterface**)iface ); 67 return queryUnknownInterface( feature, (QUnknownInterface**)iface );
68 } 68 }
69}; 69};
70 70
71#endif //QT_NO_COMPONENT 71#endif //QT_NO_COMPONENT
72 72
73#endif //QPLUGINMANAGER_H 73#endif //QPLUGINMANAGER_P_H
diff --git a/qmake/include/private/qpsprinter_p.h b/qmake/include/private/qpsprinter_p.h
index 27a4968..692cb44 100644
--- a/qmake/include/private/qpsprinter_p.h
+++ b/qmake/include/private/qpsprinter_p.h
@@ -1,33 +1,33 @@
1/********************************************************************** 1/**********************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of internal QPSPrinter class. 4** Definition of internal QPSPrinter class.
5** QPSPrinter implements PostScript (tm) output via QPrinter. 5** QPSPrinter implements PostScript (tm) output via QPrinter.
6** 6**
7** Created : 940927 7** Created : 940927
8** 8**
9** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 9** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
10** 10**
11** This file is part of the kernel module of the Qt GUI Toolkit. 11** This file is part of the kernel module of the Qt GUI Toolkit.
12** 12**
13** This file may be distributed under the terms of the Q Public License 13** This file may be distributed under the terms of the Q Public License
14** as defined by Trolltech AS of Norway and appearing in the file 14** as defined by Trolltech AS of Norway and appearing in the file
15** LICENSE.QPL included in the packaging of this file. 15** LICENSE.QPL included in the packaging of this file.
16** 16**
17** This file may be distributed and/or modified under the terms of the 17** This file may be distributed and/or modified under the terms of the
18** GNU General Public License version 2 as published by the Free Software 18** GNU General Public License version 2 as published by the Free Software
19** Foundation and appearing in the file LICENSE.GPL included in the 19** Foundation and appearing in the file LICENSE.GPL included in the
20** packaging of this file. 20** packaging of this file.
21** 21**
22** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 22** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
23** licenses may use this file in accordance with the Qt Commercial License 23** licenses may use this file in accordance with the Qt Commercial License
24** Agreement provided with the Software. 24** Agreement provided with the Software.
25** 25**
26** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 26** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
27** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 27** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28** 28**
29** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 29** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
30** information about Qt Commercial License Agreements. 30** information about Qt Commercial License Agreements.
31** See http://www.trolltech.com/qpl/ for QPL licensing information. 31** See http://www.trolltech.com/qpl/ for QPL licensing information.
32** See http://www.trolltech.com/gpl/ for GPL licensing information. 32** See http://www.trolltech.com/gpl/ for GPL licensing information.
33** 33**
@@ -40,49 +40,49 @@
40#define QPSPRINTER_P_H 40#define QPSPRINTER_P_H
41 41
42 42
43// 43//
44// W A R N I N G 44// W A R N I N G
45// ------------- 45// -------------
46// 46//
47// This file is not part of the Qt API. It exists for the convenience 47// This file is not part of the Qt API. It exists for the convenience
48// of qpsprinter.cpp and qprinter_x11.cpp. 48// of qpsprinter.cpp and qprinter_x11.cpp.
49// This header file may change from version to version without notice, 49// This header file may change from version to version without notice,
50// or even be removed. 50// or even be removed.
51// 51//
52// We mean it. 52// We mean it.
53// 53//
54// 54//
55 55
56 56
57#ifndef QT_H 57#ifndef QT_H
58#include "qprinter.h" 58#include "qprinter.h"
59#include "qtextstream.h" 59#include "qtextstream.h"
60#endif // QT_H 60#endif // QT_H
61 61
62#ifndef QT_NO_PRINTER 62#ifndef QT_NO_PRINTER
63 63
64struct QPSPrinterPrivate; 64class QPSPrinterPrivate;
65 65
66class Q_EXPORT QPSPrinter : public QPaintDevice 66class Q_EXPORT QPSPrinter : public QPaintDevice
67{ 67{
68private: 68private:
69 // QPrinter uses these 69 // QPrinter uses these
70 QPSPrinter( QPrinter *, int ); 70 QPSPrinter( QPrinter *, int );
71 ~QPSPrinter(); 71 ~QPSPrinter();
72 72
73 bool cmd ( int, QPainter *, QPDevCmdParam * ); 73 bool cmd ( int, QPainter *, QPDevCmdParam * );
74 74
75 enum { NewPage = 100, AbortPrinting }; 75 enum { NewPage = 100, AbortPrinting };
76 76
77 friend class QPrinter; 77 friend class QPrinter;
78private: 78private:
79 // not used by QPrinter 79 // not used by QPrinter
80 QPSPrinterPrivate *d; 80 QPSPrinterPrivate *d;
81 81
82 // Disabled copy constructor and operator= 82 // Disabled copy constructor and operator=
83 QPSPrinter( const QPSPrinter & ); 83 QPSPrinter( const QPSPrinter & );
84 QPSPrinter &operator=( const QPSPrinter & ); 84 QPSPrinter &operator=( const QPSPrinter & );
85}; 85};
86 86
87#endif // QT_NO_PRINTER 87#endif // QT_NO_PRINTER
88 88
diff --git a/qmake/include/private/qrichtext_p.h b/qmake/include/private/qrichtext_p.h
index 8e29804..9ed87cf 100644
--- a/qmake/include/private/qrichtext_p.h
+++ b/qmake/include/private/qrichtext_p.h
@@ -135,68 +135,70 @@ public:
135 QString anchorName; 135 QString anchorName;
136 QString anchorHref; 136 QString anchorHref;
137 }; 137 };
138 138
139#ifndef QT_NO_TEXTCUSTOMITEM 139#ifndef QT_NO_TEXTCUSTOMITEM
140 void loseCustomItem(); 140 void loseCustomItem();
141#endif 141#endif
142 142
143 union { 143 union {
144 QTextFormat* format; 144 QTextFormat* format;
145 CustomData* custom; 145 CustomData* custom;
146 } d; 146 } d;
147 147
148 bool isAnchor() const { return ( type & Anchor) != 0; } 148 bool isAnchor() const { return ( type & Anchor) != 0; }
149 bool isLink() const { return isAnchor() && !!d.custom->anchorHref; } 149 bool isLink() const { return isAnchor() && !!d.custom->anchorHref; }
150 QString anchorName() const; 150 QString anchorName() const;
151 QString anchorHref() const; 151 QString anchorHref() const;
152 void setAnchor( const QString& name, const QString& href ); 152 void setAnchor( const QString& name, const QString& href );
153 153
154private: 154private:
155 QTextStringChar &operator=( const QTextStringChar & ) { 155 QTextStringChar &operator=( const QTextStringChar & ) {
156 //abort(); 156 //abort();
157 return *this; 157 return *this;
158 } 158 }
159 QTextStringChar( const QTextStringChar & ) {
160 }
159 friend class QComplexText; 161 friend class QComplexText;
160 friend class QTextParagraph; 162 friend class QTextParagraph;
161}; 163};
162 164
163#if defined(Q_TEMPLATEDLL) 165#if defined(Q_TEMPLATEDLL)
164// MOC_SKIP_BEGIN 166// MOC_SKIP_BEGIN
165Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>; 167Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>;
166// MOC_SKIP_END 168// MOC_SKIP_END
167#endif 169#endif
168 170
169class Q_EXPORT QTextString 171class Q_EXPORT QTextString
170{ 172{
171public: 173public:
172 174
173 QTextString(); 175 QTextString();
174 QTextString( const QTextString &s ); 176 QTextString( const QTextString &s );
175 virtual ~QTextString(); 177 virtual ~QTextString();
176 178
177 static QString toString( const QMemArray<QTextStringChar> &data ); 179 static QString toString( const QMemArray<QTextStringChar> &data, bool fixspaces = TRUE );
178 QString toString() const; 180 QString toString( bool fixspaces = TRUE ) const;
179 181
180 QTextStringChar &at( int i ) const; 182 QTextStringChar &at( int i ) const;
181#if defined(Q_STRICT_INLINING_RULES) 183#if defined(Q_STRICT_INLINING_RULES)
182 // This is for the IRIX MIPSpro o32 ABI - it fails, claiming the 184 // This is for the IRIX MIPSpro o32 ABI - it fails, claiming the
183 // implementation to be a redefinition. 185 // implementation to be a redefinition.
184 inline int length() const; 186 inline int length() const;
185#else 187#else
186 int length() const; 188 int length() const;
187#endif 189#endif
188 190
189 int width( int idx ) const; 191 int width( int idx ) const;
190 192
191 void insert( int index, const QString &s, QTextFormat *f ); 193 void insert( int index, const QString &s, QTextFormat *f );
192 void insert( int index, const QChar *unicode, int len, QTextFormat *f ); 194 void insert( int index, const QChar *unicode, int len, QTextFormat *f );
193 void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE ); 195 void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE );
194 void truncate( int index ); 196 void truncate( int index );
195 void remove( int index, int len ); 197 void remove( int index, int len );
196 void clear(); 198 void clear();
197 199
198 void setFormat( int index, QTextFormat *f, bool useCollection ); 200 void setFormat( int index, QTextFormat *f, bool useCollection );
199 201
200 void setBidi( bool b ) { bidi = b; } 202 void setBidi( bool b ) { bidi = b; }
201 bool isBidi() const; 203 bool isBidi() const;
202 bool isRightToLeft() const; 204 bool isRightToLeft() const;
@@ -265,89 +267,89 @@ public:
265 // implementation to be a redefinition. 267 // implementation to be a redefinition.
266 inline QTextParagraph *paragraph() const; 268 inline QTextParagraph *paragraph() const;
267#else 269#else
268 QTextParagraph *paragraph() const; 270 QTextParagraph *paragraph() const;
269#endif 271#endif
270 272
271 void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); } 273 void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); }
272 QTextDocument *document() const; 274 QTextDocument *document() const;
273 int index() const; 275 int index() const;
274 void setIndex( int index ) { gotoPosition(paragraph(), index ); } 276 void setIndex( int index ) { gotoPosition(paragraph(), index ); }
275 277
276 void gotoPosition( QTextParagraph* p, int index = 0); 278 void gotoPosition( QTextParagraph* p, int index = 0);
277 void gotoLeft(); 279 void gotoLeft();
278 void gotoRight(); 280 void gotoRight();
279 void gotoNextLetter(); 281 void gotoNextLetter();
280 void gotoPreviousLetter(); 282 void gotoPreviousLetter();
281 void gotoUp(); 283 void gotoUp();
282 void gotoDown(); 284 void gotoDown();
283 void gotoLineEnd(); 285 void gotoLineEnd();
284 void gotoLineStart(); 286 void gotoLineStart();
285 void gotoHome(); 287 void gotoHome();
286 void gotoEnd(); 288 void gotoEnd();
287 void gotoPageUp( int visibleHeight ); 289 void gotoPageUp( int visibleHeight );
288 void gotoPageDown( int visibleHeight ); 290 void gotoPageDown( int visibleHeight );
289 void gotoNextWord(); 291 void gotoNextWord( bool onlySpace = FALSE );
290 void gotoPreviousWord(); 292 void gotoPreviousWord( bool onlySpace = FALSE );
291 void gotoWordLeft(); 293 void gotoWordLeft();
292 void gotoWordRight(); 294 void gotoWordRight();
293 295
294 void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 ); 296 void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 );
295 void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE ); 297 void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE );
296 bool remove(); 298 bool remove();
297 void indent(); 299 void indent();
298 300
299 bool atParagStart(); 301 bool atParagStart();
300 bool atParagEnd(); 302 bool atParagEnd();
301 303
302 int x() const; // x in current paragraph 304 int x() const; // x in current paragraph
303 int y() const; // y in current paragraph 305 int y() const; // y in current paragraph
304 306
305 int globalX() const; 307 int globalX() const;
306 int globalY() const; 308 int globalY() const;
307 309
308 QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); } 310 QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); }
309 int offsetX() const { return ox; } // inner document offset 311 int offsetX() const { return ox; } // inner document offset
310 int offsetY() const { return oy; } // inner document offset 312 int offsetY() const { return oy; } // inner document offset
311 int totalOffsetX() const; // total document offset 313 int totalOffsetX() const; // total document offset
312 int totalOffsetY() const; // total document offset 314 int totalOffsetY() const; // total document offset
313 315
314 bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); } 316 bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); }
315 bool place( const QPoint &pos, QTextParagraph *s, bool link ); 317 bool place( const QPoint &pos, QTextParagraph *s, bool link );
316 void restoreState(); 318 void restoreState();
317 319
318 320
319 int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast 321 int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast
320 void oneUp() { if ( !indices.isEmpty() ) pop(); } 322 void oneUp() { if ( !indices.isEmpty() ) pop(); }
321 void setValid( bool b ) { valid = b; } 323 void setValid( bool b ) { valid = b; }
322 bool isValid() const { return valid; } 324 bool isValid() const { return valid; }
323 325
324private: 326private:
325 enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; 327 enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down };
326 328
327 void push(); 329 void push();
328 void pop(); 330 void pop();
329 void processNesting( Operation op ); 331 bool processNesting( Operation op );
330 void invalidateNested(); 332 void invalidateNested();
331 void gotoIntoNested( const QPoint &globalPos ); 333 void gotoIntoNested( const QPoint &globalPos );
332 334
333 QTextParagraph *para; 335 QTextParagraph *para;
334 int idx, tmpIndex; 336 int idx, tmpIndex;
335 int ox, oy; 337 int ox, oy;
336 QValueStack<int> indices; 338 QValueStack<int> indices;
337 QValueStack<QTextParagraph*> paras; 339 QValueStack<QTextParagraph*> paras;
338 QValueStack<int> xOffsets; 340 QValueStack<int> xOffsets;
339 QValueStack<int> yOffsets; 341 QValueStack<int> yOffsets;
340 uint valid : 1; 342 uint valid : 1;
341 343
342}; 344};
343 345
344// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 346// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
345 347
346class Q_EXPORT QTextCommand 348class Q_EXPORT QTextCommand
347{ 349{
348public: 350public:
349 enum Commands { Invalid, Insert, Delete, Format, Style }; 351 enum Commands { Invalid, Insert, Delete, Format, Style };
350 352
351 QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {} 353 QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {}
352 virtual ~QTextCommand(); 354 virtual ~QTextCommand();
353 355
@@ -682,48 +684,49 @@ private:
682 int cellspacing; 684 int cellspacing;
683 int border; 685 int border;
684 int outerborder; 686 int outerborder;
685 int stretch; 687 int stretch;
686 int innerborder; 688 int innerborder;
687 int us_cp, us_ib, us_b, us_ob, us_cs; 689 int us_cp, us_ib, us_b, us_ob, us_cs;
688 QMap<QString, QString> attributes; 690 QMap<QString, QString> attributes;
689 QMap<QTextCursor*, int> currCell; 691 QMap<QTextCursor*, int> currCell;
690 Placement place; 692 Placement place;
691 void adjustCells( int y , int shift ); 693 void adjustCells( int y , int shift );
692 int pageBreakFor; 694 int pageBreakFor;
693}; 695};
694#endif 696#endif
695// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 697// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
696 698
697#ifndef QT_NO_TEXTCUSTOMITEM 699#ifndef QT_NO_TEXTCUSTOMITEM
698class QTextTableCell; 700class QTextTableCell;
699class QTextParagraph; 701class QTextParagraph;
700#endif 702#endif
701 703
702struct Q_EXPORT QTextDocumentSelection 704struct Q_EXPORT QTextDocumentSelection
703{ 705{
704 QTextCursor startCursor, endCursor; 706 QTextCursor startCursor, endCursor;
705 bool swapped; 707 bool swapped;
708 Q_DUMMY_COMPARISON_OPERATOR(QTextDocumentSelection)
706}; 709};
707 710
708#if defined(Q_TEMPLATEDLL) 711#if defined(Q_TEMPLATEDLL)
709// MOC_SKIP_BEGIN 712// MOC_SKIP_BEGIN
710Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>; 713Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>;
711Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>; 714Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>;
712Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>; 715Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>;
713Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>; 716Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>;
714// MOC_SKIP_END 717// MOC_SKIP_END
715#endif 718#endif
716 719
717class Q_EXPORT QTextDocument : public QObject 720class Q_EXPORT QTextDocument : public QObject
718{ 721{
719 Q_OBJECT 722 Q_OBJECT
720 723
721#ifndef QT_NO_TEXTCUSTOMITEM 724#ifndef QT_NO_TEXTCUSTOMITEM
722 friend class QTextTableCell; 725 friend class QTextTableCell;
723#endif 726#endif
724 friend class QTextCursor; 727 friend class QTextCursor;
725 friend class QTextEdit; 728 friend class QTextEdit;
726 friend class QTextParagraph; 729 friend class QTextParagraph;
727 730
728public: 731public:
729 enum SelectionIds { 732 enum SelectionIds {
@@ -818,48 +821,51 @@ public:
818 821
819 bool inSelection( int selId, const QPoint &pos ) const; 822 bool inSelection( int selId, const QPoint &pos ) const;
820 823
821 QStyleSheet *styleSheet() const { return sheet_; } 824 QStyleSheet *styleSheet() const { return sheet_; }
822#ifndef QT_NO_MIME 825#ifndef QT_NO_MIME
823 QMimeSourceFactory *mimeSourceFactory() const { return factory_; } 826 QMimeSourceFactory *mimeSourceFactory() const { return factory_; }
824#endif 827#endif
825 QString context() const { return contxt; } 828 QString context() const { return contxt; }
826 829
827 void setStyleSheet( QStyleSheet *s ); 830 void setStyleSheet( QStyleSheet *s );
828 void setDefaultFormat( const QFont &font, const QColor &color ); 831 void setDefaultFormat( const QFont &font, const QColor &color );
829#ifndef QT_NO_MIME 832#ifndef QT_NO_MIME
830 void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; } 833 void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; }
831#endif 834#endif
832 void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; } 835 void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; }
833 836
834 void setUnderlineLinks( bool b ); 837 void setUnderlineLinks( bool b );
835 bool underlineLinks() const { return underlLinks; } 838 bool underlineLinks() const { return underlLinks; }
836 839
837 void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; } 840 void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; }
838 QBrush *paper() const { return backBrush; } 841 QBrush *paper() const { return backBrush; }
839 842
840 void doLayout( QPainter *p, int w ); 843 void doLayout( QPainter *p, int w );
841 void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 ); 844 void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
845 void eraseParagraphEmptyArea( QTextParagraph *parag, QPainter *p, const QColorGroup &cg );
846 bool useDoubleBuffer( QTextParagraph *parag, QPainter *p );
847
842 void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch, 848 void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch,
843 QPixmap *&doubleBuffer, const QColorGroup &cg, 849 QPixmap *&doubleBuffer, const QColorGroup &cg,
844 bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); 850 bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
845 QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg, 851 QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
846 bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, 852 bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
847 bool resetChanged = TRUE ); 853 bool resetChanged = TRUE );
848 854
849#ifndef QT_NO_TEXTCUSTOMITEM 855#ifndef QT_NO_TEXTCUSTOMITEM
850 void registerCustomItem( QTextCustomItem *i, QTextParagraph *p ); 856 void registerCustomItem( QTextCustomItem *i, QTextParagraph *p );
851 void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p ); 857 void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p );
852#endif 858#endif
853 859
854 void setFlow( QTextFlow *f ); 860 void setFlow( QTextFlow *f );
855 void takeFlow(); 861 void takeFlow();
856 QTextFlow *flow() const { return flow_; } 862 QTextFlow *flow() const { return flow_; }
857 bool isPageBreakEnabled() const { return pages; } 863 bool isPageBreakEnabled() const { return pages; }
858 void setPageBreakEnabled( bool b ) { pages = b; } 864 void setPageBreakEnabled( bool b ) { pages = b; }
859 865
860 void setUseFormatCollection( bool b ) { useFC = b; } 866 void setUseFormatCollection( bool b ) { useFC = b; }
861 bool useFormatCollection() const { return useFC; } 867 bool useFormatCollection() const { return useFC; }
862 868
863#ifndef QT_NO_TEXTCUSTOMITEM 869#ifndef QT_NO_TEXTCUSTOMITEM
864 QTextTableCell *tableCell() const { return tc; } 870 QTextTableCell *tableCell() const { return tc; }
865 void setTableCell( QTextTableCell *c ) { tc = c; } 871 void setTableCell( QTextTableCell *c ) { tc = c; }
@@ -1046,48 +1052,49 @@ protected:
1046class Q_EXPORT QTextStyleCommand : public QTextCommand 1052class Q_EXPORT QTextStyleCommand : public QTextCommand
1047{ 1053{
1048public: 1054public:
1049 QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange ); 1055 QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange );
1050 virtual ~QTextStyleCommand() {} 1056 virtual ~QTextStyleCommand() {}
1051 1057
1052 Commands type() const { return Style; } 1058 Commands type() const { return Style; }
1053 QTextCursor *execute( QTextCursor *c ); 1059 QTextCursor *execute( QTextCursor *c );
1054 QTextCursor *unexecute( QTextCursor *c ); 1060 QTextCursor *unexecute( QTextCursor *c );
1055 1061
1056 static QByteArray readStyleInformation( QTextDocument* d, int fParag, int lParag ); 1062 static QByteArray readStyleInformation( QTextDocument* d, int fParag, int lParag );
1057 static void writeStyleInformation( QTextDocument* d, int fParag, const QByteArray& style ); 1063 static void writeStyleInformation( QTextDocument* d, int fParag, const QByteArray& style );
1058 1064
1059private: 1065private:
1060 int firstParag, lastParag; 1066 int firstParag, lastParag;
1061 QByteArray before; 1067 QByteArray before;
1062 QByteArray after; 1068 QByteArray after;
1063}; 1069};
1064 1070
1065// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1071// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1066 1072
1067struct Q_EXPORT QTextParagraphSelection 1073struct Q_EXPORT QTextParagraphSelection
1068{ 1074{
1069 int start, end; 1075 int start, end;
1076 Q_DUMMY_COMPARISON_OPERATOR(QTextParagraphSelection)
1070}; 1077};
1071 1078
1072struct Q_EXPORT QTextLineStart 1079struct Q_EXPORT QTextLineStart
1073{ 1080{
1074 QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) 1081 QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 )
1075#ifndef QT_NO_COMPLEXTEXT 1082#ifndef QT_NO_COMPLEXTEXT
1076 , bidicontext( 0 ) 1083 , bidicontext( 0 )
1077#endif 1084#endif
1078 { } 1085 { }
1079 QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), 1086 QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
1080 w( 0 ) 1087 w( 0 )
1081#ifndef QT_NO_COMPLEXTEXT 1088#ifndef QT_NO_COMPLEXTEXT
1082 , bidicontext( 0 ) 1089 , bidicontext( 0 )
1083#endif 1090#endif
1084 { } 1091 { }
1085#ifndef QT_NO_COMPLEXTEXT 1092#ifndef QT_NO_COMPLEXTEXT
1086 QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0), 1093 QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0),
1087 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } 1094 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
1088#endif 1095#endif
1089 1096
1090 virtual ~QTextLineStart() 1097 virtual ~QTextLineStart()
1091 { 1098 {
1092#ifndef QT_NO_COMPLEXTEXT 1099#ifndef QT_NO_COMPLEXTEXT
1093 if ( bidicontext && bidicontext->deref() ) 1100 if ( bidicontext && bidicontext->deref() )
@@ -1115,89 +1122,87 @@ public:
1115#endif 1122#endif
1116 int w; 1123 int w;
1117 1124
1118private: 1125private:
1119#ifndef QT_NO_COMPLEXTEXT 1126#ifndef QT_NO_COMPLEXTEXT
1120 QBidiContext *bidicontext; 1127 QBidiContext *bidicontext;
1121#endif 1128#endif
1122}; 1129};
1123 1130
1124#if defined(Q_TEMPLATEDLL) 1131#if defined(Q_TEMPLATEDLL)
1125// MOC_SKIP_BEGIN 1132// MOC_SKIP_BEGIN
1126Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>; 1133Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>;
1127Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>; 1134Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>;
1128// MOC_SKIP_END 1135// MOC_SKIP_END
1129#endif 1136#endif
1130 1137
1131class Q_EXPORT QTextParagraphData 1138class Q_EXPORT QTextParagraphData
1132{ 1139{
1133public: 1140public:
1134 QTextParagraphData() {} 1141 QTextParagraphData() {}
1135 virtual ~QTextParagraphData(); 1142 virtual ~QTextParagraphData();
1136 virtual void join( QTextParagraphData * ); 1143 virtual void join( QTextParagraphData * );
1137}; 1144};
1138 1145
1139class Q_EXPORT QTextParagraphPseudoDocument 1146class QTextParagraphPseudoDocument;
1140{ 1147
1141public: 1148class QSyntaxHighlighter;
1142 QTextParagraphPseudoDocument();
1143 ~QTextParagraphPseudoDocument();
1144 QRect docRect;
1145 QTextFormatter *pFormatter;
1146 QTextCommandHistory *commandHistory;
1147 int minw;
1148 int wused;
1149};
1150 1149
1151//nase
1152class Q_EXPORT QTextParagraph 1150class Q_EXPORT QTextParagraph
1153{ 1151{
1154 friend class QTextDocument; 1152 friend class QTextDocument;
1155 friend class QTextCursor; 1153 friend class QTextCursor;
1154 friend class QSyntaxHighlighter;
1156 1155
1157public: 1156public:
1158 QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE ); 1157 QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
1159 virtual ~QTextParagraph(); 1158 virtual ~QTextParagraph();
1160 1159
1161 QTextString *string() const; 1160 QTextString *string() const;
1162 QTextStringChar *at( int i ) const; // maybe remove later 1161 QTextStringChar *at( int i ) const; // maybe remove later
1163 int leftGap() const; 1162 int leftGap() const;
1164 int length() const; // maybe remove later 1163 int length() const; // maybe remove later
1165 1164
1166 void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; } 1165 void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; }
1167 QStyleSheetItem::ListStyle listStyle() const { return lstyle; } 1166 QStyleSheetItem::ListStyle listStyle() const { return lstyle; }
1168 void setListItem( bool li ); 1167 void setListItem( bool li );
1169 bool isListItem() const { return litem; } 1168 bool isListItem() const { return litem; }
1170 void setListValue( int v ) { list_val = v; } 1169 void setListValue( int v ) { list_val = v; }
1171 int listValue() const { return list_val > 0 ? list_val : -1; } 1170 int listValue() const { return list_val > 0 ? list_val : -1; }
1172 1171
1173 void setListDepth( int depth ); 1172 void setListDepth( int depth );
1174 int listDepth() const { return ldepth; } 1173 int listDepth() const { return ldepth; }
1175 1174
1176// void setFormat( QTextFormat *fm ); 1175// void setFormat( QTextFormat *fm );
1177// QTextFormat *paragFormat() const; 1176// QTextFormat *paragFormat() const;
1178 1177
1178#if defined(Q_STRICT_INLINING_RULES)
1179 // This is for the IRIX MIPSpro o32 ABI - it fails, claiming the
1180 // implementation to be a redefinition.
1181 inline QTextDocument *document() const;
1182#else
1179 QTextDocument *document() const; 1183 QTextDocument *document() const;
1184#endif
1180 QTextParagraphPseudoDocument *pseudoDocument() const; 1185 QTextParagraphPseudoDocument *pseudoDocument() const;
1181 1186
1182 QRect rect() const; 1187 QRect rect() const;
1183 void setHeight( int h ) { r.setHeight( h ); } 1188 void setHeight( int h ) { r.setHeight( h ); }
1184 void show(); 1189 void show();
1185 void hide(); 1190 void hide();
1186 bool isVisible() const { return visible; } 1191 bool isVisible() const { return visible; }
1187 1192
1188 QTextParagraph *prev() const; 1193 QTextParagraph *prev() const;
1189 QTextParagraph *next() const; 1194 QTextParagraph *next() const;
1190 void setPrev( QTextParagraph *s ); 1195 void setPrev( QTextParagraph *s );
1191 void setNext( QTextParagraph *s ); 1196 void setNext( QTextParagraph *s );
1192 1197
1193 void insert( int index, const QString &s ); 1198 void insert( int index, const QString &s );
1194 void insert( int index, const QChar *unicode, int len ); 1199 void insert( int index, const QChar *unicode, int len );
1195 void append( const QString &s, bool reallyAtEnd = FALSE ); 1200 void append( const QString &s, bool reallyAtEnd = FALSE );
1196 void truncate( int index ); 1201 void truncate( int index );
1197 void remove( int index, int len ); 1202 void remove( int index, int len );
1198 void join( QTextParagraph *s ); 1203 void join( QTextParagraph *s );
1199 1204
1200 void invalidate( int chr ); 1205 void invalidate( int chr );
1201 1206
1202 void move( int &dy ); 1207 void move( int &dy );
1203 void format( int start = -1, bool doMove = TRUE ); 1208 void format( int start = -1, bool doMove = TRUE );
@@ -1575,68 +1580,80 @@ private:
1575// MOC_SKIP_BEGIN 1580// MOC_SKIP_BEGIN
1576Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>; 1581Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>;
1577// MOC_SKIP_END 1582// MOC_SKIP_END
1578#endif 1583#endif
1579 1584
1580class Q_EXPORT QTextFormatCollection 1585class Q_EXPORT QTextFormatCollection
1581{ 1586{
1582 friend class QTextDocument; 1587 friend class QTextDocument;
1583 friend class QTextFormat; 1588 friend class QTextFormat;
1584 1589
1585public: 1590public:
1586 QTextFormatCollection(); 1591 QTextFormatCollection();
1587 virtual ~QTextFormatCollection(); 1592 virtual ~QTextFormatCollection();
1588 1593
1589 void setDefaultFormat( QTextFormat *f ); 1594 void setDefaultFormat( QTextFormat *f );
1590 QTextFormat *defaultFormat() const; 1595 QTextFormat *defaultFormat() const;
1591 virtual QTextFormat *format( QTextFormat *f ); 1596 virtual QTextFormat *format( QTextFormat *f );
1592 virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags ); 1597 virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags );
1593 virtual QTextFormat *format( const QFont &f, const QColor &c ); 1598 virtual QTextFormat *format( const QFont &f, const QColor &c );
1594 virtual void remove( QTextFormat *f ); 1599 virtual void remove( QTextFormat *f );
1595 virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); } 1600 virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); }
1596 virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); } 1601 virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); }
1597 1602
1598 void updateDefaultFormat( const QFont &font, const QColor &c, QStyleSheet *sheet ); 1603 void updateDefaultFormat( const QFont &font, const QColor &c, QStyleSheet *sheet );
1599 QDict<QTextFormat> dict() const { return cKey; }
1600 1604
1601 QPaintDevice *paintDevice() const { return paintdevice; } 1605 QPaintDevice *paintDevice() const { return paintdevice; }
1602 void setPaintDevice( QPaintDevice * ); 1606 void setPaintDevice( QPaintDevice * );
1603 1607
1604private: 1608private:
1605 void updateKeys(); 1609 void updateKeys();
1606 1610
1607private: 1611private:
1608 QTextFormat *defFormat, *lastFormat, *cachedFormat; 1612 QTextFormat *defFormat, *lastFormat, *cachedFormat;
1609 QDict<QTextFormat> cKey; 1613 QDict<QTextFormat> cKey;
1610 QTextFormat *cres; 1614 QTextFormat *cres;
1611 QFont cfont; 1615 QFont cfont;
1612 QColor ccol; 1616 QColor ccol;
1613 QString kof, knf; 1617 QString kof, knf;
1614 int cflags; 1618 int cflags;
1615 1619
1616 QPaintDevice *paintdevice; 1620 QPaintDevice *paintdevice;
1617}; 1621};
1618 1622
1623class Q_EXPORT QTextParagraphPseudoDocument
1624{
1625public:
1626 QTextParagraphPseudoDocument();
1627 ~QTextParagraphPseudoDocument();
1628 QRect docRect;
1629 QTextFormatter *pFormatter;
1630 QTextCommandHistory *commandHistory;
1631 int minw;
1632 int wused;
1633 QTextFormatCollection collection;
1634};
1635
1619// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1636// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1620 1637
1621inline int QTextString::length() const 1638inline int QTextString::length() const
1622{ 1639{
1623 return data.size(); 1640 return data.size();
1624} 1641}
1625 1642
1626inline int QTextParagraph::length() const 1643inline int QTextParagraph::length() const
1627{ 1644{
1628 return str->length(); 1645 return str->length();
1629} 1646}
1630 1647
1631inline QRect QTextParagraph::rect() const 1648inline QRect QTextParagraph::rect() const
1632{ 1649{
1633 return r; 1650 return r;
1634} 1651}
1635 1652
1636inline QTextParagraph *QTextCursor::paragraph() const 1653inline QTextParagraph *QTextCursor::paragraph() const
1637{ 1654{
1638 return para; 1655 return para;
1639} 1656}
1640 1657
1641inline int QTextCursor::index() const 1658inline int QTextCursor::index() const
1642{ 1659{
@@ -1807,48 +1824,54 @@ inline void QTextDocument::setTabArray( int *a )
1807inline void QTextDocument::setTabStops( int tw ) 1824inline void QTextDocument::setTabStops( int tw )
1808{ 1825{
1809 tStopWidth = tw; 1826 tStopWidth = tw;
1810} 1827}
1811 1828
1812inline QString QTextDocument::originalText() const 1829inline QString QTextDocument::originalText() const
1813{ 1830{
1814 if ( oTextValid ) 1831 if ( oTextValid )
1815 return oText; 1832 return oText;
1816 return text(); 1833 return text();
1817} 1834}
1818 1835
1819inline void QTextDocument::setFlow( QTextFlow *f ) 1836inline void QTextDocument::setFlow( QTextFlow *f )
1820{ 1837{
1821 if ( flow_ ) 1838 if ( flow_ )
1822 delete flow_; 1839 delete flow_;
1823 flow_ = f; 1840 flow_ = f;
1824} 1841}
1825 1842
1826inline void QTextDocument::takeFlow() 1843inline void QTextDocument::takeFlow()
1827{ 1844{
1828 flow_ = 0; 1845 flow_ = 0;
1829} 1846}
1830 1847
1848inline bool QTextDocument::useDoubleBuffer( QTextParagraph *parag, QPainter *p )
1849{
1850 return ( !parag->document()->parent() || parag->document()->nextDoubleBuffered ) &&
1851 ( !p || !p->device() || p->device()->devType() != QInternal::Printer );
1852}
1853
1831// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1854// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1832 1855
1833inline QColor QTextFormat::color() const 1856inline QColor QTextFormat::color() const
1834{ 1857{
1835 return col; 1858 return col;
1836} 1859}
1837 1860
1838inline QFont QTextFormat::font() const 1861inline QFont QTextFormat::font() const
1839{ 1862{
1840 return fn; 1863 return fn;
1841} 1864}
1842 1865
1843inline bool QTextFormat::isMisspelled() const 1866inline bool QTextFormat::isMisspelled() const
1844{ 1867{
1845 return missp; 1868 return missp;
1846} 1869}
1847 1870
1848inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const 1871inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const
1849{ 1872{
1850 return ha; 1873 return ha;
1851} 1874}
1852 1875
1853inline bool QTextFormat::operator==( const QTextFormat &f ) const 1876inline bool QTextFormat::operator==( const QTextFormat &f ) const
1854{ 1877{
diff --git a/qmake/include/private/qsettings_p.h b/qmake/include/private/qsettings_p.h
index 18d118b..095291c 100644
--- a/qmake/include/private/qsettings_p.h
+++ b/qmake/include/private/qsettings_p.h
@@ -73,49 +73,49 @@ public:
73 QSettingsPrivate( QSettings::Format format ); 73 QSettingsPrivate( QSettings::Format format );
74 ~QSettingsPrivate(); 74 ~QSettingsPrivate();
75 75
76 QSettingsGroup readGroup(); 76 QSettingsGroup readGroup();
77 void removeGroup(const QString &); 77 void removeGroup(const QString &);
78 void writeGroup(const QString &, const QString &); 78 void writeGroup(const QString &, const QString &);
79 QDateTime modificationTime(); 79 QDateTime modificationTime();
80 80
81 QStringList searchPaths; 81 QStringList searchPaths;
82 QMap<QString,QSettingsHeading> headings; 82 QMap<QString,QSettingsHeading> headings;
83 QString group; 83 QString group;
84 QString heading; 84 QString heading;
85 85
86 /*### static data brings threading trouble 86 /*### static data brings threading trouble
87 static QString *defProduct; 87 static QString *defProduct;
88 static QString *defDomain; 88 static QString *defDomain;
89 */ 89 */
90 QValueStack<QString> groupStack; 90 QValueStack<QString> groupStack;
91 QString groupPrefix; 91 QString groupPrefix;
92 92
93 bool groupDirty :1; 93 bool groupDirty :1;
94 bool modified :1; 94 bool modified :1;
95 bool globalScope :1; 95 bool globalScope :1;
96 96
97#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 97#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
98 // system dependent implementations to use the 98 // system dependent implementations to use the
99 // system specific setting database (ie. registry on Windows) 99 // system specific setting database (ie. registry on Windows)
100 100
101 QSettingsSysPrivate *sysd; 101 QSettingsSysPrivate *sysd;
102 voidsysInit(); 102 voidsysInit();
103 voidsysClear(); 103 voidsysClear();
104 104
105#if !defined(Q_NO_BOOL_TYPE) 105#if !defined(Q_NO_BOOL_TYPE)
106 boolsysWriteEntry( const QString &, bool ); 106 boolsysWriteEntry( const QString &, bool );
107#endif 107#endif
108 boolsysWriteEntry( const QString &, double ); 108 boolsysWriteEntry( const QString &, double );
109 boolsysWriteEntry( const QString &, int ); 109 boolsysWriteEntry( const QString &, int );
110 boolsysWriteEntry( const QString &, const QString & ); 110 boolsysWriteEntry( const QString &, const QString & );
111 boolsysWriteEntry( const QString &, const QStringList & ); 111 boolsysWriteEntry( const QString &, const QStringList & );
112 boolsysWriteEntry( const QString &, const QStringList &, const QChar& sep ); 112 boolsysWriteEntry( const QString &, const QStringList &, const QChar& sep );
113 113
114 QStringList sysEntryList(const QString &) const; 114 QStringList sysEntryList(const QString &) const;
115 QStringList sysSubkeyList(const QString &) const; 115 QStringList sysSubkeyList(const QString &) const;
116 116
117 QStringList sysReadListEntry( const QString &, bool * = 0 ) const; 117 QStringList sysReadListEntry( const QString &, bool * = 0 ) const;
118 QStringList sysReadListEntry( const QString &, const QChar& sep, bool * = 0 ) const; 118 QStringList sysReadListEntry( const QString &, const QChar& sep, bool * = 0 ) const;
119 QStringsysReadEntry( const QString &, const QString &def = QString::null, bool * = 0 ) const; 119 QStringsysReadEntry( const QString &, const QString &def = QString::null, bool * = 0 ) const;
120 int sysReadNumEntry( const QString &, int def = 0, bool * = 0 ) const; 120 int sysReadNumEntry( const QString &, int def = 0, bool * = 0 ) const;
121 doublesysReadDoubleEntry( const QString &, double def = 0, bool * = 0 ) const; 121 doublesysReadDoubleEntry( const QString &, double def = 0, bool * = 0 ) const;
diff --git a/qmake/include/private/qsharedmemory_p.h b/qmake/include/private/qsharedmemory_p.h
index 4a8339d..927de89 100644
--- a/qmake/include/private/qsharedmemory_p.h
+++ b/qmake/include/private/qsharedmemory_p.h
@@ -1,84 +1,87 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Includes system files for shared memory 4** Includes system files for shared memory
5** 5**
6** Created : 020124 6** Created : 020124
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the kernel module of the Qt GUI Toolkit. 10** This file is part of the kernel module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed and/or modified under the terms of the 12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software 13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the 14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file. 15** packaging of this file.
16** 16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses for Qt/Embedded may use this file in accordance with the 18** licenses for Qt/Embedded may use this file in accordance with the
19** Qt Embedded Commercial License Agreement provided with the Software. 19** Qt Embedded Commercial License Agreement provided with the Software.
20** 20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23** 23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements. 25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/gpl/ for GPL licensing information. 26** See http://www.trolltech.com/gpl/ for GPL licensing information.
27** 27**
28** Contact info@trolltech.com if any conditions of this licensing are 28** Contact info@trolltech.com if any conditions of this licensing are
29** not clear to you. 29** not clear to you.
30** 30**
31**********************************************************************/ 31**********************************************************************/
32 32
33#ifndef QSHAREDMEMORY_P_H
34#define QSHAREDMEMORY_P_H
35
33// 36//
34// W A R N I N G 37// W A R N I N G
35// ------------- 38// -------------
36// 39//
37// This file is not part of the Qt API. It exists for the convenience 40// This file is not part of the Qt API. It exists for the convenience
38// of qapplication_qws.cpp and qgfxvnc_qws.cpp. This header file may 41// of qapplication_qws.cpp and qgfxvnc_qws.cpp. This header file may
39// change from version to version without notice, or even be removed. 42// change from version to version without notice, or even be removed.
40// 43//
44// We mean it.
45//
41// 46//
42
43#if !defined(QT_QSHM_H)
44#define QT_QSHM_H
45 47
46#include <qstring.h> 48#include <qstring.h>
47 49
48#if !defined (QT_QWS_NO_SHM) 50#if !defined (QT_QWS_NO_SHM)
49 51
50#include <sys/types.h> 52#include <sys/types.h>
51#include <sys/ipc.h> 53#include <sys/ipc.h>
52 54
53class QSharedMemory { 55class QSharedMemory {
54public: 56public:
55 QSharedMemory(){}; 57 QSharedMemory(){};
56 QSharedMemory(int, QString, char c = 'Q'); 58 QSharedMemory(int, QString, char c = 'Q');
57 ~QSharedMemory(){}; 59 ~QSharedMemory(){};
58 60
59 bool create(); 61 bool create();
60 void destroy(); 62 void destroy();
61 63
62 bool attach(); 64 bool attach();
63 void detach(); 65 void detach();
64 66
65 void setPermissions(mode_t mode); 67 void setPermissions(mode_t mode);
66 int size(); 68 int size();
67 void * base() { return shmBase; }; 69 void * base() { return shmBase; };
68 70
69private: 71private:
70 void *shmBase; 72 void *shmBase;
71 int shmSize; 73 int shmSize;
72 QString shmFile; 74 QString shmFile;
73 char character; 75 char character;
74#if defined(QT_POSIX_QSHM) 76#if defined(QT_POSIX_QSHM)
75 int shmFD; 77 int shmFD;
76#else 78#else
77 int shmId; 79 int shmId;
78 key_t key; 80 key_t key;
79 int idInitted; 81 int idInitted;
80#endif 82#endif
81}; 83};
82 84
83#endif 85#endif
86
84#endif 87#endif
diff --git a/qmake/include/private/qsqldriverinterface_p.h b/qmake/include/private/qsqldriverinterface_p.h
index 8957b86..8a39ddf 100644
--- a/qmake/include/private/qsqldriverinterface_p.h
+++ b/qmake/include/private/qsqldriverinterface_p.h
@@ -1,69 +1,82 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
2** 3**
3** Definition of QSqlDriverInterface class 4** Definition of QSqlDriverInterface class
4** 5**
5** Created : 2000-11-03 6** Created : 2000-11-03
6** 7**
7** Copyright (C) 2000 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
8** 9**
9** This file is part of the sql module of the Qt GUI Toolkit. 10** This file is part of the sql module of the Qt GUI Toolkit.
10** 11**
11** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
14** 15**
15** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file. 19** packaging of this file.
19** 20**
20** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
22** with the Software. 23** with the Software.
23** 24**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26** 27**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
31** 32**
32** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you. 34** not clear to you.
34** 35**
35**********************************************************************/ 36**********************************************************************/
36 37
37#ifndef QSQLDRIVERINTERFACE_H 38#ifndef QSQLDRIVERINTERFACE_H
38#define QSQLDRIVERINTERFACE_H 39#define QSQLDRIVERINTERFACE_H
39 40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. This header file may
46// change from version to version without notice, or even be
47// removed.
48//
49// We mean it.
50//
51//
52
40#ifndef QT_H 53#ifndef QT_H
41#include <private/qcom_p.h> 54#include <private/qcom_p.h>
42#endif // QT_H 55#endif // QT_H
43 56
44#if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) 57#if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
45#define QM_EXPORT_SQL 58#define QM_EXPORT_SQL
46#else 59#else
47#define QM_EXPORT_SQL Q_EXPORT 60#define QM_EXPORT_SQL Q_EXPORT
48#endif 61#endif
49 62
50#ifndef QT_NO_SQL 63#ifndef QT_NO_SQL
51 64
52#ifndef QT_NO_COMPONENT 65#ifndef QT_NO_COMPONENT
53 66
54// {EDDD5AD5-DF3C-400c-A711-163B72FE5F61} 67// {EDDD5AD5-DF3C-400c-A711-163B72FE5F61}
55#ifndef IID_QSqlDriverFactory 68#ifndef IID_QSqlDriverFactory
56#define IID_QSqlDriverFactory QUuid(0xeddd5ad5, 0xdf3c, 0x400c, 0xa7, 0x11, 0x16, 0x3b, 0x72, 0xfe, 0x5f, 0x61) 69#define IID_QSqlDriverFactory QUuid(0xeddd5ad5, 0xdf3c, 0x400c, 0xa7, 0x11, 0x16, 0x3b, 0x72, 0xfe, 0x5f, 0x61)
57#endif 70#endif
58 71
59class QSqlDriver; 72class QSqlDriver;
60 73
61struct QM_EXPORT_SQL QSqlDriverFactoryInterface : public QFeatureListInterface 74struct QM_EXPORT_SQL QSqlDriverFactoryInterface : public QFeatureListInterface
62{ 75{
63 virtual QSqlDriver* create( const QString& name ) = 0; 76 virtual QSqlDriver* create( const QString& name ) = 0;
64}; 77};
65 78
66#endif //QT_NO_COMPONENT 79#endif //QT_NO_COMPONENT
67#endif // QT_NO_SQL 80#endif // QT_NO_SQL
68 81
69#endif // QSQLDRIVERINTERFACE_H 82#endif // QSQLDRIVERINTERFACE_P_H
diff --git a/qmake/include/private/qsqlextension_p.h b/qmake/include/private/qsqlextension_p.h
index 597b266..3445b47 100644
--- a/qmake/include/private/qsqlextension_p.h
+++ b/qmake/include/private/qsqlextension_p.h
@@ -30,72 +30,99 @@
30** See http://www.trolltech.com/gpl/ for GPL licensing information. 30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31** 31**
32** Contact info@trolltech.com if any conditions of this licensing are 32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you. 33** not clear to you.
34** 34**
35**********************************************************************/ 35**********************************************************************/
36 36
37#ifndef QSQLEXTENSION_P_H 37#ifndef QSQLEXTENSION_P_H
38#define QSQLEXTENSION_P_H 38#define QSQLEXTENSION_P_H
39 39
40// 40//
41// W A R N I N G 41// W A R N I N G
42// ------------- 42// -------------
43// 43//
44// This file is not part of the Qt API. It exists for the convenience 44// This file is not part of the Qt API. It exists for the convenience
45// of other Qt classes. This header file may change from version to 45// of other Qt classes. This header file may change from version to
46// version without notice, or even be removed. 46// version without notice, or even be removed.
47// 47//
48// We mean it. 48// We mean it.
49// 49//
50// 50//
51 51
52#ifndef QT_H 52#ifndef QT_H
53#include "qmap.h" 53#include "qmap.h"
54#include "qvaluevector.h"
54#include "qstring.h" 55#include "qstring.h"
55#include "qvariant.h" 56#include "qvariant.h"
57#include "qsql.h"
56#endif // QT_H 58#endif // QT_H
57 59
58#ifndef QT_NO_SQL 60#ifndef QT_NO_SQL
59 61
60#if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) 62#if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
61#define QM_EXPORT_SQL 63#define QM_EXPORT_SQL
64#define QM_TEMPLATE_EXTERN_SQL
62#else 65#else
63#define QM_EXPORT_SQL Q_EXPORT 66#define QM_EXPORT_SQL Q_EXPORT
67#define QM_TEMPLATE_EXTERN_SQL Q_TEMPLATE_EXTERN
64#endif 68#endif
65 69
70struct Param {
71 Param( const QVariant& v = QVariant(), QSql::ParameterType t = QSql::In ): value( v ), typ( t ) {}
72 QVariant value;
73 QSql::ParameterType typ;
74 Q_DUMMY_COMPARISON_OPERATOR(Param)
75};
76
77struct Holder {
78 Holder( const QString& hldr = QString::null, int pos = -1 ): holderName( hldr ), holderPos( pos ) {}
79 bool operator==( const Holder& h ) const { return h.holderPos == holderPos && h.holderName == holderName; }
80 bool operator!=( const Holder& h ) const { return h.holderPos != holderPos || h.holderName != holderName; }
81 QString holderName;
82 int holderPos;
83};
84
66#if defined(Q_TEMPLATEDLL) 85#if defined(Q_TEMPLATEDLL)
67Q_TEMPLATE_EXTERN template class QM_EXPORT_SQL QMap<QString,QVariant>; 86QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<QString,Param>;
68Q_TEMPLATE_EXTERN template class QM_EXPORT_SQL QMap<int,QString>; 87QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<int,QString>;
88QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QValueVector<Holder>;
69#endif 89#endif
70 90
71class QM_EXPORT_SQL QSqlExtension { 91class QM_EXPORT_SQL QSqlExtension {
72public: 92public:
73 QSqlExtension(); 93 QSqlExtension();
74 virtual ~QSqlExtension(); 94 virtual ~QSqlExtension();
75 virtual bool prepare( const QString& query ); 95 virtual bool prepare( const QString& query );
76 virtual bool exec(); 96 virtual bool exec();
77 virtual void bindValue( const QString& holder, const QVariant& value ); 97 virtual void bindValue( const QString& holder, const QVariant& value, QSql::ParameterType = QSql::In );
78 virtual void bindValue( int pos, const QVariant& value ); 98 virtual void bindValue( int pos, const QVariant& value, QSql::ParameterType = QSql::In );
79 virtual void addBindValue( const QVariant& value ); 99 virtual void addBindValue( const QVariant& value, QSql::ParameterType = QSql::In );
100 virtual QVariant parameterValue( const QString& holder );
101 virtual QVariant parameterValue( int pos );
80 void clearValues(); 102 void clearValues();
81 void clearIndex(); 103 void clearIndex();
82 104
83 enum BindMethod { BindByPosition, BindByName }; 105 enum BindMethod { BindByPosition, BindByName };
84 BindMethod bindMethod(); 106 BindMethod bindMethod();
85 BindMethod bindm; 107 BindMethod bindm;
86 int bindCount; 108 int bindCount;
87 109
88 QMap<int, QString> index; 110 QMap<int, QString> index;
89 QMap<QString, QVariant> values; 111 typedef QMap<QString, Param> ValueMap;
112 ValueMap values;
113
114 // convenience container for QSqlQuery
115 // to map holders <-> positions
116 typedef QValueVector<Holder> HolderVector;
117 HolderVector holders;
90}; 118};
91 119
92class QM_EXPORT_SQL QSqlDriverExtension 120class QM_EXPORT_SQL QSqlDriverExtension
93{ 121{
94public: 122public:
95 QSqlDriverExtension(); 123 QSqlDriverExtension();
96 virtual ~QSqlDriverExtension(); 124 virtual ~QSqlDriverExtension();
97 virtual bool isOpen() const = 0; 125 virtual bool isOpen() const = 0;
98}; 126};
99
100#endif 127#endif
101#endif 128#endif
diff --git a/qmake/include/private/qstyleinterface_p.h b/qmake/include/private/qstyleinterface_p.h
index 4aaedc7..24a43ad 100644
--- a/qmake/include/private/qstyleinterface_p.h
+++ b/qmake/include/private/qstyleinterface_p.h
@@ -12,50 +12,62 @@
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QSTYLEINTERFACE_H 36#ifndef QSTYLEINTERFACE_P_H
37#define QSTYLEINTERFACE_H 37#define QSTYLEINTERFACE_P_H
38
39//
40// W A R N I N G
41// -------------
42//
43// This file is not part of the Qt API. This header file may
44// change from version to version without notice, or even be
45// removed.
46//
47// We mean it.
48//
49//
38 50
39#ifndef QT_H 51#ifndef QT_H
40#include <private/qcom_p.h> 52#include <private/qcom_p.h>
41#endif // QT_H 53#endif // QT_H
42 54
43#ifndef QT_NO_STYLE 55#ifndef QT_NO_STYLE
44#ifndef QT_NO_COMPONENT 56#ifndef QT_NO_COMPONENT
45 57
46class QStyle; 58class QStyle;
47 59
48// {FC1B6EBE-053C-49c1-A483-C377739AB9A5} 60// {FC1B6EBE-053C-49c1-A483-C377739AB9A5}
49#ifndef IID_QStyleFactory 61#ifndef IID_QStyleFactory
50#define IID_QStyleFactory QUuid(0xfc1b6ebe, 0x53c, 0x49c1, 0xa4, 0x83, 0xc3, 0x77, 0x73, 0x9a, 0xb9, 0xa5) 62#define IID_QStyleFactory QUuid(0xfc1b6ebe, 0x53c, 0x49c1, 0xa4, 0x83, 0xc3, 0x77, 0x73, 0x9a, 0xb9, 0xa5)
51#endif 63#endif
52 64
53struct Q_EXPORT QStyleFactoryInterface : public QFeatureListInterface 65struct Q_EXPORT QStyleFactoryInterface : public QFeatureListInterface
54{ 66{
55 virtual QStyle* create( const QString& style ) = 0; 67 virtual QStyle* create( const QString& style ) = 0;
56}; 68};
57 69
58#endif //QT_NO_COMPONENT 70#endif //QT_NO_COMPONENT
59#endif //QT_NO_STYLE 71#endif //QT_NO_STYLE
60 72
61#endif //QSTYLEINTERFACE_H 73#endif //QSTYLEINTERFACE_P_H
diff --git a/qmake/include/private/qsvgdevice_p.h b/qmake/include/private/qsvgdevice_p.h
index c1cc389..3407705 100644
--- a/qmake/include/private/qsvgdevice_p.h
+++ b/qmake/include/private/qsvgdevice_p.h
@@ -1,63 +1,63 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of the QSvgDevice class 4** Definition of the QSvgDevice class
5** 5**
6** Created : 20001024 6** Created : 001024
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the xml module of the Qt GUI Toolkit. 10** This file is part of the xml module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36*****************************************************************************/ 36*****************************************************************************/
37 37
38#ifndef QSVGDEVICE_H 38#ifndef QSVGDEVICE_P_H
39#define QSVGDEVICE_H 39#define QSVGDEVICE_P_H
40 40
41// 41//
42// W A R N I N G 42// W A R N I N G
43// ------------- 43// -------------
44// 44//
45// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
46// of the QPicture class. This header file may change from 46// of the QPicture class. This header file may change from
47// version to version without notice, or even be removed. 47// version to version without notice, or even be removed.
48// 48//
49// We mean it. 49// We mean it.
50// 50//
51// 51//
52 52
53#ifndef QT_H 53#ifndef QT_H
54#include "qpaintdevice.h" 54#include "qpaintdevice.h"
55#include "qrect.h" 55#include "qrect.h"
56#include "qdom.h" 56#include "qdom.h"
57#endif // QT_H 57#endif // QT_H
58 58
59#if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML ) 59#if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML )
60#define QM_EXPORT_SVG 60#define QM_EXPORT_SVG
61#else 61#else
62#define QM_EXPORT_SVG Q_EXPORT 62#define QM_EXPORT_SVG Q_EXPORT
63#endif 63#endif
@@ -110,25 +110,25 @@ private:
110 void applyStyle( QDomElement *e, int c ) const; 110 void applyStyle( QDomElement *e, int c ) const;
111 void applyTransform( QDomElement *e ) const; 111 void applyTransform( QDomElement *e ) const;
112 112
113 // reading 113 // reading
114 QRect brect; // bounding rectangle 114 QRect brect; // bounding rectangle
115 QDomDocument doc; // document tree 115 QDomDocument doc; // document tree
116 QDomNode current; 116 QDomNode current;
117 QPoint curPt; 117 QPoint curPt;
118 QSvgDeviceState *curr; 118 QSvgDeviceState *curr;
119 QPainter *pt; // used by play() et al 119 QPainter *pt; // used by play() et al
120 120
121 // writing 121 // writing
122 bool dirtyTransform, dirtyStyle; 122 bool dirtyTransform, dirtyStyle;
123 123
124 QSvgDevicePrivate *d; 124 QSvgDevicePrivate *d;
125}; 125};
126 126
127inline QRect QSvgDevice::boundingRect() const 127inline QRect QSvgDevice::boundingRect() const
128{ 128{
129 return brect; 129 return brect;
130} 130}
131 131
132#endif // QT_NO_SVG 132#endif // QT_NO_SVG
133 133
134#endif // QSVGDEVICE_H 134#endif // QSVGDEVICE_P_H
diff --git a/qmake/include/private/qtextcodecinterface_p.h b/qmake/include/private/qtextcodecinterface_p.h
index d2a2cb9..76e77f7 100644
--- a/qmake/include/private/qtextcodecinterface_p.h
+++ b/qmake/include/private/qtextcodecinterface_p.h
@@ -15,63 +15,61 @@
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
31** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you. 32** not clear to you.
33** 33**
34**********************************************************************/ 34**********************************************************************/
35 35
36#ifndef QTEXTCODECINTERFACE_P_H 36#ifndef QTEXTCODECINTERFACE_P_H
37#define QTEXTCODECINTERFACE_P_H 37#define QTEXTCODECINTERFACE_P_H
38 38
39
40// 39//
41// W A R N I N G 40// W A R N I N G
42// ------------- 41// -------------
43// 42//
44// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
45// of qpsprinter.cpp and qprinter_x11.cpp. 44// of qpsprinter.cpp and qprinter_x11.cpp.
46// This header file may change from version to version without notice, 45// This header file may change from version to version without notice,
47// or even be removed. 46// or even be removed.
48// 47//
49// We mean it. 48// We mean it.
50// 49//
51// 50//
52 51
53
54#ifndef QT_H 52#ifndef QT_H
55#include <private/qcom_p.h> 53#include <private/qcom_p.h>
56#endif // QT_H 54#endif // QT_H
57 55
58#ifndef QT_NO_TEXTCODEC 56#ifndef QT_NO_TEXTCODEC
59#ifndef QT_NO_COMPONENT 57#ifndef QT_NO_COMPONENT
60 58
61class QTextCodec; 59class QTextCodec;
62 60
63 61
64// {F55BFA60-F695-11D4-823E-009027DC0F37} 62// {F55BFA60-F695-11D4-823E-009027DC0F37}
65#ifndef IID_QTextCodecFactory 63#ifndef IID_QTextCodecFactory
66#define IID_QTextCodecFactory QUuid( 0xf55bfa60, 0xf695, 0x11d4, 0x82, 0x3e, 0x00, 0x90, 0x27, 0xdc, 0x0f, 0x37) 64#define IID_QTextCodecFactory QUuid( 0xf55bfa60, 0xf695, 0x11d4, 0x82, 0x3e, 0x00, 0x90, 0x27, 0xdc, 0x0f, 0x37)
67#endif 65#endif
68 66
69 67
70struct Q_EXPORT QTextCodecFactoryInterface : public QFeatureListInterface 68struct Q_EXPORT QTextCodecFactoryInterface : public QFeatureListInterface
71{ 69{
72 virtual QTextCodec *createForMib( int mib ) = 0; 70 virtual QTextCodec *createForMib( int mib ) = 0;
73 virtual QTextCodec *createForName( const QString &name ) = 0; 71 virtual QTextCodec *createForName( const QString &name ) = 0;
74}; 72};
75 73
76#endif // QT_NO_COMPONENT 74#endif // QT_NO_COMPONENT
77#endif // QT_NO_TEXTCODEC 75#endif // QT_NO_TEXTCODEC
diff --git a/qmake/include/private/qtitlebar_p.h b/qmake/include/private/qtitlebar_p.h
index dabb6bf..091845f 100644
--- a/qmake/include/private/qtitlebar_p.h
+++ b/qmake/include/private/qtitlebar_p.h
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of some Qt private functions. 4** Definition of some Qt private functions.
5** 5**
6** Created : 2000-01-01 6** Created : 000101
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the widgets module of the Qt GUI Toolkit. 10** This file is part of the widgets module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
diff --git a/qmake/include/private/qucom_p.h b/qmake/include/private/qucom_p.h
index d2ff48e..6b6ad40 100644
--- a/qmake/include/private/qucom_p.h
+++ b/qmake/include/private/qucom_p.h
@@ -14,68 +14,68 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QUCOM_H 38#ifndef QUCOM_P_H
39#define QUCOM_H 39#define QUCOM_P_H
40
41#ifndef QT_H
42#include <qstring.h>
43#include "quuid.h"
44#endif // QT_H
45 40
46// 41//
47// W A R N I N G 42// W A R N I N G
48// ------------- 43// -------------
49// 44//
50// This file is not part of the Qt API. It exists for the convenience 45// This file is not part of the Qt API. It exists for the convenience
51// of a number of Qt sources files. This header file may change from 46// of a number of Qt sources files. This header file may change from
52// version to version without notice, or even be removed. 47// version to version without notice, or even be removed.
53// 48//
54// We mean it. 49// We mean it.
55// 50//
56// 51//
57 52
53#ifndef QT_H
54#include <qstring.h>
55#include "quuid.h"
56#endif // QT_H
57
58#ifdef check 58#ifdef check
59#undef check 59#undef check
60#endif 60#endif
61 61
62struct QUObject; 62struct QUObject;
63struct QUInterfaceDescription; 63struct QUInterfaceDescription;
64struct QUnknownInterface; 64struct QUnknownInterface;
65struct QDispatchInterface; 65struct QDispatchInterface;
66 66
67 67
68struct Q_EXPORT QUBuffer 68struct Q_EXPORT QUBuffer
69{ 69{
70 virtual long read( char *data, ulong maxlen ) = 0; 70 virtual long read( char *data, ulong maxlen ) = 0;
71 virtual long write( const char *data, ulong len ) = 0; 71 virtual long write( const char *data, ulong len ) = 0;
72}; 72};
73 73
74 74
75// A type for a QUObject 75// A type for a QUObject
76struct Q_EXPORT QUType 76struct Q_EXPORT QUType
77{ 77{
78 virtual const QUuid *uuid() const = 0; 78 virtual const QUuid *uuid() const = 0;
79 virtual const char *desc() const = 0; 79 virtual const char *desc() const = 0;
80 80
81 81
@@ -108,94 +108,94 @@ struct Q_EXPORT QUType_Null : public QUType
108 bool canConvertFrom( QUObject *, QUType * ); 108 bool canConvertFrom( QUObject *, QUType * );
109 bool canConvertTo( QUObject *, QUType * ); 109 bool canConvertTo( QUObject *, QUType * );
110 bool convertFrom( QUObject *, QUType * ); 110 bool convertFrom( QUObject *, QUType * );
111 bool convertTo( QUObject *, QUType * ); 111 bool convertTo( QUObject *, QUType * );
112 void clear( QUObject * ); 112 void clear( QUObject * );
113 int serializeTo( QUObject *, QUBuffer * ); 113 int serializeTo( QUObject *, QUBuffer * );
114 int serializeFrom( QUObject *, QUBuffer * ); 114 int serializeFrom( QUObject *, QUBuffer * );
115}; 115};
116extern Q_EXPORT QUType_Null static_QUType_Null; 116extern Q_EXPORT QUType_Null static_QUType_Null;
117 117
118 118
119// The magic QUObject 119// The magic QUObject
120struct Q_EXPORT QUObject 120struct Q_EXPORT QUObject
121{ 121{
122public: // scary MSVC bug makes this necessary 122public: // scary MSVC bug makes this necessary
123 QUObject() : type( &static_QUType_Null ) {} 123 QUObject() : type( &static_QUType_Null ) {}
124 ~QUObject() { type->clear( this ); } 124 ~QUObject() { type->clear( this ); }
125 125
126 QUType *type; 126 QUType *type;
127 127
128 // the unavoidable union 128 // the unavoidable union
129 union 129 union
130 { 130 {
131 bool b; 131 bool b;
132 132
133 char c; 133 char c;
134 short s; 134 short s;
135 int i; 135 int i;
136 long l; 136 long l;
137 137
138 unsigned char uc; 138 unsigned char uc;
139 unsigned short us; 139 unsigned short us;
140 unsigned int ui; 140 unsigned int ui;
141 unsigned long ul; 141 unsigned long ul;
142 142
143 float f; 143 float f;
144 double d; 144 double d;
145 145
146 char byte[16]; 146 char byte[16];
147 147
148 struct { 148 struct {
149 char* data; 149 char* data;
150 unsigned long size; 150 unsigned long size;
151 } bytearray; 151 } bytearray;
152 152
153 void* ptr; 153 void* ptr;
154 154
155 struct { 155 struct {
156 void *ptr; 156 void *ptr;
157 bool owner; 157 bool owner;
158 } voidstar; 158 } voidstar;
159 159
160 struct { 160 struct {
161 char *ptr; 161 char *ptr;
162 bool owner; 162 bool owner;
163 } charstar; 163 } charstar;
164 164
165 struct { 165 struct {
166 char *ptr; 166 char *ptr;
167 bool owner; 167 bool owner;
168 } utf8; 168 } utf8;
169 169
170 struct { 170 struct {
171 char *ptr; 171 char *ptr;
172 bool owner; 172 bool owner;
173 } local8bit; 173 } local8bit;
174 174
175 QUnknownInterface* iface; 175 QUnknownInterface* iface;
176 QDispatchInterface* idisp; 176 QDispatchInterface* idisp;
177 177
178 } payload; 178 } payload;
179 179
180}; 180};
181 181
182 182
183// A parameter description describes one method parameters. A 183// A parameter description describes one method parameters. A
184// parameter has a name, a type and a flag describing whether it's an 184// parameter has a name, a type and a flag describing whether it's an
185// in parameter, an out parameter, or both ways 185// in parameter, an out parameter, or both ways
186struct Q_EXPORT QUParameter 186struct Q_EXPORT QUParameter
187{ 187{
188 const char* name; 188 const char* name;
189 QUType *type; 189 QUType *type;
190 const void* typeExtra; //Usually 0, UEnum* for QUType_enum, const char* for QUType_ptr, int* for QUType_varptr 190 const void* typeExtra; //Usually 0, UEnum* for QUType_enum, const char* for QUType_ptr, int* for QUType_varptr
191 enum { In = 1, Out = 2, InOut = In | Out }; 191 enum { In = 1, Out = 2, InOut = In | Out };
192 int inOut; 192 int inOut;
193}; 193};
194 194
195// A method description describes one method. A method has a name and 195// A method description describes one method. A method has a name and
196// an array of parameters. 196// an array of parameters.
197struct Q_EXPORT QUMethod 197struct Q_EXPORT QUMethod
198{ 198{
199 const char* name; 199 const char* name;
200 int count; 200 int count;
201 const QUParameter* parameters; 201 const QUParameter* parameters;
@@ -242,49 +242,49 @@ struct Q_EXPORT QUComponentDescription
242 242
243 243
244// A component server description describe one component server, that 244// A component server description describe one component server, that
245// is its name, vendor, release, info and the descriptions of all 245// is its name, vendor, release, info and the descriptions of all
246// components it can instantiate. 246// components it can instantiate.
247struct Q_EXPORT QUComponentServerDescription 247struct Q_EXPORT QUComponentServerDescription
248{ 248{
249 const char* name; 249 const char* name;
250 const char* vendor; 250 const char* vendor;
251 const char* release; 251 const char* release;
252 const char* info; 252 const char* info;
253 int count; 253 int count;
254 const QUComponentDescription* components; 254 const QUComponentDescription* components;
255}; 255};
256 256
257 257
258 258
259 struct Q_EXPORT QUEnumItem // - a name/value pair 259 struct Q_EXPORT QUEnumItem // - a name/value pair
260{ 260{
261 const char *key; 261 const char *key;
262 int value; 262 int value;
263}; 263};
264 264
265struct Q_EXPORT QUEnum 265struct Q_EXPORT QUEnum
266 { 266{
267 const char *name; // - enumerator name 267 const char *name; // - enumerator name
268 unsigned int count; // - number of values 268 unsigned int count; // - number of values
269 const QUEnumItem *items; // - the name/value pairs 269 const QUEnumItem *items; // - the name/value pairs
270 bool set; // whether enum has to be treated as a set 270 bool set; // whether enum has to be treated as a set
271}; 271};
272 272
273inline bool QUType::isEqual( const QUType *t1, const QUType *t2 ) { 273inline bool QUType::isEqual( const QUType *t1, const QUType *t2 ) {
274 return t1 == t2 || t1->uuid() == t2->uuid() || 274 return t1 == t2 || t1->uuid() == t2->uuid() ||
275 *(t1->uuid()) == *(t2->uuid()); 275 *(t1->uuid()) == *(t2->uuid());
276} 276}
277 277
278inline bool QUType::check( QUObject* o, QUType* t ) { 278inline bool QUType::check( QUObject* o, QUType* t ) {
279 return isEqual( o->type, t ) || t->convertFrom( o, o->type ); 279 return isEqual( o->type, t ) || t->convertFrom( o, o->type );
280} 280}
281 281
282 282
283 283
284// {7EE17B08-5419-47e2-9776-8EEA112DCAEC} 284// {7EE17B08-5419-47e2-9776-8EEA112DCAEC}
285extern Q_EXPORT const QUuid TID_QUType_enum; 285extern Q_EXPORT const QUuid TID_QUType_enum;
286struct Q_EXPORT QUType_enum : public QUType 286struct Q_EXPORT QUType_enum : public QUType
287{ 287{
288 const QUuid *uuid() const; 288 const QUuid *uuid() const;
289 const char *desc() const; 289 const char *desc() const;
290 290
@@ -375,125 +375,89 @@ struct Q_EXPORT QUType_bool : public QUType
375 int serializeTo( QUObject *, QUBuffer * ); 375 int serializeTo( QUObject *, QUBuffer * );
376 int serializeFrom( QUObject *, QUBuffer * ); 376 int serializeFrom( QUObject *, QUBuffer * );
377}; 377};
378extern Q_EXPORT QUType_bool static_QUType_bool; 378extern Q_EXPORT QUType_bool static_QUType_bool;
379 379
380// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5} 380// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
381extern Q_EXPORT const QUuid TID_QUType_int; 381extern Q_EXPORT const QUuid TID_QUType_int;
382struct Q_EXPORT QUType_int : public QUType 382struct Q_EXPORT QUType_int : public QUType
383{ 383{
384 const QUuid *uuid() const; 384 const QUuid *uuid() const;
385 const char *desc() const; 385 const char *desc() const;
386 386
387 void set( QUObject *, int ); 387 void set( QUObject *, int );
388 int &get( QUObject *o ) { return o->payload.i; } 388 int &get( QUObject *o ) { return o->payload.i; }
389 bool canConvertFrom( QUObject *, QUType * ); 389 bool canConvertFrom( QUObject *, QUType * );
390 bool canConvertTo( QUObject *, QUType * ); 390 bool canConvertTo( QUObject *, QUType * );
391 bool convertFrom( QUObject *, QUType * ); 391 bool convertFrom( QUObject *, QUType * );
392 bool convertTo( QUObject *, QUType * ); 392 bool convertTo( QUObject *, QUType * );
393 void clear( QUObject * ) {} 393 void clear( QUObject * ) {}
394 int serializeTo( QUObject *, QUBuffer * ); 394 int serializeTo( QUObject *, QUBuffer * );
395 int serializeFrom( QUObject *, QUBuffer * ); 395 int serializeFrom( QUObject *, QUBuffer * );
396}; 396};
397extern Q_EXPORT QUType_int static_QUType_int; 397extern Q_EXPORT QUType_int static_QUType_int;
398 398
399// {5938712A-C496-11D5-8CB2-00C0F03BC0F3}
400extern Q_EXPORT const QUuid TID_QUType_uint;
401struct Q_EXPORT QUType_uint : public QUType
402{
403 const QUuid *uuid() const;
404 const char *desc() const;
405
406 void set( QUObject *, uint );
407 uint &get( QUObject *o ) { return o->payload.ui; }
408 bool canConvertFrom( QUObject *, QUType * );
409 bool canConvertTo( QUObject *, QUType * );
410 bool convertFrom( QUObject *, QUType * );
411 bool convertTo( QUObject *, QUType * );
412 void clear( QUObject * ) {}
413 int serializeTo( QUObject *, QUBuffer * );
414 int serializeFrom( QUObject *, QUBuffer * );
415};
416extern Q_EXPORT QUType_uint static_QUType_uint;
417 399
418// {2D0974E5-0BA6-4ec2-8837-C198972CB48C} 400// {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
419extern Q_EXPORT const QUuid TID_QUType_double; 401extern Q_EXPORT const QUuid TID_QUType_double;
420struct Q_EXPORT QUType_double : public QUType 402struct Q_EXPORT QUType_double : public QUType
421{ 403{
422 const QUuid *uuid() const; 404 const QUuid *uuid() const;
423 const char *desc() const; 405 const char *desc() const;
424 406
425 void set( QUObject *, double ); 407 void set( QUObject *, double );
426 double &get( QUObject *o ) { return o->payload.d; } 408 double &get( QUObject *o ) { return o->payload.d; }
427 bool canConvertFrom( QUObject *, QUType * ); 409 bool canConvertFrom( QUObject *, QUType * );
428 bool canConvertTo( QUObject *, QUType * ); 410 bool canConvertTo( QUObject *, QUType * );
429 bool convertFrom( QUObject *, QUType * ); 411 bool convertFrom( QUObject *, QUType * );
430 bool convertTo( QUObject *, QUType * ); 412 bool convertTo( QUObject *, QUType * );
431 void clear( QUObject * ) {} 413 void clear( QUObject * ) {}
432 int serializeTo( QUObject *, QUBuffer * ); 414 int serializeTo( QUObject *, QUBuffer * );
433 int serializeFrom( QUObject *, QUBuffer * ); 415 int serializeFrom( QUObject *, QUBuffer * );
434}; 416};
435extern Q_EXPORT QUType_double static_QUType_double; 417extern Q_EXPORT QUType_double static_QUType_double;
436 418
437// {544C5175-6993-4486-B04D-CEC4D21BF4B9 }
438extern Q_EXPORT const QUuid TID_QUType_float;
439struct Q_EXPORT QUType_float : public QUType
440{
441 const QUuid *uuid() const;
442 const char *desc() const;
443
444 void set( QUObject *, float );
445 float &get( QUObject *o ) { return o->payload.f; }
446 bool canConvertFrom( QUObject *, QUType * );
447 bool canConvertTo( QUObject *, QUType * );
448 bool convertFrom( QUObject *, QUType * );
449 bool convertTo( QUObject *, QUType * );
450 void clear( QUObject * ) {}
451 int serializeTo( QUObject *, QUBuffer * );
452 int serializeFrom( QUObject *, QUBuffer * );
453};
454extern Q_EXPORT QUType_float static_QUType_float;
455 419
456// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9} 420// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
457extern Q_EXPORT const QUuid TID_QUType_charstar; 421extern Q_EXPORT const QUuid TID_QUType_charstar;
458struct Q_EXPORT QUType_charstar : public QUType 422struct Q_EXPORT QUType_charstar : public QUType
459{ 423{
460 const QUuid *uuid() const; 424 const QUuid *uuid() const;
461 const char *desc() const; 425 const char *desc() const;
462 426
463 void set( QUObject *, const char*, bool take = FALSE ); 427 void set( QUObject *, const char*, bool take = FALSE );
464 char* get( QUObject *o ){ return o->payload.charstar.ptr; } 428 char* get( QUObject *o ){ return o->payload.charstar.ptr; }
465 bool canConvertFrom( QUObject *, QUType * ); 429 bool canConvertFrom( QUObject *, QUType * );
466 bool canConvertTo( QUObject *, QUType * ); 430 bool canConvertTo( QUObject *, QUType * );
467 bool convertFrom( QUObject *, QUType * ); 431 bool convertFrom( QUObject *, QUType * );
468 bool convertTo( QUObject *, QUType * ); 432 bool convertTo( QUObject *, QUType * );
469 void clear( QUObject * ); 433 void clear( QUObject * );
470 int serializeTo( QUObject *, QUBuffer * ); 434 int serializeTo( QUObject *, QUBuffer * );
471 int serializeFrom( QUObject *, QUBuffer * ); 435 int serializeFrom( QUObject *, QUBuffer * );
472 436
473}; 437};
474extern Q_EXPORT QUType_charstar static_QUType_charstar; 438extern Q_EXPORT QUType_charstar static_QUType_charstar;
475 439
476// {44C2A547-01E7-4e56-8559-35AF9D2F42B7} 440// {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
477extern const QUuid TID_QUType_QString; 441extern const QUuid TID_QUType_QString;
478 442
479struct Q_EXPORT QUType_QString : public QUType 443struct Q_EXPORT QUType_QString : public QUType
480{ 444{
481 const QUuid *uuid() const; 445 const QUuid *uuid() const;
482 const char *desc() const; 446 const char *desc() const;
483 447
484 void set( QUObject *, const QString & ); 448 void set( QUObject *, const QString & );
485 QString &get( QUObject * o ) { return *(QString*)o->payload.ptr; } 449 QString &get( QUObject * o ) { return *(QString*)o->payload.ptr; }
486 450
487 bool canConvertFrom( QUObject *, QUType * ); 451 bool canConvertFrom( QUObject *, QUType * );
488 bool canConvertTo( QUObject *, QUType * ); 452 bool canConvertTo( QUObject *, QUType * );
489 bool convertFrom( QUObject *, QUType * ); 453 bool convertFrom( QUObject *, QUType * );
490 bool convertTo( QUObject *, QUType * ); 454 bool convertTo( QUObject *, QUType * );
491 void clear( QUObject * ); 455 void clear( QUObject * );
492 int serializeTo( QUObject *, QUBuffer * ); 456 int serializeTo( QUObject *, QUBuffer * );
493 int serializeFrom( QUObject *, QUBuffer * ); 457 int serializeFrom( QUObject *, QUBuffer * );
494 458
495}; 459};
496extern Q_EXPORT QUType_QString static_QUType_QString; 460extern Q_EXPORT QUType_QString static_QUType_QString;
497 461
498 462
499#endif // QUCOM_H 463#endif // QUCOM_P_H
diff --git a/qmake/include/private/qucomextra_p.h b/qmake/include/private/qucomextra_p.h
index 3de6104..fe39692 100644
--- a/qmake/include/private/qucomextra_p.h
+++ b/qmake/include/private/qucomextra_p.h
@@ -14,50 +14,62 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QUCOMEXTRA_H 38#ifndef QUCOMEXTRA_P_H
39#define QUCOMEXTRA_H 39#define QUCOMEXTRA_P_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. This header file may
46// change from version to version without notice, or even be
47// removed.
48//
49// We mean it.
50//
51//
40 52
41#ifndef QT_H 53#ifndef QT_H
42#include <private/qucom_p.h> 54#include <private/qucom_p.h>
43#endif // QT_H 55#endif // QT_H
44 56
45 57
46class QVariant; 58class QVariant;
47 59
48#ifndef QT_NO_VARIANT 60#ifndef QT_NO_VARIANT
49// 6dc75d58-a1d9-4417-b591-d45c63a3a4ea 61// 6dc75d58-a1d9-4417-b591-d45c63a3a4ea
50extern const QUuid TID_QUType_QVariant; 62extern const QUuid TID_QUType_QVariant;
51 63
52struct Q_EXPORT QUType_QVariant : public QUType 64struct Q_EXPORT QUType_QVariant : public QUType
53{ 65{
54 const QUuid *uuid() const; 66 const QUuid *uuid() const;
55 const char *desc() const; 67 const char *desc() const;
56 68
57 void set( QUObject *, const QVariant & ); 69 void set( QUObject *, const QVariant & );
58 QVariant &get( QUObject * o ); 70 QVariant &get( QUObject * o );
59 71
60 bool canConvertFrom( QUObject *, QUType * ); 72 bool canConvertFrom( QUObject *, QUType * );
61 bool canConvertTo( QUObject *, QUType * ); 73 bool canConvertTo( QUObject *, QUType * );
62 bool convertFrom( QUObject *, QUType * ); 74 bool convertFrom( QUObject *, QUType * );
63 bool convertTo( QUObject *, QUType * ); 75 bool convertTo( QUObject *, QUType * );
@@ -68,26 +80,26 @@ struct Q_EXPORT QUType_QVariant : public QUType
68extern Q_EXPORT QUType_QVariant static_QUType_QVariant; 80extern Q_EXPORT QUType_QVariant static_QUType_QVariant;
69#endif //QT_NO_VARIANT 81#endif //QT_NO_VARIANT
70 82
71 83
72// {0x8d48b3a8, 0xbd7f, 0x11d5, 0x8d, 0x74, 0x00, 0xc0, 0xf0, 0x3b, 0xc0, 0xf3 } 84// {0x8d48b3a8, 0xbd7f, 0x11d5, 0x8d, 0x74, 0x00, 0xc0, 0xf0, 0x3b, 0xc0, 0xf3 }
73extern Q_EXPORT const QUuid TID_QUType_varptr; 85extern Q_EXPORT const QUuid TID_QUType_varptr;
74struct Q_EXPORT QUType_varptr : public QUType 86struct Q_EXPORT QUType_varptr : public QUType
75{ 87{
76 const QUuid *uuid() const; 88 const QUuid *uuid() const;
77 const char *desc() const; 89 const char *desc() const;
78 90
79 void set( QUObject *, const void* ); 91 void set( QUObject *, const void* );
80 void* &get( QUObject * o ) { return o->payload.ptr; } 92 void* &get( QUObject * o ) { return o->payload.ptr; }
81 bool canConvertFrom( QUObject *, QUType * ); 93 bool canConvertFrom( QUObject *, QUType * );
82 bool canConvertTo( QUObject *, QUType * ); 94 bool canConvertTo( QUObject *, QUType * );
83 bool convertFrom( QUObject *, QUType * ); 95 bool convertFrom( QUObject *, QUType * );
84 bool convertTo( QUObject *, QUType * ); 96 bool convertTo( QUObject *, QUType * );
85 void clear( QUObject * ) {} 97 void clear( QUObject * ) {}
86 int serializeTo( QUObject *, QUBuffer * ); 98 int serializeTo( QUObject *, QUBuffer * );
87 int serializeFrom( QUObject *, QUBuffer * ); 99 int serializeFrom( QUObject *, QUBuffer * );
88}; 100};
89extern Q_EXPORT QUType_varptr static_QUType_varptr; 101extern Q_EXPORT QUType_varptr static_QUType_varptr;
90 102
91 103
92#endif // QUCOMEXTRA_H 104#endif // QUCOMEXTRA_P_H
93 105
diff --git a/qmake/include/private/qwidgetinterface_p.h b/qmake/include/private/qwidgetinterface_p.h
index 5b5776b..78e9aad 100644
--- a/qmake/include/private/qwidgetinterface_p.h
+++ b/qmake/include/private/qwidgetinterface_p.h
@@ -1,67 +1,81 @@
1 /********************************************************************** 1/****************************************************************************
2** Copyright (C) 2000-2001 Trolltech AS. All rights reserved. 2** $Id$
3** 3**
4** This file is part of Qt Designer. 4** ...
5**
6** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the widgets module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
5** 13**
6** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 17** packaging of this file.
10** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 30**
16** Contact info@trolltech.com if any conditions of this licensing are 31** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 32** not clear to you.
18** 33**
19**********************************************************************/ 34**********************************************************************/
20 35
21#ifndef QWIDGETINTERFACE_H 36#ifndef QWIDGETINTERFACE_P_H
22#define QWIDGETINTERFACE_H 37#define QWIDGETINTERFACE_P_H
23
24
25#ifndef QT_H
26#include <private/qcom_p.h>
27#include <qiconset.h>
28#endif // QT_H
29
30#ifndef QT_NO_WIDGETPLUGIN
31 38
32// 39//
33// W A R N I N G 40// W A R N I N G
34// ------------- 41// -------------
35// 42//
36// This file is not part of the Qt API. It exists for the convenience 43// This file is not part of the Qt API. It exists for the convenience
37// of a number of Qt sources files. This header file may change from 44// of a number of Qt sources files. This header file may change from
38// version to version without notice, or even be removed. 45// version to version without notice, or even be removed.
39// 46//
40// We mean it. 47// We mean it.
41// 48//
42// 49//
43 50
51#ifndef QT_H
52#include <private/qcom_p.h>
53#include <qiconset.h>
54#endif // QT_H
55
56#ifndef QT_NO_WIDGETPLUGIN
57
44class QWidget; 58class QWidget;
45 59
46// {55184143-f18f-42c0-a8eb-71c01516019a} 60// {55184143-f18f-42c0-a8eb-71c01516019a}
47#ifndef IID_QWidgetFactory 61#ifndef IID_QWidgetFactory
48#define IID_QWidgetFactory QUuid( 0x55184143, 0xf18f, 0x42c0, 0xa8, 0xeb, 0x71, 0xc0, 0x15, 0x16, 0x1, 0x9a ) 62#define IID_QWidgetFactory QUuid( 0x55184143, 0xf18f, 0x42c0, 0xa8, 0xeb, 0x71, 0xc0, 0x15, 0x16, 0x1, 0x9a )
49#endif 63#endif
50 64
51/*! To add custom widgets to the Qt Designer, implement that interface 65/*! To add custom widgets to the Qt Designer, implement that interface
52 in your custom widget plugin. 66 in your custom widget plugin.
53 67
54 You also have to implement the function featureList() (\sa 68 You also have to implement the function featureList() (\sa
55 QFeatureListInterface) and return there all widgets (names of it) 69 QFeatureListInterface) and return there all widgets (names of it)
56 which this interface provides. 70 which this interface provides.
57*/ 71*/
58 72
59struct QWidgetFactoryInterface : public QFeatureListInterface 73struct QWidgetFactoryInterface : public QFeatureListInterface
60{ 74{
61public: 75public:
62 76
63 /*! In the implementation create and return the widget \a widget 77 /*! In the implementation create and return the widget \a widget
64 here, use \a parent and \a name when creating the widget */ 78 here, use \a parent and \a name when creating the widget */
65 virtual QWidget* create( const QString &widget, QWidget* parent = 0, const char* name = 0 ) = 0; 79 virtual QWidget* create( const QString &widget, QWidget* parent = 0, const char* name = 0 ) = 0;
66 80
67 /*! In the implementation return the name of the group of the 81 /*! In the implementation return the name of the group of the
@@ -71,41 +85,56 @@ public:
71 /*! In the implementation return the iconset, which should be used 85 /*! In the implementation return the iconset, which should be used
72 in the Qt Designer menubar and toolbar to represent the widget 86 in the Qt Designer menubar and toolbar to represent the widget
73 \a widget */ 87 \a widget */
74 virtual QIconSet iconSet( const QString &widget ) const = 0; 88 virtual QIconSet iconSet( const QString &widget ) const = 0;
75 89
76 /*! In the implementation return the include file which is needed 90 /*! In the implementation return the include file which is needed
77 for the widget \a widget in the generated code which uic 91 for the widget \a widget in the generated code which uic
78 generates. */ 92 generates. */
79 virtual QString includeFile( const QString &widget ) const = 0; 93 virtual QString includeFile( const QString &widget ) const = 0;
80 94
81 /*! In the implementation return the text which should be 95 /*! In the implementation return the text which should be
82 displayed as tooltip for the widget \a widget */ 96 displayed as tooltip for the widget \a widget */
83 virtual QString toolTip( const QString &widget ) const = 0; 97 virtual QString toolTip( const QString &widget ) const = 0;
84 98
85 /*! In the implementation return the text which should be used for 99 /*! In the implementation return the text which should be used for
86 what's this help for the widget \a widget. */ 100 what's this help for the widget \a widget. */
87 virtual QString whatsThis( const QString &widget ) const = 0; 101 virtual QString whatsThis( const QString &widget ) const = 0;
88 102
89 /*! In the implementation return TRUE here, of the \a widget 103 /*! In the implementation return TRUE here, of the \a widget
90 should be able to contain other widget in the Qt Designer, else 104 should be able to contain other widget in the Qt Designer, else
91 FALSE. */ 105 FALSE. */
92 virtual bool isContainer( const QString &widget ) const = 0; 106 virtual bool isContainer( const QString &widget ) const = 0;
93}; 107};
94 108
95#if CONTAINER_CUSTOM_WIDGETS 109#ifdef QT_CONTAINER_CUSTOM_WIDGETS
96// {15976628-e3c3-47f4-b525-d124a3caf30e} 110// {15976628-e3c3-47f4-b525-d124a3caf30e}
97#ifndef IID_QWidgetContainer 111#ifndef IID_QWidgetContainer
98#define IID_QWidgetContainer QUuid( 0x15976628, 0xe3c3, 0x47f4, 0xb5, 0x25, 0xd1, 0x24, 0xa3, 0xca, 0xf3, 0x0e ) 112#define IID_QWidgetContainer QUuid( 0x15976628, 0xe3c3, 0x47f4, 0xb5, 0x25, 0xd1, 0x24, 0xa3, 0xca, 0xf3, 0x0e )
99#endif 113#endif
100 114
101struct QWidgetContainerInterfacePrivate : public QUnknownInterface 115struct QWidgetContainerInterfacePrivate : public QUnknownInterface
102{ 116{
103public: 117public:
104 virtual QWidget *containerOfWidget( QWidget *widget ) const = 0; 118 virtual QWidget *containerOfWidget( const QString &f, QWidget *container ) const = 0;
105 virtual QWidgetList containersOf( QWidget *widget ) const = 0; 119 virtual bool isPassiveInteractor( const QString &f, QWidget *container ) const = 0;
106 virtual bool isPassiveInteractor( QWidget *widget ) const = 0; 120
121 virtual bool supportsPages( const QString &f ) const = 0;
122
123 virtual QWidget *addPage( const QString &f, QWidget *container,
124 const QString &name, int index ) const = 0;
125 virtual void insertPage( const QString &f, QWidget *container,
126 const QString &name, int index, QWidget *page ) const = 0;
127 virtual void removePage( const QString &f, QWidget *container, int index ) const = 0;
128 virtual void movePage( const QString &f, QWidget *container, int fromIndex, int toIndex ) const = 0;
129 virtual int count( const QString &key, QWidget *container ) const = 0;
130 virtual int currentIndex( const QString &key, QWidget *container ) const = 0;
131 virtual QString pageLabel( const QString &key, QWidget *container, int index ) const = 0;
132 virtual QWidget *page( const QString &key, QWidget *container, int index ) const = 0;
133 virtual void renamePage( const QString &key, QWidget *container,
134 int index, const QString &newName ) const = 0;
135 virtual QWidgetList pages( const QString &f, QWidget *container ) const = 0;
107}; 136};
108#endif 137#endif
109 138
110#endif // QT_NO_WIDGETPLUGIN 139#endif // QT_NO_WIDGETPLUGIN
111#endif // QWIDGETINTERFACE_H 140#endif // QWIDGETINTERFACE_P_H
diff --git a/qmake/include/private/qwidgetresizehandler_p.h b/qmake/include/private/qwidgetresizehandler_p.h
index ca229db..9297832 100644
--- a/qmake/include/private/qwidgetresizehandler_p.h
+++ b/qmake/include/private/qwidgetresizehandler_p.h
@@ -1,63 +1,75 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of the QWidgetResizeHandler class 4** Definition of the QWidgetResizeHandler class
5** 5**
6** Created : 001010 6** Created : 001010
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the workspace module of the Qt GUI Toolkit. 10** This file is part of the workspace module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QWIDGETRESIZEHANDLER_H 38#ifndef QWIDGETRESIZEHANDLER_P_H
39#define QWIDGETRESIZEHANDLER_H 39#define QWIDGETRESIZEHANDLER_P_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. This header file may
46// change from version to version without notice, or even be
47// removed.
48//
49// We mean it.
50//
51//
40 52
41#ifndef QT_H 53#ifndef QT_H
42#include "qobject.h" 54#include "qobject.h"
43#endif // QT_H 55#endif // QT_H
44#ifndef QT_NO_RESIZEHANDLER 56#ifndef QT_NO_RESIZEHANDLER
45class QMouseEvent; 57class QMouseEvent;
46class QKeyEvent; 58class QKeyEvent;
47 59
48class Q_EXPORT QWidgetResizeHandler : public QObject 60class Q_EXPORT QWidgetResizeHandler : public QObject
49{ 61{
50 Q_OBJECT 62 Q_OBJECT
51 63
52public: 64public:
53 QWidgetResizeHandler( QWidget *parent, QWidget *cw = 0, const char *name = 0 ); 65 QWidgetResizeHandler( QWidget *parent, QWidget *cw = 0, const char *name = 0 );
54 void setActive( bool b ) { active = b; if ( !active ) setMouseCursor( Nowhere ); } 66 void setActive( bool b ) { active = b; if ( !active ) setMouseCursor( Nowhere ); }
55 bool isActive() const { return active; } 67 bool isActive() const { return active; }
56 void setMovingEnabled( bool b ) { moving = b; } 68 void setMovingEnabled( bool b ) { moving = b; }
57 bool isMovingEnabled() const { return moving; } 69 bool isMovingEnabled() const { return moving; }
58 70
59 bool isButtonDown() const { return buttonDown; } 71 bool isButtonDown() const { return buttonDown; }
60 72
61 void setExtraHeight( int h ) { extrahei = h; } 73 void setExtraHeight( int h ) { extrahei = h; }
62 void setSizeProtection( bool b ) { sizeprotect = b; } 74 void setSizeProtection( bool b ) { sizeprotect = b; }
63 75
diff --git a/qmake/include/qasciidict.h b/qmake/include/qasciidict.h
index 8f344cd..ecd9c9f 100644
--- a/qmake/include/qasciidict.h
+++ b/qmake/include/qasciidict.h
@@ -94,25 +94,29 @@ template<> inline void QAsciiDict<void>::deleteItem( QPtrCollection::Item )
94 94
95template<class type> inline void QAsciiDict<type>::deleteItem( QPtrCollection::Item d ) 95template<class type> inline void QAsciiDict<type>::deleteItem( QPtrCollection::Item d )
96{ 96{
97 if ( del_item ) delete (type *)d; 97 if ( del_item ) delete (type *)d;
98} 98}
99 99
100template<class type> 100template<class type>
101class QAsciiDictIterator : public QGDictIterator 101class QAsciiDictIterator : public QGDictIterator
102{ 102{
103public: 103public:
104 QAsciiDictIterator(const QAsciiDict<type> &d) 104 QAsciiDictIterator(const QAsciiDict<type> &d)
105 : QGDictIterator((QGDict &)d) {} 105 : QGDictIterator((QGDict &)d) {}
106 ~QAsciiDictIterator() {} 106 ~QAsciiDictIterator() {}
107 uint count() const { return dict->count(); } 107 uint count() const { return dict->count(); }
108 bool isEmpty() const { return dict->count() == 0; } 108 bool isEmpty() const { return dict->count() == 0; }
109 type *toFirst() { return (type *)QGDictIterator::toFirst(); } 109 type *toFirst() { return (type *)QGDictIterator::toFirst(); }
110 operator type *() const { return (type *)QGDictIterator::get(); } 110 operator type *() const { return (type *)QGDictIterator::get(); }
111 type *current() const { return (type *)QGDictIterator::get(); } 111 type *current() const { return (type *)QGDictIterator::get(); }
112 const char *currentKey() const { return QGDictIterator::getKeyAscii(); } 112 const char *currentKey() const { return QGDictIterator::getKeyAscii(); }
113 type *operator()() { return (type *)QGDictIterator::operator()(); } 113 type *operator()() { return (type *)QGDictIterator::operator()(); }
114 type *operator++() { return (type *)QGDictIterator::operator++(); } 114 type *operator++() { return (type *)QGDictIterator::operator++(); }
115 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} 115 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);}
116}; 116};
117 117
118#ifdef QT_QWINEXPORT
119#define Q_DEFINED_QASCIIDICT
120#include "qwinexport.h"
121#endif /* QT_QWINEXPORT */
118#endif // QASCIIDICT_H 122#endif // QASCIIDICT_H
diff --git a/qmake/include/qcstring.h b/qmake/include/qcstring.h
index 004bb3b..6b7352a 100644
--- a/qmake/include/qcstring.h
+++ b/qmake/include/qcstring.h
@@ -80,51 +80,53 @@ Q_EXPORT int qstrnicmp( const char *, const char *, uint len );
80 80
81#ifndef QT_CLEAN_NAMESPACE 81#ifndef QT_CLEAN_NAMESPACE
82Q_EXPORT inline uint cstrlen( const char *str ) 82Q_EXPORT inline uint cstrlen( const char *str )
83{ return (uint)strlen(str); } 83{ return (uint)strlen(str); }
84 84
85Q_EXPORT inline char *cstrcpy( char *dst, const char *src ) 85Q_EXPORT inline char *cstrcpy( char *dst, const char *src )
86{ return strcpy(dst,src); } 86{ return strcpy(dst,src); }
87 87
88Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 ) 88Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 )
89{ return strcmp(str1,str2); } 89{ return strcmp(str1,str2); }
90 90
91Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len ) 91Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len )
92{ return strncmp(str1,str2,len); } 92{ return strncmp(str1,str2,len); }
93#endif 93#endif
94 94
95 95
96// qChecksum: Internet checksum 96// qChecksum: Internet checksum
97 97
98Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len ); 98Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len );
99 99
100/***************************************************************************** 100/*****************************************************************************
101 QByteArray class 101 QByteArray class
102 *****************************************************************************/ 102 *****************************************************************************/
103 103
104#ifndef QT_QWINEXPORT
104#if defined(Q_TEMPLATEDLL) 105#if defined(Q_TEMPLATEDLL)
105Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<char>; 106Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<char>;
106#endif 107#endif
108#endif /* QT_QWINEXPORT */
107 109
108#if defined(Q_QDOC) 110#if defined(Q_QDOC)
109/* 111/*
110 We want qdoc to document QByteArray as a real class that inherits 112 We want qdoc to document QByteArray as a real class that inherits
111 QMemArray<char> and that is inherited by QBitArray. 113 QMemArray<char> and that is inherited by QBitArray.
112*/ 114*/
113class QByteArray : public QMemArray<char> 115class QByteArray : public QMemArray<char>
114{ 116{
115public: 117public:
116 QByteArray(); 118 QByteArray();
117 QByteArray( int size ); 119 QByteArray( int size );
118}; 120};
119#else 121#else
120typedef QMemArray<char> QByteArray; 122typedef QMemArray<char> QByteArray;
121#endif 123#endif
122 124
123#ifndef QT_NO_COMPRESS 125#ifndef QT_NO_COMPRESS
124Q_EXPORT QByteArray qCompress( const uchar* data, int nbytes ); 126Q_EXPORT QByteArray qCompress( const uchar* data, int nbytes );
125Q_EXPORT QByteArray qUncompress( const uchar* data, int nbytes ); 127Q_EXPORT QByteArray qUncompress( const uchar* data, int nbytes );
126Q_EXPORT inline QByteArray qCompress( const QByteArray& data) 128Q_EXPORT inline QByteArray qCompress( const QByteArray& data)
127{ return qCompress( (const uchar*)data.data(), data.size() ); } 129{ return qCompress( (const uchar*)data.data(), data.size() ); }
128Q_EXPORT inline QByteArray qUncompress( const QByteArray& data ) 130Q_EXPORT inline QByteArray qUncompress( const QByteArray& data )
129{ return qUncompress( (const uchar*)data.data(), data.size() ); } 131{ return qUncompress( (const uchar*)data.data(), data.size() ); }
130#endif 132#endif
@@ -211,48 +213,50 @@ public:
211 short toShort( bool *ok=0 )const; 213 short toShort( bool *ok=0 )const;
212 ushort toUShort( bool *ok=0 )const; 214 ushort toUShort( bool *ok=0 )const;
213 int toInt( bool *ok=0 )const; 215 int toInt( bool *ok=0 )const;
214 uint toUInt( bool *ok=0 )const; 216 uint toUInt( bool *ok=0 )const;
215 long toLong( bool *ok=0 )const; 217 long toLong( bool *ok=0 )const;
216 ulong toULong( bool *ok=0 )const; 218 ulong toULong( bool *ok=0 )const;
217 float toFloat( bool *ok=0 )const; 219 float toFloat( bool *ok=0 )const;
218 double toDouble( bool *ok=0 )const; 220 double toDouble( bool *ok=0 )const;
219 221
220 QCString &setStr( const char *s ); 222 QCString &setStr( const char *s );
221 QCString &setNum( short ); 223 QCString &setNum( short );
222 QCString &setNum( ushort ); 224 QCString &setNum( ushort );
223 QCString &setNum( int ); 225 QCString &setNum( int );
224 QCString &setNum( uint ); 226 QCString &setNum( uint );
225 QCString &setNum( long ); 227 QCString &setNum( long );
226 QCString &setNum( ulong ); 228 QCString &setNum( ulong );
227 QCString &setNum( float, char f='g', int prec=6 ); 229 QCString &setNum( float, char f='g', int prec=6 );
228 QCString &setNum( double, char f='g', int prec=6 ); 230 QCString &setNum( double, char f='g', int prec=6 );
229 231
230 boolsetExpand( uint index, char c ); 232 boolsetExpand( uint index, char c );
231 233
232 operator const char *() const; 234 operator const char *() const;
233 QCString &operator+=( const char *str ); 235 QCString &operator+=( const char *str );
234 QCString &operator+=( char c ); 236 QCString &operator+=( char c );
237private:
238 intfind( const char *str, int index, bool cs, uint l ) const;
235}; 239};
236 240
237 241
238/***************************************************************************** 242/*****************************************************************************
239 QCString stream functions 243 QCString stream functions
240 *****************************************************************************/ 244 *****************************************************************************/
241#ifndef QT_NO_DATASTREAM 245#ifndef QT_NO_DATASTREAM
242Q_EXPORT QDataStream &operator<<( QDataStream &, const QCString & ); 246Q_EXPORT QDataStream &operator<<( QDataStream &, const QCString & );
243Q_EXPORT QDataStream &operator>>( QDataStream &, QCString & ); 247Q_EXPORT QDataStream &operator>>( QDataStream &, QCString & );
244#endif 248#endif
245 249
246/***************************************************************************** 250/*****************************************************************************
247 QCString inline functions 251 QCString inline functions
248 *****************************************************************************/ 252 *****************************************************************************/
249 253
250inline QCString &QCString::operator=( const QCString &s ) 254inline QCString &QCString::operator=( const QCString &s )
251{ return (QCString&)assign( s ); } 255{ return (QCString&)assign( s ); }
252 256
253inline QCString &QCString::operator=( const char *str ) 257inline QCString &QCString::operator=( const char *str )
254{ return (QCString&)duplicate( str, qstrlen(str)+1 ); } 258{ return (QCString&)duplicate( str, qstrlen(str)+1 ); }
255 259
256inline bool QCString::isNull() const 260inline bool QCString::isNull() const
257{ return data() == 0; } 261{ return data() == 0; }
258 262
@@ -367,25 +371,28 @@ Q_EXPORT inline const QCString operator+( const QCString &s1, const char *s2 )
367} 371}
368 372
369Q_EXPORT inline const QCString operator+( const char *s1, const QCString &s2 ) 373Q_EXPORT inline const QCString operator+( const char *s1, const QCString &s2 )
370{ 374{
371 QCString tmp( s1 ); 375 QCString tmp( s1 );
372 tmp += s2; 376 tmp += s2;
373 return tmp; 377 return tmp;
374} 378}
375 379
376Q_EXPORT inline const QCString operator+( const QCString &s1, char c2 ) 380Q_EXPORT inline const QCString operator+( const QCString &s1, char c2 )
377{ 381{
378 QCString tmp( s1.data() ); 382 QCString tmp( s1.data() );
379 tmp += c2; 383 tmp += c2;
380 return tmp; 384 return tmp;
381} 385}
382 386
383Q_EXPORT inline const QCString operator+( char c1, const QCString &s2 ) 387Q_EXPORT inline const QCString operator+( char c1, const QCString &s2 )
384{ 388{
385 QCString tmp; 389 QCString tmp;
386 tmp += c1; 390 tmp += c1;
387 tmp += s2; 391 tmp += s2;
388 return tmp; 392 return tmp;
389} 393}
390 394
395#ifdef QT_QWINEXPORT
396#include <qwinexport.h>
397#endif /* QT_QWINEXPORT */
391#endif // QCSTRING_H 398#endif // QCSTRING_H
diff --git a/qmake/include/qdict.h b/qmake/include/qdict.h
index 04ae7bf..d8943ad 100644
--- a/qmake/include/qdict.h
+++ b/qmake/include/qdict.h
@@ -94,25 +94,29 @@ template<> inline void QDict<void>::deleteItem( Item )
94 94
95template<class type> inline void QDict<type>::deleteItem( QPtrCollection::Item d ) 95template<class type> inline void QDict<type>::deleteItem( QPtrCollection::Item d )
96{ 96{
97 if ( del_item ) delete (type *)d; 97 if ( del_item ) delete (type *)d;
98} 98}
99 99
100template<class type> 100template<class type>
101class QDictIterator : public QGDictIterator 101class QDictIterator : public QGDictIterator
102{ 102{
103public: 103public:
104 QDictIterator(const QDict<type> &d) : QGDictIterator((QGDict &)d) { } 104 QDictIterator(const QDict<type> &d) : QGDictIterator((QGDict &)d) { }
105 ~QDictIterator() {} 105 ~QDictIterator() {}
106 uint count() const { return dict->count(); } 106 uint count() const { return dict->count(); }
107 bool isEmpty() const { return dict->count() == 0; } 107 bool isEmpty() const { return dict->count() == 0; }
108 type *toFirst() { return (type *)QGDictIterator::toFirst(); } 108 type *toFirst() { return (type *)QGDictIterator::toFirst(); }
109 operator type *() const { return (type *)QGDictIterator::get(); } 109 operator type *() const { return (type *)QGDictIterator::get(); }
110 type *operator*() { return (type *)QGDictIterator::get(); } 110 type *operator*() { return (type *)QGDictIterator::get(); }
111 type *current() const { return (type *)QGDictIterator::get(); } 111 type *current() const { return (type *)QGDictIterator::get(); }
112 QString currentKey() const{ return QGDictIterator::getKeyString(); } 112 QString currentKey() const{ return QGDictIterator::getKeyString(); }
113 type *operator()() { return (type *)QGDictIterator::operator()(); } 113 type *operator()() { return (type *)QGDictIterator::operator()(); }
114 type *operator++() { return (type *)QGDictIterator::operator++(); } 114 type *operator++() { return (type *)QGDictIterator::operator++(); }
115 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j); } 115 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j); }
116}; 116};
117 117
118#ifdef QT_QWINEXPORT
119#define Q_DEFINED_QDICT
120#include "qwinexport.h"
121#endif /* QT_QWINEXPORT */
118#endif // QDICT_H 122#endif // QDICT_H
diff --git a/qmake/include/qdir.h b/qmake/include/qdir.h
index 6e9f1ab..4b08b79 100644
--- a/qmake/include/qdir.h
+++ b/qmake/include/qdir.h
@@ -157,59 +157,60 @@ public:
157 virtual bool operator==( const QDir & ) const; 157 virtual bool operator==( const QDir & ) const;
158 virtual bool operator!=( const QDir & ) const; 158 virtual bool operator!=( const QDir & ) const;
159 159
160 virtual bool remove( const QString &fileName, 160 virtual bool remove( const QString &fileName,
161 bool acceptAbsPath = TRUE ); 161 bool acceptAbsPath = TRUE );
162 virtual bool rename( const QString &name, const QString &newName, 162 virtual bool rename( const QString &name, const QString &newName,
163 bool acceptAbsPaths = TRUE ); 163 bool acceptAbsPaths = TRUE );
164 virtual bool exists( const QString &name, 164 virtual bool exists( const QString &name,
165 bool acceptAbsPath = TRUE ); 165 bool acceptAbsPath = TRUE );
166 166
167 static char separator(); 167 static char separator();
168 168
169 static bool setCurrent( const QString &path ); 169 static bool setCurrent( const QString &path );
170 static QDir current(); 170 static QDir current();
171 static QDir home(); 171 static QDir home();
172 static QDir root(); 172 static QDir root();
173 static QString currentDirPath(); 173 static QString currentDirPath();
174 static QString homeDirPath(); 174 static QString homeDirPath();
175 static QString rootDirPath(); 175 static QString rootDirPath();
176 176
177 static bool match( const QStringList &filters, const QString &fileName ); 177 static bool match( const QStringList &filters, const QString &fileName );
178 static bool match( const QString &filter, const QString &fileName ); 178 static bool match( const QString &filter, const QString &fileName );
179 static QString cleanDirPath( const QString &dirPath ); 179 static QString cleanDirPath( const QString &dirPath );
180 static bool isRelativePath( const QString &path ); 180 static bool isRelativePath( const QString &path );
181 void refresh() const;
181 182
182private: 183private:
183#ifdef Q_OS_MAC 184#ifdef Q_OS_MAC
184 typedef struct FSSpec FSSpec; 185 typedef struct FSSpec FSSpec;
185 static FSSpec *make_spec(const QString &); 186 static FSSpec *make_spec(const QString &);
186#endif 187#endif
187 void init(); 188 void init();
188 virtual bool readDirEntries( const QString &nameFilter, 189 virtual bool readDirEntries( const QString &nameFilter,
189 int FilterSpec, int SortSpec ); 190 int FilterSpec, int SortSpec );
190 191
191 static void slashify ( QString &); 192 static void slashify( QString & );
192 193
193 QStringdPath; 194 QStringdPath;
194 QStringList *fList; 195 QStringList *fList;
195 QFileInfoList *fiList; 196 QFileInfoList *fiList;
196 QStringnameFilt; 197 QStringnameFilt;
197 FilterSpecfiltS; 198 FilterSpecfiltS;
198 SortSpecsortS; 199 SortSpecsortS;
199 uint dirty: 1; 200 uint dirty: 1;
200 uintallDirs : 1; 201 uintallDirs : 1;
201}; 202};
202 203
203 204
204inline QString QDir::path() const 205inline QString QDir::path() const
205{ 206{
206 return dPath; 207 return dPath;
207} 208}
208 209
209inline QString QDir::nameFilter() const 210inline QString QDir::nameFilter() const
210{ 211{
211 return nameFilt; 212 return nameFilt;
212} 213}
213 214
214inline QDir::FilterSpec QDir::filter() const 215inline QDir::FilterSpec QDir::filter() const
215{ 216{
diff --git a/qmake/include/qfeatures.h b/qmake/include/qfeatures.h
index 57502f9..270a6de 100644
--- a/qmake/include/qfeatures.h
+++ b/qmake/include/qfeatures.h
@@ -53,49 +53,49 @@
53// Automatic widget layout 53// Automatic widget layout
54//#define QT_NO_LAYOUT 54//#define QT_NO_LAYOUT
55 55
56// Networking 56// Networking
57//#define QT_NO_NETWORK 57//#define QT_NO_NETWORK
58 58
59// Palettes 59// Palettes
60//#define QT_NO_PALETTE 60//#define QT_NO_PALETTE
61 61
62// Alpha-blended cursor 62// Alpha-blended cursor
63//#define QT_NO_QWS_ALPHA_CURSOR 63//#define QT_NO_QWS_ALPHA_CURSOR
64 64
65// 1-bit monochrome 65// 1-bit monochrome
66//#define QT_NO_QWS_DEPTH_1 66//#define QT_NO_QWS_DEPTH_1
67 67
68// 15 or 16-bit color 68// 15 or 16-bit color
69//#define QT_NO_QWS_DEPTH_16 69//#define QT_NO_QWS_DEPTH_16
70 70
71// 24-bit color 71// 24-bit color
72//#define QT_NO_QWS_DEPTH_24 72//#define QT_NO_QWS_DEPTH_24
73 73
74// 32-bit color 74// 32-bit color
75//#define QT_NO_QWS_DEPTH_32 75//#define QT_NO_QWS_DEPTH_32
76 76
77// 4-bit greyscale 77// 4-bit grayscale
78//#define QT_NO_QWS_DEPTH_4 78//#define QT_NO_QWS_DEPTH_4
79 79
80// 8-bit color 80// 8-bit color
81//#define QT_NO_QWS_DEPTH_8 81//#define QT_NO_QWS_DEPTH_8
82 82
83// 8-bit grayscale 83// 8-bit grayscale
84//#define QT_NO_QWS_DEPTH_8GRAYSCALE 84//#define QT_NO_QWS_DEPTH_8GRAYSCALE
85 85
86// Favour code size over graphics speed 86// Favour code size over graphics speed
87//#define QT_NO_QWS_GFX_SPEED 87//#define QT_NO_QWS_GFX_SPEED
88 88
89// Console keyboard 89// Console keyboard
90//#define QT_NO_QWS_KEYBOARD 90//#define QT_NO_QWS_KEYBOARD
91 91
92// Linux framebuffer 92// Linux framebuffer
93//#define QT_NO_QWS_LINUXFB 93//#define QT_NO_QWS_LINUXFB
94 94
95// Mach64 acceleration 95// Mach64 acceleration
96//#define QT_NO_QWS_MACH64 96//#define QT_NO_QWS_MACH64
97 97
98// Window Manager 98// Window Manager
99//#define QT_NO_QWS_MANAGER 99//#define QT_NO_QWS_MANAGER
100 100
101// Matrox MGA acceleration 101// Matrox MGA acceleration
diff --git a/qmake/include/qgarray.h b/qmake/include/qgarray.h
index 12edea6..40720a6 100644
--- a/qmake/include/qgarray.h
+++ b/qmake/include/qgarray.h
@@ -28,88 +28,97 @@
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QGARRAY_H 38#ifndef QGARRAY_H
39#define QGARRAY_H 39#define QGARRAY_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include "qshared.h" 42#include "qshared.h"
43#endif // QT_H 43#endif // QT_H
44 44
45 45
46 class Q_EXPORT QGArray // generic array 46 class Q_EXPORT QGArray // generic array
47{ 47{
48friend class QBuffer; 48friend class QBuffer;
49public: 49public:
50 //### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE. 50 //### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE.
51 struct array_data : public QShared {// shared array 51 struct array_data : public QShared {// shared array
52 array_data(){ data=0; len=0; } 52 array_data():data(0),len(0)
53#ifdef QT_QGARRAY_SPEED_OPTIM
54 ,maxl(0)
55#endif
56 {}
53 char *data; // actual array data 57 char *data; // actual array data
54 uint len; 58 uint len;
59#ifdef QT_QGARRAY_SPEED_OPTIM
60 uint maxl;
61#endif
55 }; 62 };
56 QGArray(); 63 QGArray();
64 enum Optimization { MemOptim, SpeedOptim };
57protected: 65protected:
58 QGArray( int, int ); // dummy; does not alloc 66 QGArray( int, int ); // dummy; does not alloc
59 QGArray( int size ); // allocate 'size' bytes 67 QGArray( int size ); // allocate 'size' bytes
60 QGArray( const QGArray &a ); // shallow copy 68 QGArray( const QGArray &a ); // shallow copy
61 virtual ~QGArray(); 69 virtual ~QGArray();
62 70
63 QGArray &operator=( const QGArray &a ) { return assign( a ); } 71 QGArray &operator=( const QGArray &a ) { return assign( a ); }
64 72
65 virtual void detach(){ duplicate(*this); } 73 virtual void detach(){ duplicate(*this); }
66 74
67 // ### Qt 4.0: maybe provide two versions of data(), at(), etc. 75 // ### Qt 4.0: maybe provide two versions of data(), at(), etc.
68 char *data() const{ return shd->data; } 76 char *data() const{ return shd->data; }
69 uint nrefs() const{ return shd->count; } 77 uint nrefs() const{ return shd->count; }
70 uint size() const{ return shd->len; } 78 uint size() const{ return shd->len; }
71 boolisEqual( const QGArray &a ) const; 79 boolisEqual( const QGArray &a ) const;
72 80
81 boolresize( uint newsize, Optimization optim );
73 boolresize( uint newsize ); 82 boolresize( uint newsize );
74 83
75 boolfill( const char *d, int len, uint sz ); 84 boolfill( const char *d, int len, uint sz );
76 85
77 QGArray &assign( const QGArray &a ); 86 QGArray &assign( const QGArray &a );
78 QGArray &assign( const char *d, uint len ); 87 QGArray &assign( const char *d, uint len );
79 QGArray &duplicate( const QGArray &a ); 88 QGArray &duplicate( const QGArray &a );
80 QGArray &duplicate( const char *d, uint len ); 89 QGArray &duplicate( const char *d, uint len );
81 voidstore( const char *d, uint len ); 90 voidstore( const char *d, uint len );
82 91
83 array_data *sharedBlock() const { return shd; } 92 array_data *sharedBlock() const { return shd; }
84 voidsetSharedBlock( array_data *p ) { shd=(array_data*)p; } 93 voidsetSharedBlock( array_data *p ) { shd=(array_data*)p; }
85 94
86 QGArray &setRawData( const char *d, uint len ); 95 QGArray &setRawData( const char *d, uint len );
87 voidresetRawData( const char *d, uint len ); 96 voidresetRawData( const char *d, uint len );
88 97
89 int find( const char *d, uint index, uint sz ) const; 98 int find( const char *d, uint index, uint sz ) const;
90 int contains( const char *d, uint sz ) const; 99 int contains( const char *d, uint sz ) const;
91 100
92 voidsort( uint sz ); 101 voidsort( uint sz );
93 int bsearch( const char *d, uint sz ) const; 102 int bsearch( const char *d, uint sz ) const;
94 103
95 char *at( uint index ) const; 104 char *at( uint index ) const;
96 105
97 boolsetExpand( uint index, const char *d, uint sz ); 106 boolsetExpand( uint index, const char *d, uint sz );
98 107
99protected: 108protected:
100 virtual array_data *newData(); 109 virtual array_data *newData();
101 virtual void deleteData( array_data *p ); 110 virtual void deleteData( array_data *p );
102 111
103private: 112private:
104 static void msg_index( uint ); 113 static void msg_index( uint );
105 array_data *shd; 114 array_data *shd;
106}; 115};
107 116
108 117
109inline char *QGArray::at( uint index ) const 118inline char *QGArray::at( uint index ) const
110{ 119{
111#if defined(QT_CHECK_RANGE) 120#if defined(QT_CHECK_RANGE)
112 if ( index >= size() ) { 121 if ( index >= size() ) {
113 msg_index( index ); 122 msg_index( index );
114 index = 0; 123 index = 0;
115 } 124 }
diff --git a/qmake/include/qglobal.h b/qmake/include/qglobal.h
index 13cff64..d212bff 100644
--- a/qmake/include/qglobal.h
+++ b/qmake/include/qglobal.h
@@ -17,53 +17,53 @@
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QGLOBAL_H 38#ifndef QGLOBAL_H
39#define QGLOBAL_H 39#define QGLOBAL_H
40 40
41#define QT_VERSION_STR "3.1.0-b2" 41#define QT_VERSION_STR "3.1.2"
42/* 42/*
43 QT_VERSION is (major << 16) + (minor << 8) + patch. 43 QT_VERSION is (major << 16) + (minor << 8) + patch.
44 */ 44 */
45#define QT_VERSION 0x030100 45#define QT_VERSION 0x030102
46 46
47/* 47/*
48 The operating system, must be one of: (Q_OS_x) 48 The operating system, must be one of: (Q_OS_x)
49 49
50 MACX- Mac OS X 50 MACX- Mac OS X
51 MAC9- Mac OS 9 51 MAC9- Mac OS 9
52 MSDOS- MS-DOS and Windows 52 MSDOS- MS-DOS and Windows
53 OS2- OS/2 53 OS2- OS/2
54 OS2EMX- XFree86 on OS/2 (not PM) 54 OS2EMX- XFree86 on OS/2 (not PM)
55 WIN32- Win32 (Windows 95/98/ME and Windows NT/2000/XP) 55 WIN32- Win32 (Windows 95/98/ME and Windows NT/2000/XP)
56 CYGWIN- Cygwin 56 CYGWIN- Cygwin
57 SOLARIS- Sun Solaris 57 SOLARIS- Sun Solaris
58 HPUX- HP-UX 58 HPUX- HP-UX
59 ULTRIX- DEC Ultrix 59 ULTRIX- DEC Ultrix
60 LINUX- Linux 60 LINUX- Linux
61 FREEBSD- FreeBSD 61 FREEBSD- FreeBSD
62 NETBSD- NetBSD 62 NETBSD- NetBSD
63 OPENBSD- OpenBSD 63 OPENBSD- OpenBSD
64 BSDI- BSD/OS 64 BSDI- BSD/OS
65 IRIX- SGI Irix 65 IRIX- SGI Irix
66 OSF- HP Tru64 UNIX 66 OSF- HP Tru64 UNIX
67 SCO- SCO OpenServer 5 67 SCO- SCO OpenServer 5
68 UNIXWARE- UnixWare 7, Open UNIX 8 68 UNIXWARE- UnixWare 7, Open UNIX 8
69 AIX- AIX 69 AIX- AIX
@@ -120,54 +120,54 @@
120#elif defined(__OpenBSD__) 120#elif defined(__OpenBSD__)
121# define Q_OS_OPENBSD 121# define Q_OS_OPENBSD
122# define Q_OS_BSD4 122# define Q_OS_BSD4
123#elif defined(__bsdi__) 123#elif defined(__bsdi__)
124# define Q_OS_BSDI 124# define Q_OS_BSDI
125# define Q_OS_BSD4 125# define Q_OS_BSD4
126#elif defined(__sgi) 126#elif defined(__sgi)
127# define Q_OS_IRIX 127# define Q_OS_IRIX
128#elif defined(__osf__) 128#elif defined(__osf__)
129# define Q_OS_OSF 129# define Q_OS_OSF
130#elif defined(_AIX) 130#elif defined(_AIX)
131# define Q_OS_AIX 131# define Q_OS_AIX
132#elif defined(__Lynx__) 132#elif defined(__Lynx__)
133# define Q_OS_LYNX 133# define Q_OS_LYNX
134#elif defined(__GNU_HURD__) 134#elif defined(__GNU_HURD__)
135# define Q_OS_HURD 135# define Q_OS_HURD
136#elif defined(__DGUX__) 136#elif defined(__DGUX__)
137# define Q_OS_DGUX 137# define Q_OS_DGUX
138#elif defined(__QNXNTO__) 138#elif defined(__QNXNTO__)
139# define Q_OS_QNX6 139# define Q_OS_QNX6
140#elif defined(__QNX__) 140#elif defined(__QNX__)
141# define Q_OS_QNX 141# define Q_OS_QNX
142#elif defined(_SEQUENT_) 142#elif defined(_SEQUENT_)
143# define Q_OS_DYNIX 143# define Q_OS_DYNIX
144#elif defined(_SCO_DS) /* SCO OpenServer 5 */ 144#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */
145# define Q_OS_SCO 145# define Q_OS_SCO
146#elif defined(__UNIXWARE__) /* UnixWare 7 + GCC, Open UNIX 8 + GCC */ 146#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */
147# define Q_OS_UNIXWARE 147# define Q_OS_UNIXWARE
148# define Q_OS_UNIXWARE7 148# define Q_OS_UNIXWARE7
149#elif defined(__USLC__) /* UnixWare 7 + UDK, Open UNIX 8 + OUDK */ 149#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */
150# define Q_OS_UNIXWARE 150# define Q_OS_UNIXWARE
151# define Q_OS_UNIXWARE7 151# define Q_OS_UNIXWARE7
152#else 152#else
153# error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com" 153# error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com"
154#endif 154#endif
155 155
156#if defined(Q_OS_MAC9) || defined(Q_OS_MACX) 156#if defined(Q_OS_MAC9) || defined(Q_OS_MACX)
157# define Q_OS_MAC 157# define Q_OS_MAC
158#endif 158#endif
159 159
160#if defined(Q_OS_MAC9) || defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN32) || defined(Q_OS_WIN64) 160#if defined(Q_OS_MAC9) || defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
161# undef Q_OS_UNIX 161# undef Q_OS_UNIX
162#elif !defined(Q_OS_UNIX) 162#elif !defined(Q_OS_UNIX)
163# define Q_OS_UNIX 163# define Q_OS_UNIX
164#endif 164#endif
165 165
166 166
167/* 167/*
168 The compiler, must be one of: (Q_CC_x) 168 The compiler, must be one of: (Q_CC_x)
169 169
170 SYM- Symantec C++ for both PC and Macintosh 170 SYM- Symantec C++ for both PC and Macintosh
171 MPW- MPW C++ 171 MPW- MPW C++
172 MWERKS- Metrowerks CodeWarrior 172 MWERKS- Metrowerks CodeWarrior
173 MSVC- Microsoft Visual C/C++ 173 MSVC- Microsoft Visual C/C++
@@ -204,94 +204,100 @@
204# if !defined(_CPPUNWIND) 204# if !defined(_CPPUNWIND)
205# define Q_NO_EXCEPTIONS 205# define Q_NO_EXCEPTIONS
206# endif 206# endif
207 207
208#elif defined(applec) 208#elif defined(applec)
209# define Q_CC_MPW 209# define Q_CC_MPW
210# define Q_NO_BOOL_TYPE 210# define Q_NO_BOOL_TYPE
211# define Q_NO_EXPLICIT_KEYWORD 211# define Q_NO_EXPLICIT_KEYWORD
212# define Q_NO_USING_KEYWORD 212# define Q_NO_USING_KEYWORD
213 213
214#elif defined(__MWERKS__) 214#elif defined(__MWERKS__)
215# define Q_CC_MWERKS 215# define Q_CC_MWERKS
216/* "explicit" recognized since 4.0d1 */ 216/* "explicit" recognized since 4.0d1 */
217# define QMAC_PASCAL pascal 217# define QMAC_PASCAL pascal
218# define Q_NO_USING_KEYWORD /* ### check "using" status */ 218# define Q_NO_USING_KEYWORD /* ### check "using" status */
219 219
220#elif defined(_MSC_VER) 220#elif defined(_MSC_VER)
221# define Q_CC_MSVC 221# define Q_CC_MSVC
222/* proper support of bool for _MSC_VER >= 1100 */ 222/* proper support of bool for _MSC_VER >= 1100 */
223# define Q_CANNOT_DELETE_CONSTANT 223# define Q_CANNOT_DELETE_CONSTANT
224# define Q_INLINE_TEMPLATES inline 224# define Q_INLINE_TEMPLATES inline
225/* Visual C++.Net issues for _MSC_VER >= 1300 */ 225/* Visual C++.Net issues for _MSC_VER >= 1300 */
226# if _MSC_VER >= 1300 226# if _MSC_VER >= 1300
227# define Q_CC_MSVC_NET 227# define Q_CC_MSVC_NET
228# define Q_TYPENAME 228# if _MSC_VER < 1310
229# define Q_TYPENAME
230# endif
229# endif 231# endif
230# define Q_NO_USING_KEYWORD /* ### check "using" status */ 232# define Q_NO_USING_KEYWORD /* ### check "using" status */
231 233
232#elif defined(__BORLANDC__) || defined(__TURBOC__) 234#elif defined(__BORLANDC__) || defined(__TURBOC__)
233# define Q_CC_BOR 235# define Q_CC_BOR
234# if __BORLANDC__ < 0x502 236# if __BORLANDC__ < 0x502
235# define Q_NO_BOOL_TYPE 237# define Q_NO_BOOL_TYPE
236# define Q_NO_EXPLICIT_KEYWORD 238# define Q_NO_EXPLICIT_KEYWORD
237# endif 239# endif
238# define Q_NO_USING_KEYWORD /* ### check "using" status */ 240# define Q_NO_USING_KEYWORD /* ### check "using" status */
239 241
240#elif defined(__WATCOMC__) 242#elif defined(__WATCOMC__)
241# define Q_CC_WAT 243# define Q_CC_WAT
242# if defined(Q_OS_QNX4) 244# if defined(Q_OS_QNX4)
243/* compiler flags */ 245/* compiler flags */
244# define Q_TYPENAME 246# define Q_TYPENAME
245# define Q_NO_BOOL_TYPE 247# define Q_NO_BOOL_TYPE
246# define Q_CANNOT_DELETE_CONSTANT 248# define Q_CANNOT_DELETE_CONSTANT
247# define mutable 249# define mutable
248/* ??? */ 250/* ??? */
249# define Q_BROKEN_TEMPLATE_SPECIALIZATION 251# define Q_BROKEN_TEMPLATE_SPECIALIZATION
250/* no template classes in QVariant */ 252/* no template classes in QVariant */
251# define QT_NO_TEMPLATE_VARIANT 253# define QT_NO_TEMPLATE_VARIANT
252/* Wcc does not fill in functions needed by valuelists, maps, and 254/* Wcc does not fill in functions needed by valuelists, maps, and
253 valuestacks implicitly */ 255 valuestacks implicitly */
254# define Q_FULL_TEMPLATE_INSTANTIATION 256# define Q_FULL_TEMPLATE_INSTANTIATION
255/* can we just compare the structures? */ 257/* can we just compare the structures? */
256# define Q_FULL_TEMPLATE_INSTANTIATION_MEMCMP 258# define Q_FULL_TEMPLATE_INSTANTIATION_MEMCMP
257/* these are not useful to our customers */ 259/* these are not useful to our customers */
258# define QT_QWS_NO_SHM 260# define QT_QWS_NO_SHM
259# define QT_NO_QWS_MULTIPROCESS 261# define QT_NO_QWS_MULTIPROCESS
260# define QT_NO_SQL 262# define QT_NO_SQL
261# define QT_NO_QWS_CURSOR 263# define QT_NO_QWS_CURSOR
262# endif 264# endif
263 265
264#elif defined(__GNUC__) 266#elif defined(__GNUC__)
265# define Q_CC_GNU 267# define Q_CC_GNU
266# define Q_C_CALLBACKS 268# define Q_C_CALLBACKS
267# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 269# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
268# define Q_FULL_TEMPLATE_INSTANTIATION 270# define Q_FULL_TEMPLATE_INSTANTIATION
269# endif 271# endif
270/* GCC 2.95 knows "using" but does not support it correctly */ 272/* GCC 2.95 knows "using" but does not support it correctly */
271# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95 273# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
272# define Q_NO_USING_KEYWORD 274# define Q_NO_USING_KEYWORD
273# endif 275# endif
276/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
277# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
278# define Q_WRONG_SB_CTYPE_MACROS
279# endif
274# if (defined(__arm__) || defined(__ARMEL__)) && !defined(QT_MOC_CPP) 280# if (defined(__arm__) || defined(__ARMEL__)) && !defined(QT_MOC_CPP)
275# define Q_PACKED __attribute__ ((packed)) 281# define Q_PACKED __attribute__ ((packed))
276# endif 282# endif
277# if !defined(__EXCEPTIONS) 283# if !defined(__EXCEPTIONS)
278# define Q_NO_EXCEPTIONS 284# define Q_NO_EXCEPTIONS
279# endif 285# endif
280 286
281/* IBM compiler versions are a bit messy. There are actually two products: 287/* IBM compiler versions are a bit messy. There are actually two products:
282 the C product, and the C++ product. The C++ compiler is always packaged 288 the C product, and the C++ product. The C++ compiler is always packaged
283 with the latest version of the C compiler. Version numbers do not always 289 with the latest version of the C compiler. Version numbers do not always
284 match. This little table (I'm not sure it's accurate) should be helpful: 290 match. This little table (I'm not sure it's accurate) should be helpful:
285 291
286 C++ product C product 292 C++ product C product
287 293
288 C Set 3.1 C Compiler 3.0 294 C Set 3.1 C Compiler 3.0
289 ... ... 295 ... ...
290 C++ Compiler 3.6.6 C Compiler 4.3 296 C++ Compiler 3.6.6 C Compiler 4.3
291 ... ... 297 ... ...
292 Visual Age C++ 4.0 ... 298 Visual Age C++ 4.0 ...
293 ... ... 299 ... ...
294 Visual Age C++ 5.0 C Compiler 5.0 300 Visual Age C++ 5.0 C Compiler 5.0
295 301
296 Now: 302 Now:
297 __xlC__ is the version of the C compiler in hexadecimal notation 303 __xlC__ is the version of the C compiler in hexadecimal notation
@@ -369,112 +375,129 @@
369# define Q_NO_EXCEPTIONS 375# define Q_NO_EXCEPTIONS
370# endif 376# endif
371 377
372/* Using the `using' keyword avoids Intel C++ warnings */ 378/* Using the `using' keyword avoids Intel C++ warnings */
373# elif defined(__INTEL_COMPILER) 379# elif defined(__INTEL_COMPILER)
374# define Q_CC_INTEL 380# define Q_CC_INTEL
375# if !defined(__EXCEPTIONS) 381# if !defined(__EXCEPTIONS)
376# define Q_NO_EXCEPTIONS 382# define Q_NO_EXCEPTIONS
377# endif 383# endif
378 384
379/* The Portland Group compiler is based on EDG and does define __EDG__ */ 385/* The Portland Group compiler is based on EDG and does define __EDG__ */
380# elif defined(__PGI) 386# elif defined(__PGI)
381# define Q_CC_PGI 387# define Q_CC_PGI
382# if !defined(__EXCEPTIONS) 388# if !defined(__EXCEPTIONS)
383# define Q_NO_EXCEPTIONS 389# define Q_NO_EXCEPTIONS
384# endif 390# endif
385 391
386/* Never tested! */ 392/* Never tested! */
387# elif defined(__ghs) 393# elif defined(__ghs)
388# define Q_CC_GHS 394# define Q_CC_GHS
389 395
390/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */ 396/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */
391# elif defined(__USLC__) && defined(__SCO_VERSION__) 397# elif defined(__USLC__) && defined(__SCO_VERSION__)
392# define Q_CC_USLC 398# define Q_CC_USLC
399/* The latest UDK 7.1.1b does not need this, but previous versions do */
400# if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010)
401# define Q_INLINE_TEMPLATES inline
402# endif
393# define Q_NO_USING_KEYWORD /* ### check "using" status */ 403# define Q_NO_USING_KEYWORD /* ### check "using" status */
394 404
395/* Never tested! */ 405/* Never tested! */
396# elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER) 406# elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER)
397# define Q_CC_OC 407# define Q_CC_OC
398# define Q_NO_USING_KEYWORD 408# define Q_NO_USING_KEYWORD
399 409
400/* CDS++ is not documented to define __EDG__ or __EDG in the Reliant 410/* CDS++ defines __EDG__ although this is not documented in the Reliant
401 documentation but we suppose it does, in any case it does follow 411 documentation. It also follows conventions like _BOOL and this documented */
402 conventions like _BOOL */
403# elif defined(sinix) 412# elif defined(sinix)
404# define Q_CC_CDS 413# define Q_CC_CDS
405# define Q_NO_USING_KEYWORD 414# define Q_NO_USING_KEYWORD
406# if defined(__cplusplus) && (__cplusplus < 2) /* Cfront C++ mode */ 415# if defined(__cplusplus) && (__cplusplus < 2) /* Cfront C++ mode */
407# define Q_NO_EXCEPTIONS 416# define Q_NO_EXCEPTIONS
408# endif 417# endif
409 418
410/* The MIPSpro compiler in o32 mode is based on EDG but disables features 419/* The MIPSpro compiler in o32 mode is based on EDG but disables features
411 such as template specialization nevertheless */ 420 such as template specialization nevertheless */
412# elif defined(__sgi) 421# elif defined(__sgi)
413# define Q_CC_MIPS 422# define Q_CC_MIPS
414# if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32) /* o32 ABI */ 423# if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32) /* o32 ABI */
415# define Q_TYPENAME 424# define Q_TYPENAME
416# define Q_BROKEN_TEMPLATE_SPECIALIZATION 425# define Q_BROKEN_TEMPLATE_SPECIALIZATION
417# define Q_STRICT_INLINING_RULES 426# define Q_STRICT_INLINING_RULES
427# define Q_NO_EXPLICIT_KEYWORD
428# define Q_INLINE_TEMPLATES inline
418# elif defined(_COMPILER_VERSION) && (_COMPILER_VERSION < 730) /* 7.2 */ 429# elif defined(_COMPILER_VERSION) && (_COMPILER_VERSION < 730) /* 7.2 */
419# define Q_TYPENAME 430# define Q_TYPENAME
420# define Q_BROKEN_TEMPLATE_SPECIALIZATION 431# define Q_BROKEN_TEMPLATE_SPECIALIZATION
421# endif 432# endif
422# define Q_NO_USING_KEYWORD /* ### check "using" status */ 433# define Q_NO_USING_KEYWORD /* ### check "using" status */
423# endif 434# endif
424 435
425/* The older UnixWare 2.X compiler? */ 436/* The older UnixWare 2.X compiler? */
426#elif defined(__USLC__) && !defined(__SCO_VERSION__) 437#elif defined(__USLC__)
427# define Q_CC_USLC 438# define Q_CC_USLC
439# define Q_TYPENAME
428# define Q_NO_BOOL_TYPE 440# define Q_NO_BOOL_TYPE
429# define Q_NO_EXPLICIT_KEYWORD 441# define Q_NO_EXPLICIT_KEYWORD
430# define Q_NO_USING_KEYWORD 442# define Q_NO_USING_KEYWORD
443# define Q_INLINE_TEMPLATES inline
431 444
432/* Never tested! */ 445/* Never tested! */
433#elif defined(__HIGHC__) 446#elif defined(__HIGHC__)
434# define Q_CC_HIGHC 447# define Q_CC_HIGHC
435 448
436#elif defined(__SUNPRO_CC) 449#elif defined(__SUNPRO_CC)
437# define Q_CC_SUN 450# define Q_CC_SUN
438/* 5.0 compiler or better 451/* 5.0 compiler or better
439 'bool' is enabled by default but can be disabled using -features=nobool 452 'bool' is enabled by default but can be disabled using -features=nobool
440 in which case _BOOL is not defined 453 in which case _BOOL is not defined
441 this is the default in 4.2 compatibility mode triggered by -compat=4 */ 454 this is the default in 4.2 compatibility mode triggered by -compat=4 */
442# if __SUNPRO_CC >= 0x500 455# if __SUNPRO_CC >= 0x500
443# if !defined(_BOOL) 456# if !defined(_BOOL)
444# define Q_NO_BOOL_TYPE 457# define Q_NO_BOOL_TYPE
445# endif 458# endif
446# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4) 459# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4)
447# define Q_NO_USING_KEYWORD 460# define Q_NO_USING_KEYWORD
448# endif 461# endif
449# define Q_C_CALLBACKS 462# define Q_C_CALLBACKS
450/* 4.2 compiler or older */ 463/* 4.2 compiler or older */
451# else 464# else
452# define Q_NO_BOOL_TYPE 465# define Q_NO_BOOL_TYPE
453# define Q_NO_EXPLICIT_KEYWORD 466# define Q_NO_EXPLICIT_KEYWORD
454# define Q_NO_USING_KEYWORD 467# define Q_NO_USING_KEYWORD
455# endif 468# endif
456 469
470/* CDS++ does not seem to define __EDG__ or __EDG according to Reliant
471 documentation but nevertheless uses EDG conventions like _BOOL */
472#elif defined(sinix)
473# define Q_CC_EDG
474# define Q_CC_CDS
475# if !defined(_BOOL)
476# define Q_NO_BOOL_TYPE
477# endif
478# define Q_BROKEN_TEMPLATE_SPECIALIZATION
479
457#elif defined(Q_OS_HPUX) 480#elif defined(Q_OS_HPUX)
458/* __HP_aCC was not defined in first aCC releases */ 481/* __HP_aCC was not defined in first aCC releases */
459# if defined(__HP_aCC) || __cplusplus >= 199707L 482# if defined(__HP_aCC) || __cplusplus >= 199707L
460# define Q_CC_HPACC 483# define Q_CC_HPACC
461# else 484# else
462# define Q_CC_HP 485# define Q_CC_HP
463# define Q_NO_BOOL_TYPE 486# define Q_NO_BOOL_TYPE
464# define Q_FULL_TEMPLATE_INSTANTIATION 487# define Q_FULL_TEMPLATE_INSTANTIATION
465# define Q_BROKEN_TEMPLATE_SPECIALIZATION 488# define Q_BROKEN_TEMPLATE_SPECIALIZATION
466# define Q_NO_EXPLICIT_KEYWORD 489# define Q_NO_EXPLICIT_KEYWORD
467# endif 490# endif
468# define Q_NO_USING_KEYWORD /* ### check "using" status */ 491# define Q_NO_USING_KEYWORD /* ### check "using" status */
469 492
470#else 493#else
471# error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com" 494# error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com"
472#endif 495#endif
473 496
474#ifndef Q_PACKED 497#ifndef Q_PACKED
475# define Q_PACKED 498# define Q_PACKED
476#endif 499#endif
477 500
478 501
479/* 502/*
480 The window system, must be one of: (Q_WS_x) 503 The window system, must be one of: (Q_WS_x)
@@ -485,48 +508,49 @@
485 WIN32- Windows 508 WIN32- Windows
486 X11- X Window System 509 X11- X Window System
487 PM - unsupported 510 PM - unsupported
488 WIN16- unsupported 511 WIN16- unsupported
489*/ 512*/
490 513
491#if defined(Q_OS_MAC9) 514#if defined(Q_OS_MAC9)
492# define Q_WS_MAC9 515# define Q_WS_MAC9
493#elif defined(Q_OS_MSDOS) 516#elif defined(Q_OS_MSDOS)
494# define Q_WS_WIN16 517# define Q_WS_WIN16
495# error "Qt requires Win32 and does not work with Windows 3.x" 518# error "Qt requires Win32 and does not work with Windows 3.x"
496#elif defined(_WIN32_X11_) 519#elif defined(_WIN32_X11_)
497# define Q_WS_X11 520# define Q_WS_X11
498#elif defined(Q_OS_WIN32) 521#elif defined(Q_OS_WIN32)
499# define Q_WS_WIN32 522# define Q_WS_WIN32
500# if defined(Q_OS_WIN64) 523# if defined(Q_OS_WIN64)
501# define Q_WS_WIN64 524# define Q_WS_WIN64
502# endif 525# endif
503#elif defined(Q_OS_OS2) 526#elif defined(Q_OS_OS2)
504# define Q_WS_PM 527# define Q_WS_PM
505# error "Qt does not work with OS/2 Presentation Manager or Workplace Shell" 528# error "Qt does not work with OS/2 Presentation Manager or Workplace Shell"
506#elif defined(Q_OS_UNIX) 529#elif defined(Q_OS_UNIX)
507# if defined(QWS) 530# if defined(QWS)
508# define Q_WS_QWS 531# define Q_WS_QWS
532# define QT_NO_QWS_IM
509# elif defined(Q_OS_MACX) 533# elif defined(Q_OS_MACX)
510# define Q_WS_MACX 534# define Q_WS_MACX
511# else 535# else
512# define Q_WS_X11 536# define Q_WS_X11
513# endif 537# endif
514#endif 538#endif
515#if defined(Q_OS_MAC) && !defined(QMAC_PASCAL) 539#if defined(Q_OS_MAC) && !defined(QMAC_PASCAL)
516# define QMAC_PASCAL 540# define QMAC_PASCAL
517#endif 541#endif
518 542
519#if defined(Q_WS_WIN16) || defined(Q_WS_WIN32) 543#if defined(Q_WS_WIN16) || defined(Q_WS_WIN32)
520# define Q_WS_WIN 544# define Q_WS_WIN
521#endif 545#endif
522 546
523#if (defined(Q_WS_MAC9) || defined(Q_WS_MACX)) && !defined(Q_WS_QWS) && !defined(Q_WS_X11) 547#if (defined(Q_WS_MAC9) || defined(Q_WS_MACX)) && !defined(Q_WS_QWS) && !defined(Q_WS_X11)
524# define Q_WS_MAC 548# define Q_WS_MAC
525#endif 549#endif
526 550
527 551
528/* 552/*
529 Some classes do not permit copies to be made of an object. 553 Some classes do not permit copies to be made of an object.
530 These classes contains a private copy constructor and operator= 554 These classes contains a private copy constructor and operator=
531 to disable copying (the compiler gives an error message). 555 to disable copying (the compiler gives an error message).
532 Undefine Q_DISABLE_COPY to turn off this checking. 556 Undefine Q_DISABLE_COPY to turn off this checking.
@@ -724,107 +748,125 @@ class QDataStream;
724#endif 748#endif
725 749
726#if defined(Q_WS_MAC9) 750#if defined(Q_WS_MAC9)
727//No need for menu merging 751//No need for menu merging
728# ifndef QMAC_QMENUBAR_NO_MERGE 752# ifndef QMAC_QMENUBAR_NO_MERGE
729# define QMAC_QMENUBAR_NO_MERGE 753# define QMAC_QMENUBAR_NO_MERGE
730# endif 754# endif
731//Mac9 does not use quartz 755//Mac9 does not use quartz
732# ifndef QMAC_NO_QUARTZ 756# ifndef QMAC_NO_QUARTZ
733# define QMAC_NO_QUARTZ 757# define QMAC_NO_QUARTZ
734# endif 758# endif
735# ifndef QMAC_QMENUBAR_NO_EVENT 759# ifndef QMAC_QMENUBAR_NO_EVENT
736# define QMAC_QMENUBAR_NO_EVENT 760# define QMAC_QMENUBAR_NO_EVENT
737# endif 761# endif
738#endif 762#endif
739#if defined(Q_WS_MACX) //for no nobody uses quartz, just putting in first level hooks 763#if defined(Q_WS_MACX) //for no nobody uses quartz, just putting in first level hooks
740# ifndef QMAC_NO_QUARTZ 764# ifndef QMAC_NO_QUARTZ
741# define QMAC_NO_QUARTZ 765# define QMAC_NO_QUARTZ
742# endif 766# endif
743# ifndef QMAC_QMENUBAR_NO_EVENT 767# ifndef QMAC_QMENUBAR_NO_EVENT
744# define QMAC_QMENUBAR_NO_EVENT 768# define QMAC_QMENUBAR_NO_EVENT
745# endif 769# endif
746#endif 770#endif
747 771
772#if !defined(Q_WS_QWS) && !defined(QT_NO_COP)
773# define QT_NO_COP
774#endif
775
748#ifndef QT_H 776#ifndef QT_H
749#include <qfeatures.h> 777#include <qfeatures.h>
750#endif // QT_H 778#endif // QT_H
751 779
752 780
753// 781//
754// Create Qt DLL if QT_DLL is defined (Windows only) 782// Create Qt DLL if QT_DLL is defined (Windows only)
783// or QT_SHARED is defined (Kylix only)
755// 784//
756 785
757#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) 786#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
758# if defined(QT_NODLL) 787# if defined(QT_NODLL)
759# undef QT_MAKEDLL 788# undef QT_MAKEDLL
760# undef QT_DLL 789# undef QT_DLL
761 # elif defined(QT_MAKEDLL)/* create a Qt DLL library */ 790 # elif defined(QT_MAKEDLL)/* create a Qt DLL library */
762# if defined(QT_DLL) 791# if defined(QT_DLL)
763# undef QT_DLL 792# undef QT_DLL
764# endif 793# endif
765# define Q_EXPORT __declspec(dllexport) 794# define Q_EXPORT __declspec(dllexport)
766# define Q_TEMPLATEDLL 795# define Q_TEMPLATEDLL
767# define Q_TEMPLATE_EXTERN 796# define Q_TEMPLATE_EXTERN
768 # undef Q_DISABLE_COPY/* avoid unresolved externals */ 797 # undef Q_DISABLE_COPY/* avoid unresolved externals */
769 # elif defined(QT_DLL) /* use a Qt DLL library */ 798 # elif defined(QT_DLL) /* use a Qt DLL library */
770# define Q_EXPORT __declspec(dllimport) 799# define Q_EXPORT __declspec(dllimport)
771# define Q_TEMPLATEDLL 800# define Q_TEMPLATEDLL
772# ifndef Q_TEMPLATE_EXTERN 801# ifndef Q_TEMPLATE_EXTERN
773# if defined(Q_CC_MSVC) 802# if defined(Q_CC_MSVC_NET)
774# define Q_TEMPLATE_EXTERN /*extern*/ //### too many warnings, even though disabled 803# define Q_TEMPLATE_EXTERN extern
775# else 804# else
776# define Q_TEMPLATE_EXTERN 805# define Q_TEMPLATE_EXTERN
777# endif 806# endif
778# endif 807# endif
779# undef Q_DISABLE_COPY /* avoid unresolved externals */ 808 # undef Q_DISABLE_COPY/* avoid unresolved externals */
809# endif
810#elif defined(Q_OS_LINUX) && defined(Q_CC_BOR)
811 # if defined(QT_SHARED)/* create a Qt shared library */
812# define Q_EXPORT __declspec(dllexport)
813# define Q_TEMPLATEDLL
814# define Q_TEMPLATE_EXTERN
815 # undef Q_DISABLE_COPY/* avoid unresolved externals */
816# else
817# define Q_TEMPLATEDLL
818# define Q_TEMPLATE_EXTERN
819 # undef Q_DISABLE_COPY /* avoid unresolved externals */
780# endif 820# endif
781#else 821#else
782 # undef QT_MAKEDLL /* ignore these for other platforms */ 822 # undef QT_MAKEDLL /* ignore these for other platforms */
783# undef QT_DLL 823# undef QT_DLL
784#endif 824#endif
785 825
786#ifndef Q_EXPORT 826#ifndef Q_EXPORT
787# define Q_EXPORT 827# define Q_EXPORT
788#endif 828#endif
789 829
790 830
791// 831//
792// Some platform specific stuff 832// Some platform specific stuff
793// 833//
794 834
795#if defined(Q_WS_WIN) 835#if defined(Q_WS_WIN)
796extern Q_EXPORT bool qt_winunicode; 836extern Q_EXPORT bool qt_winunicode;
797#endif 837#endif
798 838
799 839
800// 840//
801// System information 841// System information
802// 842//
803 843
804Q_EXPORT const char *qVersion(); 844Q_EXPORT const char *qVersion();
805Q_EXPORT bool qSysInfo( int *wordSize, bool *bigEndian ); 845Q_EXPORT bool qSysInfo( int *wordSize, bool *bigEndian );
806#if defined(Q_WS_WIN) 846#if defined(Q_OS_MAC)
847int qMacVersion();
848#elif defined(Q_WS_WIN)
807Q_EXPORT int qWinVersion(); 849Q_EXPORT int qWinVersion();
808#if defined(UNICODE) 850#if defined(UNICODE)
809#define QT_WA( uni, ansi ) if ( qt_winunicode ) { uni } else { ansi } 851#define QT_WA( uni, ansi ) if ( qt_winunicode ) { uni } else { ansi }
810#define QT_WA_INLINE( uni, ansi ) ( qt_winunicode ? uni : ansi ) 852#define QT_WA_INLINE( uni, ansi ) ( qt_winunicode ? uni : ansi )
811#else 853#else
812#define QT_WA( uni, ansi ) ansi 854#define QT_WA( uni, ansi ) ansi
813#define QT_WA_INLINE( uni, ansi ) ansi 855#define QT_WA_INLINE( uni, ansi ) ansi
814#endif 856#endif
815#endif 857#endif
816 858
817#ifdef Q_OS_TEMP 859#ifdef Q_OS_TEMP
818#ifdef QT_WA 860#ifdef QT_WA
819#undef QT_WA 861#undef QT_WA
820#undef QT_WA_INLINE 862#undef QT_WA_INLINE
821#endif 863#endif
822#define QT_WA( uni, ansi ) uni 864#define QT_WA( uni, ansi ) uni
823#define QT_WA_INLINE( uni, ansi ) ( uni ) 865#define QT_WA_INLINE( uni, ansi ) ( uni )
824#endif 866#endif
825 867
826#ifndef Q_INLINE_TEMPLATES 868#ifndef Q_INLINE_TEMPLATES
827# define Q_INLINE_TEMPLATES 869# define Q_INLINE_TEMPLATES
828#endif 870#endif
829 871
830#ifndef Q_TYPENAME 872#ifndef Q_TYPENAME
@@ -948,59 +990,76 @@ typedef QtMsgHandler msg_handler;
948#endif // QT_NO_COMPAT 990#endif // QT_NO_COMPAT
949 991
950Q_EXPORT void qSuppressObsoleteWarnings( bool = TRUE ); 992Q_EXPORT void qSuppressObsoleteWarnings( bool = TRUE );
951 993
952Q_EXPORT void qObsolete( const char *obj, const char *oldfunc, 994Q_EXPORT void qObsolete( const char *obj, const char *oldfunc,
953 const char *newfunc ); 995 const char *newfunc );
954Q_EXPORT void qObsolete( const char *obj, const char *oldfunc ); 996Q_EXPORT void qObsolete( const char *obj, const char *oldfunc );
955Q_EXPORT void qObsolete( const char *message ); 997Q_EXPORT void qObsolete( const char *message );
956 998
957 999
958// 1000//
959// Install paths from configure 1001// Install paths from configure
960// 1002//
961 1003
962Q_EXPORT const char *qInstallPath(); 1004Q_EXPORT const char *qInstallPath();
963Q_EXPORT const char *qInstallPathDocs(); 1005Q_EXPORT const char *qInstallPathDocs();
964Q_EXPORT const char *qInstallPathHeaders(); 1006Q_EXPORT const char *qInstallPathHeaders();
965Q_EXPORT const char *qInstallPathLibs(); 1007Q_EXPORT const char *qInstallPathLibs();
966Q_EXPORT const char *qInstallPathBins(); 1008Q_EXPORT const char *qInstallPathBins();
967Q_EXPORT const char *qInstallPathPlugins(); 1009Q_EXPORT const char *qInstallPathPlugins();
968Q_EXPORT const char *qInstallPathData(); 1010Q_EXPORT const char *qInstallPathData();
969 1011
970#endif // __cplusplus 1012#endif // __cplusplus
971 1013
1014// compilers which follow outdated template instantiation rules
1015// require a class to have a comparison operator to exist when
1016// a QValueList of this type is instantiated. It's not actually
1017// used in the list, though. Hence the dummy implementation.
1018// Just in case other code relies on it we better trigger a warning
1019// mandating a real implementation.
1020#ifdef Q_FULL_TEMPLATE_INSTANTIATION
1021# define Q_DUMMY_COMPARISON_OPERATOR(C) \
1022 bool operator==( const C& ) const { \
1023 qWarning( #C"::operator==( const "#C"& ) got called." ); \
1024 return FALSE; \
1025 }
1026#else
1027# define Q_DUMMY_COMPARISON_OPERATOR(C)
1028#endif
1029
972#endif // QGLOBAL_H 1030#endif // QGLOBAL_H
973 1031
974// 1032//
975// Avoid some particularly useless warnings from some stupid compilers. 1033// Avoid some particularly useless warnings from some stupid compilers.
976// To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out 1034// To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
977// the line "#define QT_NO_WARNINGS" 1035// the line "#define QT_NO_WARNINGS"
978// 1036//
979 1037
980#if !defined(QT_CC_WARNINGS) 1038#if !defined(QT_CC_WARNINGS)
981# define QT_NO_WARNINGS 1039# define QT_NO_WARNINGS
982#endif 1040#endif
983#if defined(QT_NO_WARNINGS) 1041#if defined(QT_NO_WARNINGS)
984# if defined(Q_CC_MSVC) 1042# if defined(Q_CC_MSVC)
985# pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data 1043# pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data
986# pragma warning(disable: 4275) // non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' 1044# pragma warning(disable: 4275) // non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
987# pragma warning(disable: 4514) // unreferenced inline/local function has been removed 1045# pragma warning(disable: 4514) // unreferenced inline/local function has been removed
988# pragma warning(disable: 4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning) 1046# pragma warning(disable: 4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning)
989# pragma warning(disable: 4097) // typedef-name 'identifier1' used as synonym for class-name 'identifier2' 1047# pragma warning(disable: 4097) // typedef-name 'identifier1' used as synonym for class-name 'identifier2'
990# pragma warning(disable: 4706) // assignment within conditional expression 1048# pragma warning(disable: 4706) // assignment within conditional expression
991# pragma warning(disable: 4786) // truncating debug info after 255 characters 1049# pragma warning(disable: 4786) // truncating debug info after 255 characters
992# pragma warning(disable: 4660) // template-class specialization 'identifier' is already instantiated 1050# pragma warning(disable: 4660) // template-class specialization 'identifier' is already instantiated
993# pragma warning(disable: 4355) // 'this' : used in base member initializer list 1051# pragma warning(disable: 4355) // 'this' : used in base member initializer list
994# pragma warning(disable: 4231) // nonstandard extension used : 'extern' before template explicit instantiation 1052# pragma warning(disable: 4231) // nonstandard extension used : 'extern' before template explicit instantiation
1053# pragma warning(disable: 4710) // function not inlined
995# elif defined(Q_CC_BOR) 1054# elif defined(Q_CC_BOR)
996# pragma option -w-inl 1055# pragma option -w-inl
997# pragma option -w-aus 1056# pragma option -w-aus
998# pragma warn -inl 1057# pragma warn -inl
999# pragma warn -pia 1058# pragma warn -pia
1000# pragma warn -ccc 1059# pragma warn -ccc
1001# pragma warn -rch 1060# pragma warn -rch
1002# pragma warn -sig 1061# pragma warn -sig
1003# elif defined(Q_CC_MWERKS) 1062# elif defined(Q_CC_MWERKS)
1004# pragma warn_possunwant off 1063# pragma warn_possunwant off
1005# endif 1064# endif
1006#endif 1065#endif
diff --git a/qmake/include/qintdict.h b/qmake/include/qintdict.h
index b4cb223..0299879 100644
--- a/qmake/include/qintdict.h
+++ b/qmake/include/qintdict.h
@@ -90,25 +90,29 @@ template<> inline void QIntDict<void>::deleteItem( QPtrCollection::Item )
90#endif 90#endif
91 91
92template<class type> inline void QIntDict<type>::deleteItem( QPtrCollection::Item d ) 92template<class type> inline void QIntDict<type>::deleteItem( QPtrCollection::Item d )
93{ 93{
94 if ( del_item ) delete (type*)d; 94 if ( del_item ) delete (type*)d;
95} 95}
96 96
97template<class type> 97template<class type>
98class QIntDictIterator : public QGDictIterator 98class QIntDictIterator : public QGDictIterator
99{ 99{
100public: 100public:
101 QIntDictIterator(const QIntDict<type> &d) :QGDictIterator((QGDict &)d) {} 101 QIntDictIterator(const QIntDict<type> &d) :QGDictIterator((QGDict &)d) {}
102 ~QIntDictIterator() {} 102 ~QIntDictIterator() {}
103 uint count() const { return dict->count(); } 103 uint count() const { return dict->count(); }
104 bool isEmpty() const { return dict->count() == 0; } 104 bool isEmpty() const { return dict->count() == 0; }
105 type *toFirst() { return (type *)QGDictIterator::toFirst(); } 105 type *toFirst() { return (type *)QGDictIterator::toFirst(); }
106 operator type *() const { return (type *)QGDictIterator::get(); } 106 operator type *() const { return (type *)QGDictIterator::get(); }
107 type *current() const { return (type *)QGDictIterator::get(); } 107 type *current() const { return (type *)QGDictIterator::get(); }
108 long currentKey() const { return QGDictIterator::getKeyInt(); } 108 long currentKey() const { return QGDictIterator::getKeyInt(); }
109 type *operator()() { return (type *)QGDictIterator::operator()(); } 109 type *operator()() { return (type *)QGDictIterator::operator()(); }
110 type *operator++() { return (type *)QGDictIterator::operator++(); } 110 type *operator++() { return (type *)QGDictIterator::operator++(); }
111 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} 111 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);}
112}; 112};
113 113
114#ifdef QT_QWINEXPORT
115#define Q_DEFINED_QINTDICT
116#include "qwinexport.h"
117#endif /* QT_QWINEXPORT */
114#endif // QINTDICT_H 118#endif // QINTDICT_H
diff --git a/qmake/include/qmap.h b/qmake/include/qmap.h
index 269bd6b..4bc0a2f 100644
--- a/qmake/include/qmap.h
+++ b/qmake/include/qmap.h
@@ -859,25 +859,29 @@ Q_INLINE_TEMPLATES QDataStream& operator>>( QDataStream& s, QMap<Key,T>& m ) {
859 m.clear(); 859 m.clear();
860 Q_UINT32 c; 860 Q_UINT32 c;
861 s >> c; 861 s >> c;
862 for( Q_UINT32 i = 0; i < c; ++i ) { 862 for( Q_UINT32 i = 0; i < c; ++i ) {
863 Key k; T t; 863 Key k; T t;
864 s >> k >> t; 864 s >> k >> t;
865 m.insert( k, t ); 865 m.insert( k, t );
866 if ( s.atEnd() ) 866 if ( s.atEnd() )
867 break; 867 break;
868 } 868 }
869 return s; 869 return s;
870} 870}
871 871
872 872
873template<class Key, class T> 873template<class Key, class T>
874Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QMap<Key,T>& m ) { 874Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QMap<Key,T>& m ) {
875 s << (Q_UINT32)m.size(); 875 s << (Q_UINT32)m.size();
876 QMapConstIterator<Key,T> it = m.begin(); 876 QMapConstIterator<Key,T> it = m.begin();
877 for( ; it != m.end(); ++it ) 877 for( ; it != m.end(); ++it )
878 s << it.key() << it.data(); 878 s << it.key() << it.data();
879 return s; 879 return s;
880} 880}
881#endif 881#endif
882 882
883#ifdef QT_QWINEXPORT
884#define Q_DEFINED_QMAP
885#include "qwinexport.h"
886#endif /* QT_QWINEXPORT */
883#endif // QMAP_H 887#endif // QMAP_H
diff --git a/qmake/include/qmemarray.h b/qmake/include/qmemarray.h
index a5baf99..267670d 100644
--- a/qmake/include/qmemarray.h
+++ b/qmake/include/qmemarray.h
@@ -22,101 +22,108 @@
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QMEMARRAY_H 38#ifndef QMEMARRAY_H
39#define QMEMARRAY_H 39#define QMEMARRAY_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include "qgarray.h" 42#include "qgarray.h"
43#endif // QT_H 43#endif // QT_H
44 44
45 45
46template<class type> 46template<class type>
47class QMemArray : public QGArray 47class QMemArray : public QGArray
48{ 48{
49public: 49public:
50 typedef type* Iterator; 50 typedef type* Iterator;
51 typedef const type* ConstIterator; 51 typedef const type* ConstIterator;
52 typedef type ValueType; 52 typedef type ValueType;
53 53
54protected: 54protected:
55 QMemArray( int, int ) : QGArray( 0, 0 ) {} 55 QMemArray( int, int ) : QGArray( 0, 0 ) {}
56 56
57public: 57public:
58 QMemArray() {} 58 QMemArray() {}
59 QMemArray( int size ) : QGArray(size*sizeof(type)) {} 59 QMemArray( int size ) : QGArray(size*sizeof(type)) {}
60 QMemArray( const QMemArray<type> &a ) : QGArray(a) {} 60 QMemArray( const QMemArray<type> &a ) : QGArray(a) {}
61 ~QMemArray() {} 61 ~QMemArray() {}
62 QMemArray<type> &operator=(const QMemArray<type> &a) 62 QMemArray<type> &operator=(const QMemArray<type> &a)
63 { return (QMemArray<type>&)QGArray::assign(a); } 63 { return (QMemArray<type>&)QGArray::assign(a); }
64 type *data() const{ return (type *)QGArray::data(); } 64 type *data() const{ return (type *)QGArray::data(); }
65 uint nrefs() const{ return QGArray::nrefs(); } 65 uint nrefs() const{ return QGArray::nrefs(); }
66 uint size() const{ return QGArray::size()/sizeof(type); } 66 uint size() const{ return QGArray::size()/sizeof(type); }
67 uint count() const{ return size(); } 67 uint count() const{ return size(); }
68 bool isEmpty() const{ return QGArray::size() == 0; } 68 bool isEmpty() const{ return QGArray::size() == 0; }
69 bool isNull() const{ return QGArray::data() == 0; } 69 bool isNull() const{ return QGArray::data() == 0; }
70 bool resize( uint size ){ return QGArray::resize(size*sizeof(type)); } 70 bool resize( uint size ){ return QGArray::resize(size*sizeof(type)); }
71 bool resize( uint size, Optimization optim ) { return QGArray::resize(size*sizeof(type), optim); }
71 bool truncate( uint pos ){ return QGArray::resize(pos*sizeof(type)); } 72 bool truncate( uint pos ){ return QGArray::resize(pos*sizeof(type)); }
72 bool fill( const type &d, int size = -1 ) 73 bool fill( const type &d, int size = -1 )
73 { return QGArray::fill((char*)&d,size,sizeof(type) ); } 74 { return QGArray::fill((char*)&d,size,sizeof(type) ); }
74 void detach() { QGArray::detach(); } 75 void detach() { QGArray::detach(); }
75 QMemArray<type> copy() const 76 QMemArray<type> copy() const
76 { QMemArray<type> tmp; return tmp.duplicate(*this); } 77 { QMemArray<type> tmp; return tmp.duplicate(*this); }
77 QMemArray<type>& assign( const QMemArray<type>& a ) 78 QMemArray<type>& assign( const QMemArray<type>& a )
78 { return (QMemArray<type>&)QGArray::assign(a); } 79 { return (QMemArray<type>&)QGArray::assign(a); }
79 QMemArray<type>& assign( const type *a, uint n ) 80 QMemArray<type>& assign( const type *a, uint n )
80 { return (QMemArray<type>&)QGArray::assign((char*)a,n*sizeof(type)); } 81 { return (QMemArray<type>&)QGArray::assign((char*)a,n*sizeof(type)); }
81 QMemArray<type>& duplicate( const QMemArray<type>& a ) 82 QMemArray<type>& duplicate( const QMemArray<type>& a )
82 { return (QMemArray<type>&)QGArray::duplicate(a); } 83 { return (QMemArray<type>&)QGArray::duplicate(a); }
83 QMemArray<type>& duplicate( const type *a, uint n ) 84 QMemArray<type>& duplicate( const type *a, uint n )
84 { return (QMemArray<type>&)QGArray::duplicate((char*)a,n*sizeof(type)); } 85 { return (QMemArray<type>&)QGArray::duplicate((char*)a,n*sizeof(type)); }
85 QMemArray<type>& setRawData( const type *a, uint n ) 86 QMemArray<type>& setRawData( const type *a, uint n )
86 { return (QMemArray<type>&)QGArray::setRawData((char*)a, 87 { return (QMemArray<type>&)QGArray::setRawData((char*)a,
87 n*sizeof(type)); } 88 n*sizeof(type)); }
88 void resetRawData( const type *a, uint n ) 89 void resetRawData( const type *a, uint n )
89 { QGArray::resetRawData((char*)a,n*sizeof(type)); } 90 { QGArray::resetRawData((char*)a,n*sizeof(type)); }
90 int find( const type &d, uint i=0 ) const 91 int find( const type &d, uint i=0 ) const
91 { return QGArray::find((char*)&d,i,sizeof(type)); } 92 { return QGArray::find((char*)&d,i,sizeof(type)); }
92 int contains( const type &d ) const 93 int contains( const type &d ) const
93 { return QGArray::contains((char*)&d,sizeof(type)); } 94 { return QGArray::contains((char*)&d,sizeof(type)); }
94 void sort() { QGArray::sort(sizeof(type)); } 95 void sort() { QGArray::sort(sizeof(type)); }
95 int bsearch( const type &d ) const 96 int bsearch( const type &d ) const
96 { return QGArray::bsearch((const char*)&d,sizeof(type)); } 97 { return QGArray::bsearch((const char*)&d,sizeof(type)); }
97 // ### Qt 4.0: maybe provide uint overload as work-around for MSVC bug 98 // ### Qt 4.0: maybe provide uint overload as work-around for MSVC bug
98 type& operator[]( int i ) const 99 type& operator[]( int i ) const
99 { return (type &)(*(type *)QGArray::at(i*sizeof(type))); } 100 { return (type &)(*(type *)QGArray::at(i*sizeof(type))); }
100 type& at( uint i ) const 101 type& at( uint i ) const
101 { return (type &)(*(type *)QGArray::at(i*sizeof(type))); } 102 { return (type &)(*(type *)QGArray::at(i*sizeof(type))); }
102 operator const type*() const { return (const type *)QGArray::data(); } 103 operator const type*() const { return (const type *)QGArray::data(); }
103 bool operator==( const QMemArray<type> &a ) const { return isEqual(a); } 104 bool operator==( const QMemArray<type> &a ) const { return isEqual(a); }
104 bool operator!=( const QMemArray<type> &a ) const { return !isEqual(a); } 105 bool operator!=( const QMemArray<type> &a ) const { return !isEqual(a); }
105 Iterator begin() { return data(); } 106 Iterator begin() { return data(); }
106 Iterator end() { return data() + size(); } 107 Iterator end() { return data() + size(); }
107 ConstIterator begin() const { return data(); } 108 ConstIterator begin() const { return data(); }
108 ConstIterator end() const { return data() + size(); } 109 ConstIterator end() const { return data() + size(); }
109}; 110};
110 111
112#ifndef QT_QWINEXPORT
111#if defined(Q_TEMPLATEDLL) 113#if defined(Q_TEMPLATEDLL)
112// MOC_SKIP_BEGIN 114// MOC_SKIP_BEGIN
113Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<int>; 115Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<int>;
114Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<bool>; 116Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<bool>;
115// MOC_SKIP_END 117// MOC_SKIP_END
116#endif 118#endif
119#endif /* QT_QWINEXPORT */
117 120
118#ifndef QT_NO_COMPAT 121#ifndef QT_NO_COMPAT
119#define QArray QMemArray 122#define QArray QMemArray
120#endif 123#endif
121 124
125#ifdef QT_QWINEXPORT
126#define Q_DEFINED_QMEMARRAY
127#include <qwinexport.h>
128#endif /* QT_QWINEXPORT */
122#endif // QARRAY_H 129#endif // QARRAY_H
diff --git a/qmake/include/qptrlist.h b/qmake/include/qptrlist.h
index 53fb605..17b5ee9 100644
--- a/qmake/include/qptrlist.h
+++ b/qmake/include/qptrlist.h
@@ -1,31 +1,29 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QPtrList template/macro class 4** Definition of QPtrList template/macro class
5** 5**
6** Created :
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the tools module of the Qt GUI Toolkit. 8** This file is part of the tools module of the Qt GUI Toolkit.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
15** 13**
16** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 17** packaging of this file.
20** 18**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 21** Agreement provided with the Software.
24** 22**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 25**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
@@ -136,25 +134,29 @@ public:
136 operator type *() const { return (type *)QGListIterator::get(); } 134 operator type *() const { return (type *)QGListIterator::get(); }
137 type *operator*() { return (type *)QGListIterator::get(); } 135 type *operator*() { return (type *)QGListIterator::get(); }
138 136
139 // No good, since QPtrList<char> (ie. QStrList fails... 137 // No good, since QPtrList<char> (ie. QStrList fails...
140 // 138 //
141 // MSVC++ gives warning 139 // MSVC++ gives warning
142 // Sunpro C++ 4.1 gives error 140 // Sunpro C++ 4.1 gives error
143 // type *operator->() { return (type *)QGListIterator::get(); } 141 // type *operator->() { return (type *)QGListIterator::get(); }
144 142
145 type *current() const { return (type *)QGListIterator::get(); } 143 type *current() const { return (type *)QGListIterator::get(); }
146 type *operator()() { return (type *)QGListIterator::operator()();} 144 type *operator()() { return (type *)QGListIterator::operator()();}
147 type *operator++() { return (type *)QGListIterator::operator++(); } 145 type *operator++() { return (type *)QGListIterator::operator++(); }
148 type *operator+=(uint j) { return (type *)QGListIterator::operator+=(j);} 146 type *operator+=(uint j) { return (type *)QGListIterator::operator+=(j);}
149 type *operator--() { return (type *)QGListIterator::operator--(); } 147 type *operator--() { return (type *)QGListIterator::operator--(); }
150 type *operator-=(uint j) { return (type *)QGListIterator::operator-=(j);} 148 type *operator-=(uint j) { return (type *)QGListIterator::operator-=(j);}
151 QPtrListIterator<type>& operator=(const QPtrListIterator<type>&it) 149 QPtrListIterator<type>& operator=(const QPtrListIterator<type>&it)
152 { QGListIterator::operator=(it); return *this; } 150 { QGListIterator::operator=(it); return *this; }
153}; 151};
154 152
155#ifndef QT_NO_COMPAT 153#ifndef QT_NO_COMPAT
156#define QList QPtrList 154#define QList QPtrList
157#define QListIterator QPtrListIterator 155#define QListIterator QPtrListIterator
158#endif 156#endif
159 157
158#ifdef QT_QWINEXPORT
159#define Q_DEFINED_QPTRLIST
160#include "qwinexport.h"
161#endif /* QT_QWINEXPORT */
160#endif // QPTRLIST_H 162#endif // QPTRLIST_H
diff --git a/qmake/include/qptrvector.h b/qmake/include/qptrvector.h
index f6d9623..49b40b7 100644
--- a/qmake/include/qptrvector.h
+++ b/qmake/include/qptrvector.h
@@ -89,25 +89,29 @@ protected:
89 virtual int compareItems( QPtrCollection::Item d1, QPtrCollection::Item d2 ); 89 virtual int compareItems( QPtrCollection::Item d1, QPtrCollection::Item d2 );
90 virtual QDataStream& read( QDataStream &s, QPtrCollection::Item &d ); 90 virtual QDataStream& read( QDataStream &s, QPtrCollection::Item &d );
91 virtual QDataStream& write( QDataStream &s, QPtrCollection::Item d ) const; 91 virtual QDataStream& write( QDataStream &s, QPtrCollection::Item d ) const;
92#endif 92#endif
93 93
94private: 94private:
95 void deleteItem( Item d ); 95 void deleteItem( Item d );
96}; 96};
97 97
98#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) 98#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
99template<> inline void QPtrVector<void>::deleteItem( QPtrCollection::Item ) 99template<> inline void QPtrVector<void>::deleteItem( QPtrCollection::Item )
100{ 100{
101} 101}
102#endif 102#endif
103 103
104template<class type> inline void QPtrVector<type>::deleteItem( QPtrCollection::Item d ) 104template<class type> inline void QPtrVector<type>::deleteItem( QPtrCollection::Item d )
105{ 105{
106 if ( del_item ) delete (type *)d; 106 if ( del_item ) delete (type *)d;
107} 107}
108 108
109#ifndef QT_NO_COMPAT 109#ifndef QT_NO_COMPAT
110#define QVector QPtrVector 110#define QVector QPtrVector
111#endif 111#endif
112 112
113#ifdef QT_QWINEXPORT
114#define Q_DEFINED_QPTRVECTOR
115#include "qwinexport.h"
116#endif /* QT_QWINEXPORT */
113#endif // QVECTOR_H 117#endif // QVECTOR_H
diff --git a/qmake/include/qregexp.h b/qmake/include/qregexp.h
index 7bb777a..90f54bd 100644
--- a/qmake/include/qregexp.h
+++ b/qmake/include/qregexp.h
@@ -59,49 +59,49 @@ public:
59 QRegExp& operator=( const QRegExp& rx ); 59 QRegExp& operator=( const QRegExp& rx );
60 60
61 bool operator==( const QRegExp& rx ) const; 61 bool operator==( const QRegExp& rx ) const;
62 bool operator!=( const QRegExp& rx ) const { return !operator==( rx ); } 62 bool operator!=( const QRegExp& rx ) const { return !operator==( rx ); }
63 63
64 bool isEmpty() const; 64 bool isEmpty() const;
65 bool isValid() const; 65 bool isValid() const;
66 QString pattern() const; 66 QString pattern() const;
67 void setPattern( const QString& pattern ); 67 void setPattern( const QString& pattern );
68 bool caseSensitive() const; 68 bool caseSensitive() const;
69 void setCaseSensitive( bool sensitive ); 69 void setCaseSensitive( bool sensitive );
70#ifndef QT_NO_REGEXP_WILDCARD 70#ifndef QT_NO_REGEXP_WILDCARD
71 bool wildcard() const; 71 bool wildcard() const;
72 void setWildcard( bool wildcard ); 72 void setWildcard( bool wildcard );
73#endif 73#endif
74 bool minimal() const; 74 bool minimal() const;
75 void setMinimal( bool minimal ); 75 void setMinimal( bool minimal );
76 76
77 bool exactMatch( const QString& str ) const; 77 bool exactMatch( const QString& str ) const;
78#ifndef QT_NO_COMPAT 78#ifndef QT_NO_COMPAT
79 int match( const QString& str, int index = 0, int *len = 0, 79 int match( const QString& str, int index = 0, int *len = 0,
80 bool indexIsStart = TRUE ) const; 80 bool indexIsStart = TRUE ) const;
81#endif 81#endif
82 82
83#if defined(qdoc) 83#if defined(Q_QDOC)
84 int search( const QString& str, int offset = 0, 84 int search( const QString& str, int offset = 0,
85 CaretMode caretMode = CaretAtZero ) const; 85 CaretMode caretMode = CaretAtZero ) const;
86 int searchRev( const QString& str, int offset = -1, 86 int searchRev( const QString& str, int offset = -1,
87 CaretMode caretMode = CaretAtZero ) const; 87 CaretMode caretMode = CaretAtZero ) const;
88#else 88#else
89 // ### Qt 4.0: reduce these four to two functions 89 // ### Qt 4.0: reduce these four to two functions
90 int search( const QString& str, int offset = 0 ) const; 90 int search( const QString& str, int offset = 0 ) const;
91 int search( const QString& str, int offset, CaretMode caretMode ) const; 91 int search( const QString& str, int offset, CaretMode caretMode ) const;
92 int searchRev( const QString& str, int offset = -1 ) const; 92 int searchRev( const QString& str, int offset = -1 ) const;
93 int searchRev( const QString& str, int offset, CaretMode caretMode ) const; 93 int searchRev( const QString& str, int offset, CaretMode caretMode ) const;
94#endif 94#endif
95 int matchedLength() const; 95 int matchedLength() const;
96#ifndef QT_NO_REGEXP_CAPTURE 96#ifndef QT_NO_REGEXP_CAPTURE
97 int numCaptures() const; 97 int numCaptures() const;
98 QStringList capturedTexts(); 98 QStringList capturedTexts();
99 QString cap( int nth = 0 ); 99 QString cap( int nth = 0 );
100 int pos( int nth = 0 ); 100 int pos( int nth = 0 );
101 QString errorString(); 101 QString errorString();
102#endif 102#endif
103 103
104 static QString escape( const QString& str ); 104 static QString escape( const QString& str );
105 105
106private: 106private:
107 void compile( bool caseSensitive ); 107 void compile( bool caseSensitive );
diff --git a/qmake/include/qstring.h b/qmake/include/qstring.h
index 2a87a5a..c1d6740 100644
--- a/qmake/include/qstring.h
+++ b/qmake/include/qstring.h
@@ -1,69 +1,75 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of the QString class, and related Unicode 4** Definition of the QString class, and related Unicode functions.
5** functions.
6** 5**
7** Created : 920609 6** Created : 920609
8** 7**
9** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
10** 9**
11** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
12** 11**
13** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
14** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
15** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
16** 15**
17** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
18** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
19** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
20** packaging of this file. 19** packaging of this file.
21** 20**
22** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
23** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
24** Agreement provided with the Software. 23** Agreement provided with the Software.
25** 24**
26** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
27** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28** 27**
29** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
30** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
31** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
32** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
33** 32**
34** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
35** not clear to you. 34** not clear to you.
36** 35**
37**********************************************************************/ 36**********************************************************************/
38 37
39#ifndef QSTRING_H 38#ifndef QSTRING_H
40#define QSTRING_H 39#define QSTRING_H
41 40
42#ifndef QT_H 41#ifndef QT_H
43#include "qcstring.h" 42#include "qcstring.h"
44#endif // QT_H 43#endif // QT_H
45 44
45#ifndef QT_NO_STL
46#include <string>
47#if defined(Q_WRONG_SB_CTYPE_MACROS) && defined(_SB_CTYPE_MACROS)
48#undef _SB_CTYPE_MACROS
49#endif
50#endif
51
46 52
47/***************************************************************************** 53/*****************************************************************************
48 QString class 54 QString class
49 *****************************************************************************/ 55 *****************************************************************************/
50 56
51class QRegExp; 57class QRegExp;
52class QString; 58class QString;
53class QCharRef; 59class QCharRef;
54template <class T> class QDeepCopy; 60template <class T> class QDeepCopy;
55 61
56class Q_EXPORT QChar { 62class Q_EXPORT QChar {
57public: 63public:
58 QChar(); 64 QChar();
59 QChar( char c ); 65 QChar( char c );
60 QChar( uchar c ); 66 QChar( uchar c );
61 QChar( uchar c, uchar r ); 67 QChar( uchar c, uchar r );
62 QChar( const QChar& c ); 68 QChar( const QChar& c );
63 QChar( ushort rc ); 69 QChar( ushort rc );
64 QChar( short rc ); 70 QChar( short rc );
65 QChar( uint rc ); 71 QChar( uint rc );
66 QChar( int rc ); 72 QChar( int rc );
67 73
68 QT_STATIC_CONST QChar null; // 0000 74 QT_STATIC_CONST QChar null; // 0000
69 QT_STATIC_CONST QChar replacement; // FFFD 75 QT_STATIC_CONST QChar replacement; // FFFD
@@ -315,101 +321,105 @@ inline bool operator<=( QChar c, char ch )
315 321
316inline bool operator<=( char ch, QChar c ) 322inline bool operator<=( char ch, QChar c )
317{ 323{
318 return ((uchar) ch) <= c.ucs; 324 return ((uchar) ch) <= c.ucs;
319} 325}
320 326
321inline bool operator<=( QChar c1, QChar c2 ) 327inline bool operator<=( QChar c1, QChar c2 )
322{ 328{
323 return c1.ucs <= c2.ucs; 329 return c1.ucs <= c2.ucs;
324} 330}
325 331
326inline bool operator>=( QChar c, char ch ) { return ch <= c; } 332inline bool operator>=( QChar c, char ch ) { return ch <= c; }
327inline bool operator>=( char ch, QChar c ) { return c <= ch; } 333inline bool operator>=( char ch, QChar c ) { return c <= ch; }
328inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; } 334inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; }
329inline bool operator<( QChar c, char ch ) { return !(ch<=c); } 335inline bool operator<( QChar c, char ch ) { return !(ch<=c); }
330inline bool operator<( char ch, QChar c ) { return !(c<=ch); } 336inline bool operator<( char ch, QChar c ) { return !(c<=ch); }
331inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); } 337inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); }
332inline bool operator>( QChar c, char ch ) { return !(ch>=c); } 338inline bool operator>( QChar c, char ch ) { return !(ch>=c); }
333inline bool operator>( char ch, QChar c ) { return !(c>=ch); } 339inline bool operator>( char ch, QChar c ) { return !(c>=ch); }
334inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); } 340inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); }
335 341
336// internal 342// internal
337struct Q_EXPORT QStringData : public QShared { 343struct Q_EXPORT QStringData : public QShared {
338 QStringData() : 344 QStringData() :
339 QShared(), unicode(0), ascii(0), len(0), simpletext(1), maxl(0), dirty(0) { ref(); } 345 QShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); }
340 QStringData(QChar *u, uint l, uint m) : 346 QStringData(QChar *u, uint l, uint m) :
341 QShared(), unicode(u), ascii(0), len(l), simpletext(1), maxl(m), dirty(1) { } 347 QShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { }
342 ~QStringData() { if ( unicode ) delete[] ((char*)unicode); 348 ~QStringData() { if ( unicode ) delete[] ((char*)unicode);
343 if ( ascii ) delete[] ascii; } 349 if ( ascii ) delete[] ascii; }
344 350
345 void deleteSelf(); 351 void deleteSelf();
346 QChar *unicode; 352 QChar *unicode;
347 char *ascii; 353 char *ascii;
348 void setDirty() { 354 void setDirty() {
349 if ( ascii ) { 355 if ( ascii ) {
350 delete [] ascii; 356 delete [] ascii;
351 ascii = 0; 357 ascii = 0;
352 } 358 }
353 dirty = 1; 359 issimpletext = FALSE;
354 } 360 }
355#ifdef Q_OS_MAC9 361#ifdef Q_OS_MAC9
356 uint len; 362 uint len;
357#else 363#else
358 uint len : 30; 364 uint len : 30;
359#endif 365#endif
360 uint simpletext : 1; 366 uint issimpletext : 1;
361#ifdef Q_OS_MAC9 367#ifdef Q_OS_MAC9
362 uint maxl; 368 uint maxl;
363#else 369#else
364 uint maxl : 30; 370 uint maxl : 30;
365#endif 371#endif
366 uint dirty : 1; 372 uint islatin1 : 1;
367 373
368private: 374private:
369#if defined(Q_DISABLE_COPY) 375#if defined(Q_DISABLE_COPY)
370 QStringData( const QStringData& ); 376 QStringData( const QStringData& );
371 QStringData& operator=( const QStringData& ); 377 QStringData& operator=( const QStringData& );
372#endif 378#endif
373}; 379};
374 380
375 381
376class Q_EXPORT QString 382class Q_EXPORT QString
377{ 383{
378public: 384public:
379 QString(); // make null string 385 QString(); // make null string
380 QString( QChar ); // one-char string 386 QString( QChar ); // one-char string
381 QString( const QString & ); // impl-shared copy 387 QString( const QString & ); // impl-shared copy
382 QString( const QByteArray& ); // deep copy 388 QString( const QByteArray& ); // deep copy
383 QString( const QChar* unicode, uint length ); // deep copy 389 QString( const QChar* unicode, uint length ); // deep copy
384#ifndef QT_NO_CAST_ASCII 390#ifndef QT_NO_CAST_ASCII
385 QString( const char *str ); // deep copy 391 QString( const char *str ); // deep copy
386#endif 392#endif
393#ifndef QT_NO_STL
394 QString( const std::string& ); // deep copy
395#endif
387 ~QString(); 396 ~QString();
388 397
389 QString &operator=( const QString & ); // impl-shared copy 398 QString &operator=( const QString & ); // impl-shared copy
390#ifndef QT_NO_CAST_ASCII
391 QString &operator=( const char * ); // deep copy 399 QString &operator=( const char * ); // deep copy
400#ifndef QT_NO_STL
401 QString &operator=( const std::string& ); // deep copy
392#endif 402#endif
393 QString &operator=( const QCString& ); // deep copy 403 QString &operator=( const QCString& ); // deep copy
394 QString &operator=( QChar c ); 404 QString &operator=( QChar c );
395 QString &operator=( char c ); 405 QString &operator=( char c );
396 406
397 QT_STATIC_CONST QString null; 407 QT_STATIC_CONST QString null;
398 408
399 bool isNull() const; 409 bool isNull() const;
400 bool isEmpty() const; 410 bool isEmpty() const;
401 uint length() const; 411 uint length() const;
402 void truncate( uint pos ); 412 void truncate( uint pos );
403 413
404 QString & fill( QChar c, int len = -1 ); 414 QString & fill( QChar c, int len = -1 );
405 415
406 QString copy() const; 416 QString copy() const;
407 417
408 QString arg( long a, int fieldwidth=0, int base=10 ) const; 418 QString arg( long a, int fieldwidth=0, int base=10 ) const;
409 QString arg( ulong a, int fieldwidth=0, int base=10 ) const; 419 QString arg( ulong a, int fieldwidth=0, int base=10 ) const;
410 QString arg( int a, int fieldwidth=0, int base=10 ) const; 420 QString arg( int a, int fieldwidth=0, int base=10 ) const;
411 QString arg( uint a, int fieldwidth=0, int base=10 ) const; 421 QString arg( uint a, int fieldwidth=0, int base=10 ) const;
412 QString arg( short a, int fieldwidth=0, int base=10 ) const; 422 QString arg( short a, int fieldwidth=0, int base=10 ) const;
413 QString arg( ushort a, int fieldwidth=0, int base=10 ) const; 423 QString arg( ushort a, int fieldwidth=0, int base=10 ) const;
414 QString arg( char a, int fieldwidth=0 ) const; 424 QString arg( char a, int fieldwidth=0 ) const;
415 QString arg( QChar a, int fieldwidth=0 ) const; 425 QString arg( QChar a, int fieldwidth=0 ) const;
@@ -473,55 +483,61 @@ public:
473 QString left( uint len ) const; 483 QString left( uint len ) const;
474 QString right( uint len ) const; 484 QString right( uint len ) const;
475 QString mid( uint index, uint len=0xffffffff) const; 485 QString mid( uint index, uint len=0xffffffff) const;
476 486
477 QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const; 487 QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const;
478 QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const; 488 QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const;
479 489
480 QString lower() const; 490 QString lower() const;
481 QString upper() const; 491 QString upper() const;
482 492
483 QString stripWhiteSpace() const; 493 QString stripWhiteSpace() const;
484 QString simplifyWhiteSpace() const; 494 QString simplifyWhiteSpace() const;
485 495
486 QString &insert( uint index, const QString & ); 496 QString &insert( uint index, const QString & );
487 QString &insert( uint index, const QChar*, uint len ); 497 QString &insert( uint index, const QChar*, uint len );
488 QString &insert( uint index, QChar ); 498 QString &insert( uint index, QChar );
489 QString &insert( uint index, char c ) { return insert(index,QChar(c)); } 499 QString &insert( uint index, char c ) { return insert(index,QChar(c)); }
490 QString &append( char ); 500 QString &append( char );
491 QString &append( QChar ); 501 QString &append( QChar );
492 QString &append( const QString & ); 502 QString &append( const QString & );
493#ifndef QT_NO_CAST_ASCII 503#ifndef QT_NO_CAST_ASCII
494 QString &append( const QByteArray & ); 504 QString &append( const QByteArray & );
495 QString &append( const char * ); 505 QString &append( const char * );
496#endif 506#endif
507#ifndef QT_NO_STL
508 QString &append( const std::string& );
509#endif
497 QString &prepend( char ); 510 QString &prepend( char );
498 QString &prepend( QChar ); 511 QString &prepend( QChar );
499 QString &prepend( const QString & ); 512 QString &prepend( const QString & );
500#ifndef QT_NO_CAST_ASCII 513#ifndef QT_NO_CAST_ASCII
501 QString &prepend( const QByteArray & ); 514 QString &prepend( const QByteArray & );
502 QString &prepend( const char * ); 515 QString &prepend( const char * );
503#endif 516#endif
517#ifndef QT_NO_STL
518 QString &prepend( const std::string& );
519#endif
504 QString &remove( uint index, uint len ); 520 QString &remove( uint index, uint len );
505 QString &remove( QChar c ); 521 QString &remove( QChar c );
506 QString &remove( char c ) { return remove( QChar(c) ); } 522 QString &remove( char c ) { return remove( QChar(c) ); }
507 QString &remove( const QString & ); 523 QString &remove( const QString & );
508#ifndef QT_NO_REGEXP 524#ifndef QT_NO_REGEXP
509 QString &remove( const QRegExp & ); 525 QString &remove( const QRegExp & );
510#endif 526#endif
511#ifndef QT_NO_CAST_ASCII 527#ifndef QT_NO_CAST_ASCII
512 QString &remove( const char * ); 528 QString &remove( const char * );
513#endif 529#endif
514 QString &replace( uint index, uint len, const QString & ); 530 QString &replace( uint index, uint len, const QString & );
515 QString &replace( uint index, uint len, const QChar*, uint clen ); 531 QString &replace( uint index, uint len, const QChar*, uint clen );
516 QString &replace( uint index, uint len, QChar ); 532 QString &replace( uint index, uint len, QChar );
517 QString &replace( uint index, uint len, char c ) 533 QString &replace( uint index, uint len, char c )
518 { return replace( index, len, QChar(c) ); } 534 { return replace( index, len, QChar(c) ); }
519 QString &replace( QChar c, const QString & ); 535 QString &replace( QChar c, const QString & );
520 QString &replace( char c, const QString & after ) 536 QString &replace( char c, const QString & after )
521 { return replace( QChar(c), after ); } 537 { return replace( QChar(c), after ); }
522 QString &replace( const QString &, const QString & ); 538 QString &replace( const QString &, const QString & );
523#ifndef QT_NO_REGEXP_CAPTURE 539#ifndef QT_NO_REGEXP_CAPTURE
524 QString &replace( const QRegExp &, const QString & ); 540 QString &replace( const QRegExp &, const QString & );
525#endif 541#endif
526 QString &replace( QChar, QChar ); 542 QString &replace( QChar, QChar );
527 543
@@ -535,126 +551,135 @@ public:
535 double toDouble( bool *ok=0 ) const; 551 double toDouble( bool *ok=0 ) const;
536 552
537 QString &setNum( short, int base=10 ); 553 QString &setNum( short, int base=10 );
538 QString &setNum( ushort, int base=10 ); 554 QString &setNum( ushort, int base=10 );
539 QString &setNum( int, int base=10 ); 555 QString &setNum( int, int base=10 );
540 QString &setNum( uint, int base=10 ); 556 QString &setNum( uint, int base=10 );
541 QString &setNum( long, int base=10 ); 557 QString &setNum( long, int base=10 );
542 QString &setNum( ulong, int base=10 ); 558 QString &setNum( ulong, int base=10 );
543 QString &setNum( float, char f='g', int prec=6 ); 559 QString &setNum( float, char f='g', int prec=6 );
544 QString &setNum( double, char f='g', int prec=6 ); 560 QString &setNum( double, char f='g', int prec=6 );
545 561
546 static QString number( long, int base=10 ); 562 static QString number( long, int base=10 );
547 static QString number( ulong, int base=10); 563 static QString number( ulong, int base=10);
548 static QString number( int, int base=10 ); 564 static QString number( int, int base=10 );
549 static QString number( uint, int base=10); 565 static QString number( uint, int base=10);
550 static QString number( double, char f='g', int prec=6 ); 566 static QString number( double, char f='g', int prec=6 );
551 567
552 void setExpand( uint index, QChar c ); 568 void setExpand( uint index, QChar c );
553 569
554 QString &operator+=( const QString &str ); 570 QString &operator+=( const QString &str );
555#ifndef QT_NO_CAST_ASCII 571#ifndef QT_NO_CAST_ASCII
556 QString &operator+=( const QByteArray &str ); 572 QString &operator+=( const QByteArray &str );
557 QString &operator+=( const char *str ); 573 QString &operator+=( const char *str );
558#endif 574#endif
575#ifndef QT_NO_STL
576 QString &operator+=( const std::string& );
577#endif
559 QString &operator+=( QChar c ); 578 QString &operator+=( QChar c );
560 QString &operator+=( char c ); 579 QString &operator+=( char c );
561 580
562 QChar at( uint i ) const 581 QChar at( uint i ) const
563 { return i < d->len ? d->unicode[i] : QChar::null; } 582 { return i < d->len ? d->unicode[i] : QChar::null; }
564 QChar operator[]( int i ) const { return at((uint)i); } 583 QChar operator[]( int i ) const { return at((uint)i); }
565 QCharRef at( uint i ); 584 QCharRef at( uint i );
566 QCharRef operator[]( int i ); 585 QCharRef operator[]( int i );
567 586
568 QChar constref(uint i) const 587 QChar constref(uint i) const
569 { return at(i); } 588 { return at(i); }
570 QChar& ref(uint i) 589 QChar& ref(uint i)
571 { // Optimized for easy-inlining by simple compilers. 590 { // Optimized for easy-inlining by simple compilers.
572 if ( d->count != 1 || i >= d->len ) 591 if ( d->count != 1 || i >= d->len )
573 subat( i ); 592 subat( i );
574 d->setDirty(); 593 d->setDirty();
575 return d->unicode[i]; 594 return d->unicode[i];
576 } 595 }
577 596
578 const QChar* unicode() const { return d->unicode; } 597 const QChar* unicode() const { return d->unicode; }
579 const char* ascii() const { return latin1(); } 598 const char* ascii() const;
599 static QString fromAscii(const char*, int len=-1);
580 const char* latin1() const; 600 const char* latin1() const;
581 static QString fromLatin1(const char*, int len=-1); 601 static QString fromLatin1(const char*, int len=-1);
582 QCString utf8() const; 602 QCString utf8() const;
583 static QString fromUtf8(const char*, int len=-1); 603 static QString fromUtf8(const char*, int len=-1);
584 QCString local8Bit() const; 604 QCString local8Bit() const;
585 static QString fromLocal8Bit(const char*, int len=-1); 605 static QString fromLocal8Bit(const char*, int len=-1);
586 bool operator!() const; 606 bool operator!() const;
587#ifndef QT_NO_ASCII_CAST 607#ifndef QT_NO_ASCII_CAST
588 operator const char *() const { return latin1(); } 608 operator const char *() const { return ascii(); }
589#endif 609#endif
610#ifndef QT_NO_STL
611 operator std::string() const { return ascii() ? ascii() : ""; }
612#endif
613
590 static QString fromUcs2( const unsigned short *ucs2 ); 614 static QString fromUcs2( const unsigned short *ucs2 );
591 const unsigned short *ucs2() const; 615 const unsigned short *ucs2() const;
592 616
593 QString &setUnicode( const QChar* unicode, uint len ); 617 QString &setUnicode( const QChar* unicode, uint len );
594 QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ); 618 QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len );
619 QString &setAscii( const char*, int len=-1 );
595 QString &setLatin1( const char*, int len=-1 ); 620 QString &setLatin1( const char*, int len=-1 );
596 621
597 int compare( const QString& s ) const; 622 int compare( const QString& s ) const;
598 static int compare( const QString& s1, const QString& s2 ) 623 static int compare( const QString& s1, const QString& s2 )
599 { return s1.compare( s2 ); } 624 { return s1.compare( s2 ); }
600 625
601 int localeAwareCompare( const QString& s ) const; 626 int localeAwareCompare( const QString& s ) const;
602 static int localeAwareCompare( const QString& s1, const QString& s2 ) 627 static int localeAwareCompare( const QString& s1, const QString& s2 )
603 { return s1.localeAwareCompare( s2 ); } 628 { return s1.localeAwareCompare( s2 ); }
604 629
605#ifndef QT_NO_DATASTREAM 630#ifndef QT_NO_DATASTREAM
606 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & ); 631 friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & );
607#endif 632#endif
608 633
609 void compose(); 634 void compose();
610 635
611#ifndef QT_NO_COMPAT 636#ifndef QT_NO_COMPAT
612 const char* data() const { return latin1(); } 637 const char* data() const { return ascii(); }
613#endif 638#endif
614 639
615 bool startsWith( const QString& ) const; 640 bool startsWith( const QString& ) const;
616 bool endsWith( const QString& ) const; 641 bool endsWith( const QString& ) const;
617 642
618 void setLength( uint newLength ); 643 void setLength( uint newLength );
619 644
620 bool simpleText() const { if ( d->dirty ) checkSimpleText(); return (bool)d->simpletext; } 645 bool simpleText() const { if ( !d->issimpletext ) checkSimpleText(); return (bool)d->issimpletext; }
621 bool isRightToLeft() const; 646 bool isRightToLeft() const;
622 647
623 648
624private: 649private:
625 QString( int size, bool /* dummy */ );// allocate size incl. \0 650 QString( int size, bool /* dummy */ );// allocate size incl. \0
626 651
627 void deref(); 652 void deref();
628 void real_detach(); 653 void real_detach();
629 void subat( uint ); 654 void subat( uint );
630 bool findArg(int& pos, int& len) const; 655 bool findArg(int& pos, int& len) const;
631 656
632 void checkSimpleText() const; 657 void checkSimpleText() const;
633 658
634 static QChar* asciiToUnicode( const char*, uint * len, uint maxlen=(uint)-1 ); 659 static QChar* latin1ToUnicode( const char*, uint * len, uint maxlen=(uint)-1 );
635 static QChar* asciiToUnicode( const QByteArray&, uint * len ); 660 static QChar* latin1ToUnicode( const QByteArray&, uint * len );
636 static char* unicodeToAscii( const QChar*, uint len ); 661 static char* unicodeToLatin1( const QChar*, uint len );
637 662
638 QStringData *d; 663 QStringData *d;
639 static QStringData* shared_null; 664 static QStringData* shared_null;
640 static QStringData* makeSharedNull(); 665 static QStringData* makeSharedNull();
641 666
642 friend class QConstString; 667 friend class QConstString;
643 friend class QTextStream; 668 friend class QTextStream;
644 QString( QStringData* dd, bool /* dummy */ ) : d(dd) { } 669 QString( QStringData* dd, bool /* dummy */ ) : d(dd) { }
645 670
646 // needed for QDeepCopy 671 // needed for QDeepCopy
647 void detach(); 672 void detach();
648 friend class QDeepCopy<QString>; 673 friend class QDeepCopy<QString>;
649}; 674};
650 675
651class Q_EXPORT QCharRef { 676class Q_EXPORT QCharRef {
652 friend class QString; 677 friend class QString;
653 QString& s; 678 QString& s;
654 uint p; 679 uint p;
655 QCharRef(QString* str, uint pos) : s(*str), p(pos) { } 680 QCharRef(QString* str, uint pos) : s(*str), p(pos) { }
656 681
657public: 682public:
658 // most QChar operations repeated here... 683 // most QChar operations repeated here...
659 684
660 // all this is not documented: We just say "like QChar" and let it be. 685 // all this is not documented: We just say "like QChar" and let it be.
@@ -773,178 +798,194 @@ inline bool QString::isNull() const
773 798
774inline bool QString::operator!() const 799inline bool QString::operator!() const
775{ return isNull(); } 800{ return isNull(); }
776 801
777inline uint QString::length() const 802inline uint QString::length() const
778{ return d->len; } 803{ return d->len; }
779 804
780inline bool QString::isEmpty() const 805inline bool QString::isEmpty() const
781{ return length() == 0; } 806{ return length() == 0; }
782 807
783inline QString QString::copy() const 808inline QString QString::copy() const
784{ return QString( *this ); } 809{ return QString( *this ); }
785 810
786inline QString &QString::prepend( const QString & s ) 811inline QString &QString::prepend( const QString & s )
787{ return insert(0,s); } 812{ return insert(0,s); }
788 813
789inline QString &QString::prepend( QChar c ) 814inline QString &QString::prepend( QChar c )
790{ return insert(0,c); } 815{ return insert(0,c); }
791 816
792inline QString &QString::prepend( char c ) 817inline QString &QString::prepend( char c )
793{ return insert(0,c); } 818{ return insert(0,c); }
794 819
795#ifndef QT_NO_CAST_ASCII 820#ifndef QT_NO_CAST_ASCII
796inline QString &QString::prepend( const QByteArray & s ) 821inline QString &QString::prepend( const QByteArray & s )
797{ return insert(0,s.data()); } 822{ return insert(0,QString(s)); }
823#endif
824
825#ifndef QT_NO_STL
826inline QString &QString::prepend( const std::string& s )
827{ return insert(0, s); }
828#endif
829
830#ifndef QT_NO_CAST_ASCII
831inline QString &QString::operator+=( const QByteArray &s )
832{ return operator+=(QString(s)); }
798#endif 833#endif
799 834
800inline QString &QString::append( const QString & s ) 835inline QString &QString::append( const QString & s )
801{ return operator+=(s); } 836{ return operator+=(s); }
802 837
803#ifndef QT_NO_CAST_ASCII 838#ifndef QT_NO_CAST_ASCII
804inline QString &QString::append( const QByteArray &s ) 839inline QString &QString::append( const QByteArray &s )
805{ return operator+=(s.data()); } 840{ return operator+=(s); }
806 841
807inline QString &QString::append( const char * s ) 842inline QString &QString::append( const char * s )
808{ return operator+=(s); } 843{ return operator+=(s); }
809#endif 844#endif
810 845
811inline QString &QString::append( QChar c ) 846inline QString &QString::append( QChar c )
812{ return operator+=(c); } 847{ return operator+=(c); }
813 848
814inline QString &QString::append( char c ) 849inline QString &QString::append( char c )
815{ return operator+=(c); } 850{ return operator+=(c); }
816 851
817#ifndef QT_NO_CAST_ASCII 852#ifndef QT_NO_STL
818inline QString &QString::operator+=( const QByteArray &s ) 853inline QString &QString::operator+=( const std::string& s )
819{ return operator+=(s.data()); } 854{ return operator+=(s.c_str()); }
855inline QString &QString::append( const std::string& s )
856{ return operator+=(s); }
820#endif 857#endif
821 858
822inline QString &QString::setNum( short n, int base ) 859inline QString &QString::setNum( short n, int base )
823{ return setNum((long)n, base); } 860{ return setNum((long)n, base); }
824 861
825inline QString &QString::setNum( ushort n, int base ) 862inline QString &QString::setNum( ushort n, int base )
826{ return setNum((ulong)n, base); } 863{ return setNum((ulong)n, base); }
827 864
828inline QString &QString::setNum( int n, int base ) 865inline QString &QString::setNum( int n, int base )
829{ return setNum((long)n, base); } 866{ return setNum((long)n, base); }
830 867
831inline QString &QString::setNum( uint n, int base ) 868inline QString &QString::setNum( uint n, int base )
832{ return setNum((ulong)n, base); } 869{ return setNum((ulong)n, base); }
833 870
834inline QString &QString::setNum( float n, char f, int prec ) 871inline QString &QString::setNum( float n, char f, int prec )
835{ return setNum((double)n,f,prec); } 872{ return setNum((double)n,f,prec); }
836 873
837inline QString QString::arg(int a, int fieldwidth, int base) const 874inline QString QString::arg(int a, int fieldwidth, int base) const
838{ return arg((long)a, fieldwidth, base); } 875{ return arg((long)a, fieldwidth, base); }
839 876
840inline QString QString::arg(uint a, int fieldwidth, int base) const 877inline QString QString::arg(uint a, int fieldwidth, int base) const
841{ return arg((ulong)a, fieldwidth, base); } 878{ return arg((ulong)a, fieldwidth, base); }
842 879
843inline QString QString::arg(short a, int fieldwidth, int base) const 880inline QString QString::arg(short a, int fieldwidth, int base) const
844{ return arg((long)a, fieldwidth, base); } 881{ return arg((long)a, fieldwidth, base); }
845 882
846inline QString QString::arg(ushort a, int fieldwidth, int base) const 883inline QString QString::arg(ushort a, int fieldwidth, int base) const
847{ return arg((ulong)a, fieldwidth, base); } 884{ return arg((ulong)a, fieldwidth, base); }
848 885
849inline int QString::find( char c, int index, bool cs ) const 886inline int QString::find( char c, int index, bool cs ) const
850{ return find(QChar(c), index, cs); } 887{ return find(QChar(c), index, cs); }
851 888
852inline int QString::findRev( char c, int index, bool cs) const 889inline int QString::findRev( char c, int index, bool cs) const
853{ return findRev( QChar(c), index, cs ); } 890{ return findRev( QChar(c), index, cs ); }
854 891
855#ifndef QT_NO_CAST_ASCII 892#ifndef QT_NO_CAST_ASCII
856inline int QString::find( const char* str, int index ) const 893inline int QString::find( const char* str, int index ) const
857{ return find(QString::fromLatin1(str), index); } 894{ return find(QString::fromAscii(str), index); }
858 895
859inline int QString::findRev( const char* str, int index ) const 896inline int QString::findRev( const char* str, int index ) const
860{ return findRev(QString::fromLatin1(str), index); } 897{ return findRev(QString::fromAscii(str), index); }
861#endif 898#endif
862 899
863 900
864/***************************************************************************** 901/*****************************************************************************
865 QString non-member operators 902 QString non-member operators
866 *****************************************************************************/ 903 *****************************************************************************/
867 904
868Q_EXPORT bool operator!=( const QString &s1, const QString &s2 ); 905Q_EXPORT bool operator!=( const QString &s1, const QString &s2 );
869Q_EXPORT bool operator<( const QString &s1, const QString &s2 ); 906Q_EXPORT bool operator<( const QString &s1, const QString &s2 );
870Q_EXPORT bool operator<=( const QString &s1, const QString &s2 ); 907Q_EXPORT bool operator<=( const QString &s1, const QString &s2 );
871Q_EXPORT bool operator==( const QString &s1, const QString &s2 ); 908Q_EXPORT bool operator==( const QString &s1, const QString &s2 );
872Q_EXPORT bool operator>( const QString &s1, const QString &s2 ); 909Q_EXPORT bool operator>( const QString &s1, const QString &s2 );
873Q_EXPORT bool operator>=( const QString &s1, const QString &s2 ); 910Q_EXPORT bool operator>=( const QString &s1, const QString &s2 );
874#ifndef QT_NO_CAST_ASCII 911#ifndef QT_NO_CAST_ASCII
875Q_EXPORT bool operator!=( const QString &s1, const char *s2 ); 912Q_EXPORT bool operator!=( const QString &s1, const char *s2 );
876Q_EXPORT bool operator<( const QString &s1, const char *s2 ); 913Q_EXPORT bool operator<( const QString &s1, const char *s2 );
877Q_EXPORT bool operator<=( const QString &s1, const char *s2 ); 914Q_EXPORT bool operator<=( const QString &s1, const char *s2 );
878Q_EXPORT bool operator==( const QString &s1, const char *s2 ); 915Q_EXPORT bool operator==( const QString &s1, const char *s2 );
879Q_EXPORT bool operator>( const QString &s1, const char *s2 ); 916Q_EXPORT bool operator>( const QString &s1, const char *s2 );
880Q_EXPORT bool operator>=( const QString &s1, const char *s2 ); 917Q_EXPORT bool operator>=( const QString &s1, const char *s2 );
881Q_EXPORT bool operator!=( const char *s1, const QString &s2 ); 918Q_EXPORT bool operator!=( const char *s1, const QString &s2 );
882Q_EXPORT bool operator<( const char *s1, const QString &s2 ); 919Q_EXPORT bool operator<( const char *s1, const QString &s2 );
883Q_EXPORT bool operator<=( const char *s1, const QString &s2 ); 920Q_EXPORT bool operator<=( const char *s1, const QString &s2 );
884Q_EXPORT bool operator==( const char *s1, const QString &s2 ); 921Q_EXPORT bool operator==( const char *s1, const QString &s2 );
885//Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++ 922//Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++
886Q_EXPORT bool operator>=( const char *s1, const QString &s2 ); 923Q_EXPORT bool operator>=( const char *s1, const QString &s2 );
887#endif 924#endif
888 925
889Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 ) 926Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 )
890{ 927{
891 QString tmp( s1 ); 928 QString tmp( s1 );
892 tmp += s2; 929 tmp += s2;
893 return tmp; 930 return tmp;
894} 931}
895 932
896#ifndef QT_NO_CAST_ASCII 933#ifndef QT_NO_CAST_ASCII
897Q_EXPORT inline const QString operator+( const QString &s1, const char *s2 ) 934Q_EXPORT inline const QString operator+( const QString &s1, const char *s2 )
898{ 935{
899 QString tmp( s1 ); 936 QString tmp( s1 );
900 tmp += QString::fromLatin1(s2); 937 tmp += QString::fromAscii(s2);
901 return tmp; 938 return tmp;
902} 939}
903 940
904Q_EXPORT inline const QString operator+( const char *s1, const QString &s2 ) 941Q_EXPORT inline const QString operator+( const char *s1, const QString &s2 )
905{ 942{
906 QString tmp = QString::fromLatin1( s1 ); 943 QString tmp = QString::fromAscii( s1 );
907 tmp += s2; 944 tmp += s2;
908 return tmp; 945 return tmp;
909} 946}
910#endif 947#endif
911 948
912Q_EXPORT inline const QString operator+( const QString &s1, QChar c2 ) 949Q_EXPORT inline const QString operator+( const QString &s1, QChar c2 )
913{ 950{
914 QString tmp( s1 ); 951 QString tmp( s1 );
915 tmp += c2; 952 tmp += c2;
916 return tmp; 953 return tmp;
917} 954}
918 955
919Q_EXPORT inline const QString operator+( const QString &s1, char c2 ) 956Q_EXPORT inline const QString operator+( const QString &s1, char c2 )
920{ 957{
921 QString tmp( s1 ); 958 QString tmp( s1 );
922 tmp += c2; 959 tmp += c2;
923 return tmp; 960 return tmp;
924} 961}
925 962
926Q_EXPORT inline const QString operator+( QChar c1, const QString &s2 ) 963Q_EXPORT inline const QString operator+( QChar c1, const QString &s2 )
927{ 964{
928 QString tmp; 965 QString tmp;
929 tmp += c1; 966 tmp += c1;
930 tmp += s2; 967 tmp += s2;
931 return tmp; 968 return tmp;
932} 969}
933 970
934Q_EXPORT inline const QString operator+( char c1, const QString &s2 ) 971Q_EXPORT inline const QString operator+( char c1, const QString &s2 )
935{ 972{
936 QString tmp; 973 QString tmp;
937 tmp += c1; 974 tmp += c1;
938 tmp += s2; 975 tmp += s2;
939 return tmp; 976 return tmp;
940} 977}
941 978
942#if defined(Q_OS_WIN32) 979#if defined(Q_OS_WIN32)
943extern Q_EXPORT QString qt_winQString(void*); 980extern Q_EXPORT QString qt_winQString(void*);
944extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul); 981extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul);
945extern Q_EXPORT void* qt_winTchar_new(const QString& str); 982extern Q_EXPORT void* qt_winTchar_new(const QString& str);
946extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 ); 983extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 );
947extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 ); 984extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 );
948#endif 985#endif
949 986
987#ifdef QT_QWINEXPORT
988#define Q_DEFINED_QSTRING
989#include "qwinexport.h"
990#endif /* QT_QWINEXPORT */
950#endif // QSTRING_H 991#endif // QSTRING_H
diff --git a/qmake/include/qstrlist.h b/qmake/include/qstrlist.h
index 86de328..b9dd753 100644
--- a/qmake/include/qstrlist.h
+++ b/qmake/include/qstrlist.h
@@ -24,52 +24,54 @@
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QSTRLIST_H 38#ifndef QSTRLIST_H
39#define QSTRLIST_H 39#define QSTRLIST_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include "qstring.h" 42#include "qstring.h"
43#include "qptrlist.h" 43#include "qptrlist.h"
44#include "qdatastream.h" 44#include "qdatastream.h"
45#endif // QT_H 45#endif // QT_H
46 46
47 47
48#ifndef QT_QWINEXPORT
48#if defined(Q_TEMPLATEDLL) 49#if defined(Q_TEMPLATEDLL)
49Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<char>; 50Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<char>;
50Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrListIterator<char>; 51Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrListIterator<char>;
51#endif 52#endif
53#endif /* QT_QWINEXPORT */
52 54
53#if defined(Q_QDOC) 55#if defined(Q_QDOC)
54class QStrListIterator : public QPtrListIterator<char> 56class QStrListIterator : public QPtrListIterator<char>
55{ 57{
56}; 58};
57#else 59#else
58typedef QPtrListIterator<char> QStrListIterator; 60typedef QPtrListIterator<char> QStrListIterator;
59#endif 61#endif
60 62
61class Q_EXPORT QStrList : public QPtrList<char> 63class Q_EXPORT QStrList : public QPtrList<char>
62{ 64{
63public: 65public:
64 QStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; } 66 QStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; }
65 QStrList( const QStrList & ); 67 QStrList( const QStrList & );
66 ~QStrList() { clear(); } 68 ~QStrList() { clear(); }
67 QStrList& operator=( const QStrList & ); 69 QStrList& operator=( const QStrList & );
68 70
69private: 71private:
70 QPtrCollection::Item newItem( QPtrCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; } 72 QPtrCollection::Item newItem( QPtrCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; }
71 void deleteItem( QPtrCollection::Item d ) { if ( del_item ) delete[] (char*)d; } 73 void deleteItem( QPtrCollection::Item d ) { if ( del_item ) delete[] (char*)d; }
72 int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 ) { return qstrcmp((const char*)s1, 74 int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 ) { return qstrcmp((const char*)s1,
73 (const char*)s2); } 75 (const char*)s2); }
74#ifndef QT_NO_DATASTREAM 76#ifndef QT_NO_DATASTREAM
75 QDataStream &read( QDataStream &s, QPtrCollection::Item &d ) 77 QDataStream &read( QDataStream &s, QPtrCollection::Item &d )
diff --git a/qmake/include/qtextcodec.h b/qmake/include/qtextcodec.h
index 149b5cb..995e434 100644
--- a/qmake/include/qtextcodec.h
+++ b/qmake/include/qtextcodec.h
@@ -54,61 +54,75 @@ public:
54 virtual QCString fromUnicode(const QString& uc, int& lenInOut) = 0; 54 virtual QCString fromUnicode(const QString& uc, int& lenInOut) = 0;
55}; 55};
56 56
57class Q_EXPORT QTextDecoder { 57class Q_EXPORT QTextDecoder {
58public: 58public:
59 virtual ~QTextDecoder(); 59 virtual ~QTextDecoder();
60 virtual QString toUnicode(const char* chars, int len) = 0; 60 virtual QString toUnicode(const char* chars, int len) = 0;
61}; 61};
62 62
63class Q_EXPORT QTextCodec { 63class Q_EXPORT QTextCodec {
64public: 64public:
65 virtual ~QTextCodec(); 65 virtual ~QTextCodec();
66 66
67#ifndef QT_NO_CODECS 67#ifndef QT_NO_CODECS
68 static QTextCodec* loadCharmap(QIODevice*); 68 static QTextCodec* loadCharmap(QIODevice*);
69 static QTextCodec* loadCharmapFile(QString filename); 69 static QTextCodec* loadCharmapFile(QString filename);
70#endif //QT_NO_CODECS 70#endif //QT_NO_CODECS
71 static QTextCodec* codecForMib(int mib); 71 static QTextCodec* codecForMib(int mib);
72 static QTextCodec* codecForName(const char* hint, int accuracy=0); 72 static QTextCodec* codecForName(const char* hint, int accuracy=0);
73 static QTextCodec* codecForContent(const char* chars, int len); 73 static QTextCodec* codecForContent(const char* chars, int len);
74 static QTextCodec* codecForIndex(int i); 74 static QTextCodec* codecForIndex(int i);
75 static QTextCodec* codecForLocale(); 75 static QTextCodec* codecForLocale();
76 static void setCodecForLocale(QTextCodec *c); 76 static void setCodecForLocale(QTextCodec *c);
77 77
78 static QTextCodec* codecForTr();
79 static void setCodecForTr(QTextCodec *c);
80 static QTextCodec* codecForCStrings();
81 static void setCodecForCStrings(QTextCodec *c);
82
78 static void deleteAllCodecs(); 83 static void deleteAllCodecs();
79 84
80 static const char* locale(); 85 static const char* locale();
81 86
82 virtual const char* name() const = 0; 87 virtual const char* name() const = 0;
83 virtual const char* mimeName() const; 88 virtual const char* mimeName() const;
84 virtual int mibEnum() const = 0; 89 virtual int mibEnum() const = 0;
85 90
86 virtual QTextDecoder* makeDecoder() const; 91 virtual QTextDecoder* makeDecoder() const;
87 virtual QTextEncoder* makeEncoder() const; 92 virtual QTextEncoder* makeEncoder() const;
88 93
89 virtual QString toUnicode(const char* chars, int len) const; 94 virtual QString toUnicode(const char* chars, int len) const;
90 virtual QCString fromUnicode(const QString& uc, int& lenInOut) const; 95 virtual QCString fromUnicode(const QString& uc, int& lenInOut) const;
91 96
92 QCString fromUnicode(const QString& uc) const; 97 QCString fromUnicode(const QString& uc) const;
93 QString toUnicode(const QByteArray&, int len) const; 98 QString toUnicode(const QByteArray&, int len) const;
94 QString toUnicode(const QByteArray&) const; 99 QString toUnicode(const QByteArray&) const;
95 QString toUnicode(const QCString&, int len) const; 100 QString toUnicode(const QCString&, int len) const;
96 QString toUnicode(const QCString&) const; 101 QString toUnicode(const QCString&) const;
97 QString toUnicode(const char* chars) const; 102 QString toUnicode(const char* chars) const;
98 virtual bool canEncode( QChar ) const; 103 virtual bool canEncode( QChar ) const;
99 virtual bool canEncode( const QString& ) const; 104 virtual bool canEncode( const QString& ) const;
100 105
101 virtual int heuristicContentMatch(const char* chars, int len) const = 0; 106 virtual int heuristicContentMatch(const char* chars, int len) const = 0;
102 virtual int heuristicNameMatch(const char* hint) const; 107 virtual int heuristicNameMatch(const char* hint) const;
103 108
104 virtual QByteArray fromUnicode(const QString& uc, int from, int len) const; 109 virtual QByteArray fromUnicode(const QString& uc, int from, int len) const;
105 virtual unsigned short characterFromUnicode(const QString &str, int pos) const; 110 virtual unsigned short characterFromUnicode(const QString &str, int pos) const;
106 111
107protected: 112protected:
108 QTextCodec(); 113 QTextCodec();
109 static int simpleHeuristicNameMatch(const char* name, const char* hint); 114 static int simpleHeuristicNameMatch(const char* name, const char* hint);
110 115
116private:
117 static QTextCodec *cftr;
118 static QTextCodec *cfcs;
111 friend class QFont; 119 friend class QFont;
112}; 120};
121
122inline QTextCodec* QTextCodec::codecForTr() { return cftr; }
123inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; }
124inline QTextCodec* QTextCodec::codecForCStrings() { return cfcs; }
125inline void QTextCodec::setCodecForCStrings(QTextCodec *c) { cfcs = c; }
126
113#endif // QT_NO_TEXTCODEC 127#endif // QT_NO_TEXTCODEC
114#endif // QTEXTCODEC_H 128#endif // QTEXTCODEC_H
diff --git a/qmake/include/qtl.h b/qmake/include/qtl.h
index 346cecc..25631fd 100644
--- a/qmake/include/qtl.h
+++ b/qmake/include/qtl.h
@@ -68,48 +68,49 @@ public:
68}; 68};
69#endif //QT_NO_TEXTSTREAM 69#endif //QT_NO_TEXTSTREAM
70 70
71template <class InputIterator, class OutputIterator> 71template <class InputIterator, class OutputIterator>
72inline OutputIterator qCopy( InputIterator _begin, InputIterator _end, 72inline OutputIterator qCopy( InputIterator _begin, InputIterator _end,
73 OutputIterator _dest ) 73 OutputIterator _dest )
74{ 74{
75 while( _begin != _end ) 75 while( _begin != _end )
76 *_dest++ = *_begin++; 76 *_dest++ = *_begin++;
77 return _dest; 77 return _dest;
78} 78}
79 79
80template <class BiIterator, class BiOutputIterator> 80template <class BiIterator, class BiOutputIterator>
81inline BiOutputIterator qCopyBackward( BiIterator _begin, BiIterator _end, 81inline BiOutputIterator qCopyBackward( BiIterator _begin, BiIterator _end,
82 BiOutputIterator _dest ) 82 BiOutputIterator _dest )
83{ 83{
84 while ( _begin != _end ) 84 while ( _begin != _end )
85 *--_dest = *--_end; 85 *--_dest = *--_end;
86 return _dest; 86 return _dest;
87} 87}
88 88
89template <class InputIterator1, class InputIterator2> 89template <class InputIterator1, class InputIterator2>
90inline bool qEqual( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 ) 90inline bool qEqual( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 )
91{ 91{
92 // ### compare using !(*first1 == *first2) in Qt 4.0
92 for ( ; first1 != last1; ++first1, ++first2 ) 93 for ( ; first1 != last1; ++first1, ++first2 )
93 if ( *first1 != *first2 ) 94 if ( *first1 != *first2 )
94 return FALSE; 95 return FALSE;
95 return TRUE; 96 return TRUE;
96} 97}
97 98
98template <class ForwardIterator, class T> 99template <class ForwardIterator, class T>
99inline void qFill( ForwardIterator first, ForwardIterator last, const T& val ) 100inline void qFill( ForwardIterator first, ForwardIterator last, const T& val )
100{ 101{
101 for ( ; first != last; ++first ) 102 for ( ; first != last; ++first )
102 *first = val; 103 *first = val;
103} 104}
104 105
105#if 0 106#if 0
106template <class BiIterator, class OutputIterator> 107template <class BiIterator, class OutputIterator>
107inline OutputIterator qReverseCopy( BiIterator _begin, BiIterator _end, 108inline OutputIterator qReverseCopy( BiIterator _begin, BiIterator _end,
108 OutputIterator _dest ) 109 OutputIterator _dest )
109{ 110{
110 while ( _begin != _end ) { 111 while ( _begin != _end ) {
111 --_end; 112 --_end;
112 *_dest = *_end; 113 *_dest = *_end;
113 ++_dest; 114 ++_dest;
114 } 115 }
115 return _dest; 116 return _dest;
diff --git a/qmake/include/quuid.h b/qmake/include/quuid.h
index 591d2f1..664c149 100644
--- a/qmake/include/quuid.h
+++ b/qmake/include/quuid.h
@@ -1,80 +1,80 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QUuid class 4** Definition of QUuid class
5** 5**
6** Created: 010523 6** Created : 010523
7** 7**
8** Copyright (C) 1992-2001 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QUUID_H 38#ifndef QUUID_H
39#define QUUID_H 39#define QUUID_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include <qstring.h> 42#include <qstring.h>
43#endif // QT_H 43#endif // QT_H
44 44
45#include <string.h> 45#include <string.h>
46 46
47#if defined(Q_OS_WIN32) 47#if defined(Q_OS_WIN32)
48#ifndef GUID_DEFINED 48#ifndef GUID_DEFINED
49#define GUID_DEFINED 49#define GUID_DEFINED
50typedef struct _GUID 50typedef struct _GUID
51{ 51{
52 ulong Data1; 52 ulong Data1;
53 ushort Data2; 53 ushort Data2;
54 ushort Data3; 54 ushort Data3;
55 uchar Data4[ 8 ]; 55 uchar Data4[ 8 ];
56} GUID; 56} GUID, *REFGUID, *LPGUID;
57#endif 57#endif
58#endif 58#endif
59 59
60struct Q_EXPORT QUuid 60struct Q_EXPORT QUuid
61{ 61{
62 QUuid() 62 QUuid()
63 { 63 {
64 memset( this, 0, sizeof(QUuid) ); 64 memset( this, 0, sizeof(QUuid) );
65 } 65 }
66 QUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 ) 66 QUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 )
67 { 67 {
68 data1 = l; 68 data1 = l;
69 data2 = w1; 69 data2 = w1;
70 data3 = w2; 70 data3 = w2;
71 data4[0] = b1; 71 data4[0] = b1;
72 data4[1] = b2; 72 data4[1] = b2;
73 data4[2] = b3; 73 data4[2] = b3;
74 data4[3] = b4; 74 data4[3] = b4;
75 data4[4] = b5; 75 data4[4] = b5;
76 data4[5] = b6; 76 data4[5] = b6;
77 data4[6] = b7; 77 data4[6] = b7;
78 data4[7] = b8; 78 data4[7] = b8;
79 } 79 }
80 QUuid( const QUuid &uuid ) 80 QUuid( const QUuid &uuid )
diff --git a/qmake/include/qvaluelist.h b/qmake/include/qvaluelist.h
index 54f7aec..f5cd7bb 100644
--- a/qmake/include/qvaluelist.h
+++ b/qmake/include/qvaluelist.h
@@ -641,25 +641,29 @@ Q_INLINE_TEMPLATES QDataStream& operator>>( QDataStream& s, QValueList<T>& l )
641 l.clear(); 641 l.clear();
642 Q_UINT32 c; 642 Q_UINT32 c;
643 s >> c; 643 s >> c;
644 for( Q_UINT32 i = 0; i < c; ++i ) 644 for( Q_UINT32 i = 0; i < c; ++i )
645 { 645 {
646 T t; 646 T t;
647 s >> t; 647 s >> t;
648 l.append( t ); 648 l.append( t );
649 if ( s.atEnd() ) 649 if ( s.atEnd() )
650 break; 650 break;
651 } 651 }
652 return s; 652 return s;
653} 653}
654 654
655template <class T> 655template <class T>
656Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QValueList<T>& l ) 656Q_INLINE_TEMPLATES QDataStream& operator<<( QDataStream& s, const QValueList<T>& l )
657{ 657{
658 s << (Q_UINT32)l.size(); 658 s << (Q_UINT32)l.size();
659 QValueListConstIterator<T> it = l.begin(); 659 QValueListConstIterator<T> it = l.begin();
660 for( ; it != l.end(); ++it ) 660 for( ; it != l.end(); ++it )
661 s << *it; 661 s << *it;
662 return s; 662 return s;
663} 663}
664#endif // QT_NO_DATASTREAM 664#endif // QT_NO_DATASTREAM
665#ifdef QT_QWINEXPORT
666#define Q_DEFINED_QVALUELIST
667#include "qwinexport.h"
668#endif /* QT_QWINEXPORT */
665#endif // QVALUELIST_H 669#endif // QVALUELIST_H
diff --git a/qmake/include/qvaluestack.h b/qmake/include/qvaluestack.h
index 7e9bc48..c3f966e 100644
--- a/qmake/include/qvaluestack.h
+++ b/qmake/include/qvaluestack.h
@@ -1,64 +1,64 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of QValueStack class 4** Definition of QValueStack class
5** 5**
6** Created : 990925 6** Created : 990925
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#ifndef QVALUESTACK_H 38#ifndef QVALUESTACK_H
39#define QVALUESTACK_H 39#define QVALUESTACK_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include "qvaluelist.h" 42#include "qvaluelist.h"
43#endif // QT_H 43#endif // QT_H
44 44
45 45
46template<class T> 46template<class T>
47class QValueStack : public QValueList<T> 47class QValueStack : public QValueList<T>
48{ 48{
49public: 49public:
50 QValueStack() {} 50 QValueStack() {}
51 ~QValueStack() {} 51 ~QValueStack() {}
52 void push( const T& d ) { append(d); } 52 void push( const T& d ) { append(d); }
53 T pop() 53 T pop()
54 { 54 {
55 T elem( this->last() ); 55 T elem( this->last() );
56 if ( !this->isEmpty() ) 56 if ( !this->isEmpty() )
57 remove( this->fromLast() ); 57 this->remove( this->fromLast() );
58 return elem; 58 return elem;
59 } 59 }
60 T& top() { return this->last(); } 60 T& top() { return this->last(); }
61 const T& top() const { return this->last(); } 61 const T& top() const { return this->last(); }
62}; 62};
63 63
64#endif 64#endif
diff --git a/qmake/main.cpp b/qmake/main.cpp
index eed1697..cc2d08a 100644
--- a/qmake/main.cpp
+++ b/qmake/main.cpp
@@ -39,50 +39,55 @@
39#include "option.h" 39#include "option.h"
40#include "makefile.h" 40#include "makefile.h"
41#include <qnamespace.h> 41#include <qnamespace.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <ctype.h> 46#include <ctype.h>
47#include <fcntl.h> 47#include <fcntl.h>
48#include <sys/types.h> 48#include <sys/types.h>
49#include <sys/stat.h> 49#include <sys/stat.h>
50 50
51// for Borland, main is defined to qMain which breaks qmake 51// for Borland, main is defined to qMain which breaks qmake
52#undef main 52#undef main
53 53
54int main(int argc, char **argv) 54int main(int argc, char **argv)
55{ 55{
56 /* parse command line */ 56 /* parse command line */
57 if(!Option::parseCommandLine(argc, argv)) 57 if(!Option::parseCommandLine(argc, argv))
58 return 666; 58 return 666;
59 59
60 QDir sunworkshop42workaround = QDir::current(); 60 QDir sunworkshop42workaround = QDir::current();
61 QString oldpwd = sunworkshop42workaround.currentDirPath(); 61 QString oldpwd = sunworkshop42workaround.currentDirPath();
62 Option::output_dir = oldpwd; //for now this is the output dir 62 Option::output_dir = oldpwd; //for now this is the output dir
63 if(Option::output_dir.right(1) != QString(QChar(QDir::separator()))) 63#ifdef Q_WS_WIN
64 Option::output_dir += QDir::separator(); 64 if ( !(Option::output_dir.length() == 3 && Option::output_dir[0].isLetter() && Option::output_dir.endsWith(":/") ) )
65#endif
66 {
67 if(Option::output_dir.right(1) != QString(QChar(QDir::separator())))
68 Option::output_dir += QDir::separator();
69 }
65 QMakeProject proj; 70 QMakeProject proj;
66 int exit_val = 0; 71 int exit_val = 0;
67 QStringList files; 72 QStringList files;
68 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) 73 if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)
69 files << "(*hack*)"; //we don't even use files, but we do the for() body once 74 files << "(*hack*)"; //we don't even use files, but we do the for() body once
70 else 75 else
71 files = Option::mkfile::project_files; 76 files = Option::mkfile::project_files;
72 for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) { 77 for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) {
73 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 78 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
74 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 79 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
75 QString fn = (*pfile); 80 QString fn = (*pfile);
76 81
77 //setup pwd properly 82 //setup pwd properly
78 debug_msg(1, "Resetting dir to: %s", oldpwd.latin1()); 83 debug_msg(1, "Resetting dir to: %s", oldpwd.latin1());
79 QDir::setCurrent(oldpwd); //reset the old pwd 84 QDir::setCurrent(oldpwd); //reset the old pwd
80 int di = fn.findRev(Option::dir_sep); 85 int di = fn.findRev(Option::dir_sep);
81 if(di != -1) { 86 if(di != -1) {
82 debug_msg(1, "Changing dir to: %s", fn.left(di).latin1()); 87 debug_msg(1, "Changing dir to: %s", fn.left(di).latin1());
83 if(!QDir::setCurrent(fn.left(fn.findRev(Option::dir_sep)))) 88 if(!QDir::setCurrent(fn.left(fn.findRev(Option::dir_sep))))
84 fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1()); 89 fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1());
85 fn = fn.right(fn.length() - di - 1); 90 fn = fn.right(fn.length() - di - 1);
86 } 91 }
87 92
88 /* read project.. */ 93 /* read project.. */
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 34b3ee2..8b7e5e8 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -61,270 +61,325 @@ Option::QMAKE_MODE Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING;
61 61
62//all modes 62//all modes
63int Option::warn_level = WarnLogic; 63int Option::warn_level = WarnLogic;
64int Option::debug_level = 0; 64int Option::debug_level = 0;
65QFile Option::output; 65QFile Option::output;
66QString Option::output_dir; 66QString Option::output_dir;
67QStringList Option::before_user_vars; 67QStringList Option::before_user_vars;
68QStringList Option::after_user_vars; 68QStringList Option::after_user_vars;
69QString Option::user_template; 69QString Option::user_template;
70QString Option::user_template_prefix; 70QString Option::user_template_prefix;
71#if defined(Q_OS_WIN32) 71#if defined(Q_OS_WIN32)
72Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE; 72Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
73#elif defined(Q_OS_MAC9) 73#elif defined(Q_OS_MAC9)
74Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE; 74Option::TARG_MODE Option::target_mode = Option::TARG_MAC9_MODE;
75#elif defined(Q_OS_MACX) 75#elif defined(Q_OS_MACX)
76Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE; 76Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE;
77#elif defined(Q_OS_QNX6) 77#elif defined(Q_OS_QNX6)
78Option::TARG_MODE Option::target_mode = Option::TARG_QNX6_MODE; 78Option::TARG_MODE Option::target_mode = Option::TARG_QNX6_MODE;
79#else 79#else
80Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE; 80Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE;
81#endif 81#endif
82 82
83//QMAKE_GENERATE_PROJECT stuff 83//QMAKE_GENERATE_PROJECT stuff
84bool Option::projfile::do_pwd = TRUE; 84bool Option::projfile::do_pwd = TRUE;
85bool Option::projfile::do_recursive = FALSE; 85bool Option::projfile::do_recursive = TRUE;
86QStringList Option::projfile::project_dirs; 86QStringList Option::projfile::project_dirs;
87 87
88//QMAKE_GENERATE_MAKEFILE stuff 88//QMAKE_GENERATE_MAKEFILE stuff
89QString Option::mkfile::qmakespec; 89QString Option::mkfile::qmakespec;
90int Option::mkfile::cachefile_depth = -1; 90int Option::mkfile::cachefile_depth = -1;
91bool Option::mkfile::do_deps = TRUE; 91bool Option::mkfile::do_deps = TRUE;
92bool Option::mkfile::do_mocs = TRUE; 92bool Option::mkfile::do_mocs = TRUE;
93bool Option::mkfile::do_dep_heuristics = TRUE; 93bool Option::mkfile::do_dep_heuristics = TRUE;
94bool Option::mkfile::do_preprocess = FALSE; 94bool Option::mkfile::do_preprocess = FALSE;
95bool Option::mkfile::do_cache = TRUE; 95bool Option::mkfile::do_cache = TRUE;
96QString Option::mkfile::cachefile; 96QString Option::mkfile::cachefile;
97QStringList Option::mkfile::project_files; 97QStringList Option::mkfile::project_files;
98QString Option::mkfile::qmakespec_commandline; 98QString Option::mkfile::qmakespec_commandline;
99 99
100static Option::QMAKE_MODE default_mode(QString progname)
101{
102 int s = progname.findRev(Option::dir_sep);
103 if(s != -1)
104 progname = progname.right(progname.length() - (s + 1));
105 if(progname == "qmakegen")
106 return Option::QMAKE_GENERATE_PROJECT;
107 return Option::QMAKE_GENERATE_MAKEFILE;
108}
109
110QString project_builtin_regx();
100bool usage(const char *a0) 111bool usage(const char *a0)
101{ 112{
102 fprintf(stdout, "Usage: %s [mode] [options] [files]\n" 113 fprintf(stdout, "Usage: %s [mode] [options] [files]\n"
103 "\n" 114 "\n"
104 " QMake has two modes, one mode for generating project files based on\n" 115 " QMake has two modes, one mode for generating project files based on\n"
105 "some heuristics, and the other for generating makefiles. Normally you\n" 116 "some heuristics, and the other for generating makefiles. Normally you\n"
106 "shouldn't need to specify a mode, as makefile generation is the default\n" 117 "shouldn't need to specify a mode, as makefile generation is the default\n"
107 "mode for qmake, but you may use this to test qmake on an existing project\n" 118 "mode for qmake, but you may use this to test qmake on an existing project\n"
108 "\n" 119 "\n"
109 "Mode:\n" 120 "Mode:\n"
110 "\t-project Put qmake into project file generation mode\n" 121 "\t-project Put qmake into project file generation mode%s\n"
111 "\t In this mode qmake interprets files as files to\n" 122 "\t In this mode qmake interprets files as files to\n"
112 "\t be built,\n" 123 "\t be built,\n"
113 "\t defaults to *.cpp; *.l; *.y; *.ui\n" 124 "\t defaults to %s\n"
114 "\t-makefile Put qmake into makefile generation mode (default)\n" 125 "\t-makefile Put qmake into makefile generation mode%s\n"
115 "\t In this mode qmake interprets files as project files to\n" 126 "\t In this mode qmake interprets files as project files to\n"
116 "\t be processed, if skipped qmake will try to find a project\n" 127 "\t be processed, if skipped qmake will try to find a project\n"
117 "\t file in your current working directory\n" 128 "\t file in your current working directory\n"
118 "\n" 129 "\n"
119 "Warnings Options:\n" 130 "Warnings Options:\n"
120 "\t-Wnone Turn off all warnings\n" 131 "\t-Wnone Turn off all warnings\n"
121 "\t-Wall Turn on all warnings\n" 132 "\t-Wall Turn on all warnings\n"
122 "\t-Wparser Turn on parser warnings\n" 133 "\t-Wparser Turn on parser warnings\n"
123 "\t-Wlogic Turn on logic warnings\n" 134 "\t-Wlogic Turn on logic warnings\n"
124 "\n" 135 "\n"
125 "Options:\n" 136 "Options:\n"
126 "\t * You can place any variable assignment in options and it will be *\n" 137 "\t * You can place any variable assignment in options and it will be *\n"
127 "\t * processed as if it was in [files]. These assignments will be parsed *\n" 138 "\t * processed as if it was in [files]. These assignments will be parsed *\n"
128 "\t * before [files]. *\n" 139 "\t * before [files]. *\n"
129 "\t-o file Write output to file\n" 140 "\t-o file Write output to file\n"
130 "\t-unix Run in unix mode\n" 141 "\t-unix Run in unix mode\n"
131 "\t-win32 Run in win32 mode\n" 142 "\t-win32 Run in win32 mode\n"
132 "\t-macx Run in Mac OS X mode\n" 143 "\t-macx Run in Mac OS X mode\n"
133 "\t-d Increase debug level\n" 144 "\t-d Increase debug level\n"
134 "\t-t templ Overrides TEMPLATE as templ\n" 145 "\t-t templ Overrides TEMPLATE as templ\n"
135 "\t-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n" 146 "\t-tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n"
136 "\t-help This help\n" 147 "\t-help This help\n"
137 "\t-v Version information\n" 148 "\t-v Version information\n"
138 "\t-after All variable assignments after this will be\n" 149 "\t-after All variable assignments after this will be\n"
139 "\t parsed after [files] [makefile mode only]\n" 150 "\t parsed after [files]\n"
140 "\t-cache file Use file as cache [makefile mode only]\n" 151 "\t-cache file Use file as cache [makefile mode only]\n"
141 "\t-spec spec Use spec as QMAKESPEC [makefile mode only]\n" 152 "\t-spec spec Use spec as QMAKESPEC [makefile mode only]\n"
142 "\t-nocache Don't use a cache file [makefile mode only]\n" 153 "\t-nocache Don't use a cache file [makefile mode only]\n"
143 "\t-nodepend Don't generate dependencies [makefile mode only]\n" 154 "\t-nodepend Don't generate dependencies [makefile mode only]\n"
144 "\t-nomoc Don't generate moc targets [makefile mode only]\n" 155 "\t-nomoc Don't generate moc targets [makefile mode only]\n"
145 "\t-nopwd Don't look for files in pwd [ project mode only]\n" 156 "\t-nopwd Don't look for files in pwd [ project mode only]\n"
146 "\t-r Recursive search [ project mode only]\n" 157 "\t-norecursive Don't do a recursive search [ project mode only]\n"
147 ,a0); 158 ,a0,
159 default_mode(a0) == Option::QMAKE_GENERATE_PROJECT ? " (default)" : "", project_builtin_regx().latin1(),
160 default_mode(a0) == Option::QMAKE_GENERATE_MAKEFILE ? " (default)" : "");
148 return FALSE; 161 return FALSE;
149} 162}
150static Option::QMAKE_MODE default_mode(QString progname)
151{
152 int s = progname.findRev(Option::dir_sep);
153 if(s != -1)
154 progname = progname.right(progname.length() - (s + 1));
155 if(progname == "qmakegen")
156 return Option::QMAKE_GENERATE_PROJECT;
157 return Option::QMAKE_GENERATE_MAKEFILE;
158}
159
160 163
161bool 164bool
162Option::parseCommandLine(int argc, char **argv) 165Option::internalParseCommandLine(int argc, char **argv, int skip)
163{ 166{
164 bool before = TRUE; 167 bool before = TRUE;
165 for(int x = 1; x < argc; x++) { 168 for(int x = skip; x < argc; x++) {
166 if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */ 169 if(*argv[x] == '-' && strlen(argv[x]) > 1) { /* options */
167 QString opt = argv[x] + 1; 170 QString opt = argv[x] + 1;
168 171
169 //first param is a mode, or we default 172 //first param is a mode, or we default
170 if(x == 1) { 173 if(x == 1) {
171 bool specified = TRUE; 174 bool specified = TRUE;
172 if(opt == "project") { 175 if(opt == "project") {
173 Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT; 176 Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT;
174 } else if(opt == "prl") { 177 } else if(opt == "prl") {
175 Option::mkfile::do_deps = FALSE; 178 Option::mkfile::do_deps = FALSE;
176 Option::mkfile::do_mocs = FALSE; 179 Option::mkfile::do_mocs = FALSE;
177 Option::qmake_mode = Option::QMAKE_GENERATE_PRL; 180 Option::qmake_mode = Option::QMAKE_GENERATE_PRL;
178 } else if(opt == "makefile") { 181 } else if(opt == "makefile") {
179 Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE; 182 Option::qmake_mode = Option::QMAKE_GENERATE_MAKEFILE;
180 } else { 183 } else {
181 specified = FALSE; 184 specified = FALSE;
182 Option::qmake_mode = default_mode(argv[0]);
183 } 185 }
184 if(specified) 186 if(specified)
185 continue; 187 continue;
186 } 188 }
187 //all modes 189 //all modes
188 if(opt == "o" || opt == "output") { 190 if(opt == "o" || opt == "output") {
189 Option::output.setName(argv[++x]); 191 Option::output.setName(argv[++x]);
190 } else if(opt == "after") { 192 } else if(opt == "after") {
191 before = FALSE; 193 before = FALSE;
192 } else if(opt == "t" || opt == "template") { 194 } else if(opt == "t" || opt == "template") {
193 Option::user_template = argv[++x]; 195 Option::user_template = argv[++x];
194 } else if(opt == "tp" || opt == "template_prefix") { 196 } else if(opt == "tp" || opt == "template_prefix") {
195 Option::user_template_prefix = argv[++x]; 197 Option::user_template_prefix = argv[++x];
196 } else if(opt == "mac9") { 198 } else if(opt == "mac9") {
197 Option::target_mode = TARG_MAC9_MODE; 199 Option::target_mode = TARG_MAC9_MODE;
198 } else if(opt == "macx") { 200 } else if(opt == "macx") {
199 Option::target_mode = TARG_MACX_MODE; 201 Option::target_mode = TARG_MACX_MODE;
200 } else if(opt == "unix") { 202 } else if(opt == "unix") {
201 Option::target_mode = TARG_UNIX_MODE; 203 Option::target_mode = TARG_UNIX_MODE;
202 } else if(opt == "win32") { 204 } else if(opt == "win32") {
203 Option::target_mode = TARG_WIN_MODE; 205 Option::target_mode = TARG_WIN_MODE;
204 } else if(opt == "d") { 206 } else if(opt == "d") {
205 Option::debug_level++; 207 Option::debug_level++;
206 } else if(opt == "version" || opt == "v" || opt == "-version") { 208 } else if(opt == "version" || opt == "v" || opt == "-version") {
207 fprintf(stderr, "Qmake version: %s\n", qmake_version()); 209 fprintf(stderr, "Qmake version: %s (Qt %s)\n", qmake_version(), QT_VERSION_STR);
208 fprintf(stderr, "Qmake is free software from Trolltech AS.\n"); 210 fprintf(stderr, "Qmake is free software from Trolltech AS.\n");
209 return FALSE; 211 return FALSE;
210 } else if(opt == "h" || opt == "help") { 212 } else if(opt == "h" || opt == "help") {
211 return usage(argv[0]); 213 return FALSE;
212 } else if(opt == "Wall") { 214 } else if(opt == "Wall") {
213 Option::warn_level |= WarnAll; 215 Option::warn_level |= WarnAll;
214 } else if(opt == "Wparser") { 216 } else if(opt == "Wparser") {
215 Option::warn_level |= WarnParser; 217 Option::warn_level |= WarnParser;
216 } else if(opt == "Wlogic") { 218 } else if(opt == "Wlogic") {
217 Option::warn_level |= WarnLogic; 219 Option::warn_level |= WarnLogic;
218 } else if(opt == "Wnone") { 220 } else if(opt == "Wnone") {
219 Option::warn_level = WarnNone; 221 Option::warn_level = WarnNone;
220 } else { 222 } else {
221 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 223 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
222 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 224 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
223 if(opt == "nodepend") { 225 if(opt == "nodepend") {
224 Option::mkfile::do_deps = FALSE; 226 Option::mkfile::do_deps = FALSE;
225 } else if(opt == "nomoc") { 227 } else if(opt == "nomoc") {
226 Option::mkfile::do_mocs = FALSE; 228 Option::mkfile::do_mocs = FALSE;
227 } else if(opt == "nocache") { 229 } else if(opt == "nocache") {
228 Option::mkfile::do_cache = FALSE; 230 Option::mkfile::do_cache = FALSE;
229 } else if(opt == "nodependheuristics") { 231 } else if(opt == "nodependheuristics") {
230 Option::mkfile::do_dep_heuristics = FALSE; 232 Option::mkfile::do_dep_heuristics = FALSE;
231 } else if(opt == "E") { 233 } else if(opt == "E") {
232 Option::mkfile::do_preprocess = TRUE; 234 Option::mkfile::do_preprocess = TRUE;
233 } else if(opt == "cache") { 235 } else if(opt == "cache") {
234 Option::mkfile::cachefile = argv[++x]; 236 Option::mkfile::cachefile = argv[++x];
235 } else if(opt == "platform" || opt == "spec") { 237 } else if(opt == "platform" || opt == "spec") {
236 Option::mkfile::qmakespec = argv[++x]; 238 Option::mkfile::qmakespec = argv[++x];
237 Option::mkfile::qmakespec_commandline = argv[x]; 239 Option::mkfile::qmakespec_commandline = argv[x];
238 } else { 240 } else {
239 fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); 241 fprintf(stderr, "***Unknown option -%s\n", opt.latin1());
240 return usage(argv[0]); 242 return usage(argv[0]);
241 } 243 }
242 } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { 244 } else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
243 if(opt == "nopwd") { 245 if(opt == "nopwd") {
244 Option::projfile::do_pwd = FALSE; 246 Option::projfile::do_pwd = FALSE;
245 } else if(opt == "r") { 247 } else if(opt == "r") {
246 Option::projfile::do_recursive = TRUE; 248 Option::projfile::do_recursive = TRUE;
249 } else if(opt == "norecursive") {
250 Option::projfile::do_recursive = FALSE;
247 } else { 251 } else {
248 fprintf(stderr, "***Unknown option -%s\n", opt.latin1()); 252 fprintf(stderr, "***Unknown option -%s\n", opt.latin1());
249 return usage(argv[0]); 253 return FALSE;
250 } 254 }
251 } 255 }
252 } 256 }
253 } else { 257 } else {
254 if(x == 1)
255 Option::qmake_mode = default_mode(argv[0]);
256
257 QString arg = argv[x]; 258 QString arg = argv[x];
258 if(arg.find('=') != -1) { 259 if(arg.find('=') != -1) {
259 if(before) 260 if(before)
260 Option::before_user_vars.append(arg); 261 Option::before_user_vars.append(arg);
261 else 262 else
262 Option::after_user_vars.append(arg); 263 Option::after_user_vars.append(arg);
263 } else { 264 } else {
264 QFileInfo fi(arg); 265 QFileInfo fi(arg);
265 if(!fi.convertToAbs()) //strange 266 if(!fi.convertToAbs()) //strange
266 arg = fi.filePath(); 267 arg = fi.filePath();
267 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 268 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
268 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) 269 Option::qmake_mode == Option::QMAKE_GENERATE_PRL)
269 Option::mkfile::project_files.append(arg); 270 Option::mkfile::project_files.append(arg);
270 else 271 else
271 Option::projfile::project_dirs.append(arg); 272 Option::projfile::project_dirs.append(arg);
272 } 273 }
273 } 274 }
274 } 275 }
276 return TRUE;
277}
278
279
280bool
281Option::parseCommandLine(int argc, char **argv)
282{
283 Option::moc_mod = "moc_";
284 Option::lex_mod = "_lex";
285 Option::yacc_mod = "_yacc";
286 Option::prl_ext = ".prl";
287 Option::prf_ext = ".prf";
288 Option::ui_ext = ".ui";
289 Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx";
290 Option::moc_ext = ".moc";
291 Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C";
292 Option::lex_ext = ".l";
293 Option::yacc_ext = ".y";
294
275 if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) 295 if(Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING)
276 Option::qmake_mode = default_mode(argv[0]); 296 Option::qmake_mode = default_mode(argv[0]);
297 if(const char *envflags = getenv("QMAKEFLAGS")) {
298 int env_argc = 0, env_size = 0, currlen=0;
299 char quote = 0, **env_argv = NULL;
300 for(int i = 0; envflags[i]; i++) {
301 if(!quote && (envflags[i] == '\'' || envflags[i] == '"')) {
302 quote = envflags[i];
303 } else if(envflags[i] == quote) {
304 quote = 0;
305 } else if(!quote && envflags[i] == ' ') {
306 if(currlen && env_argv && env_argv[env_argc]) {
307 env_argv[env_argc][currlen] = '\0';
308 currlen = 0;
309 env_argc++;
310 }
311 } else {
312 if(!env_argv || env_argc > env_size) {
313 env_argv = (char **)realloc(env_argv, sizeof(char *)*(env_size+=10));
314 for(int i2 = env_argc; i2 < env_size; i2++)
315 env_argv[i2] = NULL;
316 }
317 if(!env_argv[env_argc]) {
318 currlen = 0;
319 env_argv[env_argc] = (char*)malloc(255);
320 }
321 if(currlen < 255)
322 env_argv[env_argc][currlen++] = envflags[i];
323 }
324 }
325 if(env_argv[env_argc]) {
326 env_argv[env_argc][currlen] = '\0';
327 currlen = 0;
328 env_argc++;
329 }
330 internalParseCommandLine(env_argc, env_argv);
331 for(int i2 = 0; i2 < env_size; i2++) {
332 if(env_argv[i2])
333 free(env_argv[i2]);
334 }
335 free(env_argv);
336 }
337 if(!internalParseCommandLine(argc, argv, 1))
338 return usage(argv[0]);
277 339
278 //last chance for defaults 340 //last chance for defaults
279 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || 341 if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
280 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { 342 Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
281 if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty()) 343 if(Option::mkfile::qmakespec.isNull() || Option::mkfile::qmakespec.isEmpty())
282 Option::mkfile::qmakespec = getenv("QMAKESPEC"); 344 Option::mkfile::qmakespec = getenv("QMAKESPEC");
283 345
284 //try REALLY hard to do it for them, lazy.. 346 //try REALLY hard to do it for them, lazy..
285 if(Option::mkfile::project_files.isEmpty()) { 347 if(Option::mkfile::project_files.isEmpty()) {
286 QString proj = QDir::currentDirPath(); 348 QString pwd = QDir::currentDirPath(),
287 proj = proj.right(proj.length() - (proj.findRev('/') + 1)) + ".pro"; 349 proj = pwd + "/" + pwd.right(pwd.length() - (pwd.findRev('/') + 1)) + ".pro";
288 if(QFile::exists(proj)) 350 if(QFile::exists(proj)) {
289 Option::mkfile::project_files.append(proj); 351 Option::mkfile::project_files.append(proj);
290 else 352 } else { //last try..
291 return usage(argv[0]); 353 QDir d(pwd, "*.pro");
354 if(d.count() != 1)
355 return usage(argv[0]);
356 Option::mkfile::project_files.append(pwd + "/" + d[0]);
357 }
292 } 358 }
293 } 359 }
294 360
295 //defaults for globals 361 //defaults for globals
296 Option::moc_mod = "moc_";
297 Option::lex_mod = "_lex";
298 Option::yacc_mod = "_yacc";
299 Option::prl_ext = ".prl";
300 Option::prf_ext = ".prf";
301 Option::ui_ext = ".ui";
302 Option::h_ext << ".h" << ".hpp" << ".hh" << ".H" << ".hxx";
303 Option::moc_ext = ".moc";
304 Option::cpp_ext << ".cpp" << ".cc" << ".cxx" << ".C";
305 Option::lex_ext = ".l";
306 Option::yacc_ext = ".y";
307 if(Option::target_mode == Option::TARG_WIN_MODE) { 362 if(Option::target_mode == Option::TARG_WIN_MODE) {
308 Option::dir_sep = "\\"; 363 Option::dir_sep = "\\";
309 Option::obj_ext = ".obj"; 364 Option::obj_ext = ".obj";
310 } else { 365 } else {
311 if(Option::target_mode == Option::TARG_MAC9_MODE) 366 if(Option::target_mode == Option::TARG_MAC9_MODE)
312 Option::dir_sep = ":"; 367 Option::dir_sep = ":";
313 else 368 else
314 Option::dir_sep = "/"; 369 Option::dir_sep = "/";
315 Option::obj_ext = ".o"; 370 Option::obj_ext = ".o";
316 } 371 }
317 return TRUE; 372 return TRUE;
318} 373}
319 374
320bool Option::postProcessProject(QMakeProject *project) 375bool Option::postProcessProject(QMakeProject *project)
321{ 376{
322 Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"]; 377 Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"];
323 if(cpp_ext.isEmpty()) 378 if(cpp_ext.isEmpty())
324 cpp_ext << ".cpp"; //something must be there 379 cpp_ext << ".cpp"; //something must be there
325 Option::h_ext = project->variables()["QMAKE_EXT_H"]; 380 Option::h_ext = project->variables()["QMAKE_EXT_H"];
326 if(h_ext.isEmpty()) 381 if(h_ext.isEmpty())
327 h_ext << ".h"; 382 h_ext << ".h";
328 383
329 if(!project->isEmpty("QMAKE_EXT_PRL")) 384 if(!project->isEmpty("QMAKE_EXT_PRL"))
330 Option::prl_ext = project->first("QMAKE_EXT_PRL"); 385 Option::prl_ext = project->first("QMAKE_EXT_PRL");
@@ -365,55 +420,55 @@ static QString fixPath(QString x)
365 QFileInfo fi(x); 420 QFileInfo fi(x);
366 if(fi.isDir()) { 421 if(fi.isDir()) {
367 QDir dir(x); 422 QDir dir(x);
368 x = dir.canonicalPath(); 423 x = dir.canonicalPath();
369 } else { 424 } else {
370 QString dir = fi.dir().canonicalPath(); 425 QString dir = fi.dir().canonicalPath();
371 if(!dir.isEmpty() && dir.right(1) != Option::dir_sep) 426 if(!dir.isEmpty() && dir.right(1) != Option::dir_sep)
372 dir += Option::dir_sep; 427 dir += Option::dir_sep;
373 x = dir + fi.fileName(); 428 x = dir + fi.fileName();
374 } 429 }
375#endif 430#endif
376 return QDir::cleanDirPath(x); 431 return QDir::cleanDirPath(x);
377} 432}
378 433
379 434
380QString 435QString
381Option::fixPathToTargetOS(const QString& in, bool fix_env, bool canonical) 436Option::fixPathToTargetOS(const QString& in, bool fix_env, bool canonical)
382{ 437{
383 QString tmp(in); 438 QString tmp(in);
384 if(fix_env) 439 if(fix_env)
385 fixEnvVariables(tmp); 440 fixEnvVariables(tmp);
386 if(canonical) 441 if(canonical)
387 tmp = fixPath(tmp); 442 tmp = fixPath(tmp);
388 QString rep; 443 QString rep;
389 if(Option::target_mode == TARG_MAC9_MODE) 444 if(Option::target_mode == TARG_MAC9_MODE)
390 rep = "[/\\\\]"; 445 tmp = tmp.replace('/', Option::dir_sep).replace('\\', Option::dir_sep);
391 else if(Option::target_mode == TARG_WIN_MODE) 446 else if(Option::target_mode == TARG_WIN_MODE)
392 rep = "[/]"; 447 tmp = tmp.replace('/', Option::dir_sep);
393 else 448 else
394 rep = "[\\\\]"; 449 tmp = tmp.replace('\\', Option::dir_sep);
395 return tmp.replace(QRegExp(rep), Option::dir_sep); 450 return tmp;
396} 451}
397 452
398QString 453QString
399Option::fixPathToLocalOS(const QString& in, bool fix_env, bool canonical) 454Option::fixPathToLocalOS(const QString& in, bool fix_env, bool canonical)
400{ 455{
401 QString tmp(in); 456 QString tmp(in);
402 if(fix_env) 457 if(fix_env)
403 fixEnvVariables(tmp); 458 fixEnvVariables(tmp);
404 if(canonical) 459 if(canonical)
405 tmp = fixPath(tmp); 460 tmp = fixPath(tmp);
406#if defined(Q_OS_WIN32) 461#if defined(Q_OS_WIN32)
407 return tmp.replace('/', '\\'); 462 return tmp.replace('/', '\\');
408#else 463#else
409 return tmp.replace('\\', '/'); 464 return tmp.replace('\\', '/');
410#endif 465#endif
411} 466}
412 467
413const char *qmake_version() 468const char *qmake_version()
414{ 469{
415 static char *ret = NULL; 470 static char *ret = NULL;
416 if(ret) 471 if(ret)
417 return ret; 472 return ret;
418 ret = (char *)malloc(15); 473 ret = (char *)malloc(15);
419 sprintf(ret, "%d.%02d%c", QMAKE_VERSION_MAJOR, QMAKE_VERSION_MINOR, 'a' + QMAKE_VERSION_PATCH); 474 sprintf(ret, "%d.%02d%c", QMAKE_VERSION_MAJOR, QMAKE_VERSION_MINOR, 'a' + QMAKE_VERSION_PATCH);
diff --git a/qmake/option.h b/qmake/option.h
index 9a5a85a..8bd348e 100644
--- a/qmake/option.h
+++ b/qmake/option.h
@@ -22,49 +22,49 @@
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __OPTION_H__ 37#ifndef __OPTION_H__
38#define __OPTION_H__ 38#define __OPTION_H__
39 39
40#include "project.h" 40#include "project.h"
41#include <qstring.h> 41#include <qstring.h>
42#include <qstringlist.h> 42#include <qstringlist.h>
43#include <qfile.h> 43#include <qfile.h>
44 44
45#define QMAKE_VERSION_MAJOR 1 45#define QMAKE_VERSION_MAJOR 1
46#define QMAKE_VERSION_MINOR 4 46#define QMAKE_VERSION_MINOR 5
47#define QMAKE_VERSION_PATCH 0 47#define QMAKE_VERSION_PATCH 0
48const char *qmake_version(); 48const char *qmake_version();
49 49
50void fixEnvVariables(QString &x); 50void fixEnvVariables(QString &x);
51void debug_msg(int level, const char *fmt, ...); 51void debug_msg(int level, const char *fmt, ...);
52enum QMakeWarn { 52enum QMakeWarn {
53 WarnNone = 0x00, 53 WarnNone = 0x00,
54 WarnParser = 0x01, 54 WarnParser = 0x01,
55 WarnLogic = 0x02, 55 WarnLogic = 0x02,
56 WarnAll = 0xFF 56 WarnAll = 0xFF
57}; 57};
58void warn_msg(QMakeWarn t, const char *fmt, ...); 58void warn_msg(QMakeWarn t, const char *fmt, ...);
59 59
60struct Option 60struct Option
61{ 61{
62 //simply global convenience 62 //simply global convenience
63 static QString prf_ext; 63 static QString prf_ext;
64 static QString prl_ext; 64 static QString prl_ext;
65 static QString ui_ext; 65 static QString ui_ext;
66 static QStringList h_ext; 66 static QStringList h_ext;
67 static QStringList cpp_ext; 67 static QStringList cpp_ext;
68 static QString moc_ext; 68 static QString moc_ext;
69 static QString obj_ext; 69 static QString obj_ext;
70 static QString lex_ext; 70 static QString lex_ext;
@@ -95,28 +95,31 @@ struct Option
95 enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE }; 95 enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, TARG_MAC9_MODE, TARG_QNX6_MODE };
96 static TARG_MODE target_mode; 96 static TARG_MODE target_mode;
97 static QString user_template, user_template_prefix; 97 static QString user_template, user_template_prefix;
98 98
99 //QMAKE_GENERATE_PROJECT options 99 //QMAKE_GENERATE_PROJECT options
100 struct projfile { 100 struct projfile {
101 static bool do_pwd; 101 static bool do_pwd;
102 static bool do_recursive; 102 static bool do_recursive;
103 static QStringList project_dirs; 103 static QStringList project_dirs;
104 }; 104 };
105 105
106 //QMAKE_GENERATE_MAKEFILE options 106 //QMAKE_GENERATE_MAKEFILE options
107 struct mkfile { 107 struct mkfile {
108 static QString qmakespec; 108 static QString qmakespec;
109 static bool do_cache; 109 static bool do_cache;
110 static bool do_deps; 110 static bool do_deps;
111 static bool do_mocs; 111 static bool do_mocs;
112 static bool do_dep_heuristics; 112 static bool do_dep_heuristics;
113 static bool do_preprocess; 113 static bool do_preprocess;
114 static QString cachefile; 114 static QString cachefile;
115 static int cachefile_depth; 115 static int cachefile_depth;
116 static QStringList project_files; 116 static QStringList project_files;
117 static QString qmakespec_commandline; 117 static QString qmakespec_commandline;
118 }; 118 };
119
120private:
121 static bool internalParseCommandLine(int, char **, int=0);
119}; 122};
120 123
121 124
122#endif /* __OPTION_H__ */ 125#endif /* __OPTION_H__ */
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 44eb503..834823d 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -45,147 +45,158 @@
45#ifdef Q_OS_UNIX 45#ifdef Q_OS_UNIX
46# include <unistd.h> 46# include <unistd.h>
47#endif 47#endif
48#include <stdio.h> 48#include <stdio.h>
49#include <stdlib.h> 49#include <stdlib.h>
50 50
51#ifdef Q_OS_WIN32 51#ifdef Q_OS_WIN32
52#define QT_POPEN _popen 52#define QT_POPEN _popen
53#else 53#else
54#define QT_POPEN popen 54#define QT_POPEN popen
55#endif 55#endif
56 56
57struct parser_info { 57struct parser_info {
58 QString file; 58 QString file;
59 int line_no; 59 int line_no;
60} parser; 60} parser;
61static void qmake_error_msg(const char *msg) 61static void qmake_error_msg(const char *msg)
62{ 62{
63 fprintf(stderr, "%s:%d: %s\n", parser.file.latin1(), parser.line_no, msg); 63 fprintf(stderr, "%s:%d: %s\n", parser.file.latin1(), parser.line_no, msg);
64} 64}
65 65
66static QString varMap(const QString &x) 66static QString varMap(const QString &x)
67{ 67{
68 QString ret(x); 68 QString ret(x);
69 ret.replace(QRegExp("^TMAKE"), "QMAKE"); 69 if(ret.startsWith("TMAKE")) //tmake no more!
70 ret = "QMAKE" + ret.mid(5);
70 if(ret == "INTERFACES") 71 if(ret == "INTERFACES")
71 ret = "FORMS"; 72 ret = "FORMS";
73 if(ret == "QMAKE_POST_BUILD")
74 ret = "QMAKE_POST_LINK";
75 if(ret == "TARGETDEPS")
76 ret = "POST_TARGETDEPS";
72 return ret; 77 return ret;
73} 78}
74 79
75static QStringList split_arg_list(const QString &params) 80static QStringList split_arg_list(const QString &params)
76{ 81{
77 QStringList args; 82 QStringList args;
78 int last = 0, parens = 0; 83 int last = 0, parens = 0;
79 QChar quote = 0; 84 QChar quote = 0;
80 for(int x = 0; x < (int)params.length(); x++) { 85 for(int x = 0; x < (int)params.length(); x++) {
81 if(params[x] == ')') { 86 if(params[x] == ')') {
82 parens--; 87 parens--;
83 } else if(params[x] == '(') { 88 } else if(params[x] == '(') {
84 parens++; 89 parens++;
85 } else if(params[x] == quote) { 90 } else if(params[x] == quote) {
86 quote = 0; 91 quote = 0;
87 } else if(params[x] == '\'' || params[x] == '"') { 92 } else if(params[x] == '\'' || params[x] == '"') {
88 quote = params[x]; 93 quote = params[x];
89 } else if(!parens && !quote && params[x] == ',') { 94 } else if(!parens && !quote && params[x] == ',') {
90 args << params.mid(last, x - last); 95 args << params.mid(last, x - last);
91 last = x+1; 96 last = x+1;
92 } 97 }
93 } 98 }
94 if(last != (int)params.length()) 99 if(last != (int)params.length())
95 args << params.mid(last); 100 args << params.mid(last);
96 return args; 101 return args;
97} 102}
98 103
99static QStringList split_value_list(const QString &vals, bool do_semicolon=FALSE) 104static QStringList split_value_list(const QString &vals, bool do_semicolon=FALSE)
100{ 105{
101 int last = 0; 106 int last = 0;
102 QStringList ret; 107 QStringList ret;
103 QValueStack<QChar> quote; 108 QValueStack<QChar> quote;
104 for(int x = 0; x < (int)vals.length(); x++) { 109 for(int x = 0; x < (int)vals.length(); x++) {
105 if(!quote.isEmpty() && vals[x] == quote.top()) { 110 if(!quote.isEmpty() && vals[x] == quote.top()) {
106 quote.pop(); 111 quote.pop();
107 } else if(vals[x] == '\'' || vals[x] == '"') { 112 } else if(vals[x] == '\'' || vals[x] == '"') {
108 quote.push(vals[x]); 113 quote.push(vals[x]);
109 } else if(quote.isEmpty() && 114 } else if(quote.isEmpty() &&
110 ((do_semicolon && vals[x] == ';') || vals[x] == ' ')) { 115 ((do_semicolon && vals[x] == ';') || vals[x] == ' ')) {
111 ret << vals.mid(last, x - last); 116 ret << vals.mid(last, x - last);
112 last = x+1; 117 last = x+1;
113 } 118 }
114 } 119 }
115 if(last != (int)vals.length()) 120 if(last != (int)vals.length())
116 ret << vals.mid(last); 121 ret << vals.mid(last);
117 return ret; 122 return ret;
118} 123}
119 124
120QMakeProject::QMakeProject() 125QMakeProject::QMakeProject()
121{ 126{
122} 127}
123 128
124bool 129bool
125QMakeProject::parse(QString t, QMap<QString, QStringList> &place) 130QMakeProject::parse(const QString &t, QMap<QString, QStringList> &place)
126{ 131{
127 QString s = t.simplifyWhiteSpace(); 132 QString s = t.simplifyWhiteSpace();
128 s.replace(QRegExp("#.*$"), ""); /* bye comments */ 133 int hash_mark = s.find('#');
134 if(hash_mark != -1) //good bye comments
135 s = s.left(hash_mark);
129 if(s.isEmpty()) /* blank_line */ 136 if(s.isEmpty()) /* blank_line */
130 return TRUE; 137 return TRUE;
131 138
132 if(s.stripWhiteSpace().left(1) == "}") { 139 if(s.stripWhiteSpace().left(1) == "}") {
133 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.latin1(), 140 debug_msg(1, "Project Parser: %s:%d : Leaving block %d", parser.file.latin1(),
134 parser.line_no, scope_block); 141 parser.line_no, scope_block);
135 test_status = ((scope_flag & (0x01 << scope_block)) ? TestFound : TestSeek); 142 test_status = ((scope_flag & (0x01 << scope_block)) ? TestFound : TestSeek);
136 scope_block--; 143 scope_block--;
137 s = s.mid(1).stripWhiteSpace(); 144 s = s.mid(1).stripWhiteSpace();
138 if(s.isEmpty()) 145 if(s.isEmpty())
139 return TRUE; 146 return TRUE;
140 } 147 }
141 if(!(scope_flag & (0x01 << scope_block))) { 148 if(!(scope_flag & (0x01 << scope_block))) {
142 /* adjust scope for each block which appears on a single line */ 149 /* adjust scope for each block which appears on a single line */
143 for(int i = (s.contains('{')-s.contains('}')); i; i--) 150 for(int i = (s.contains('{')-s.contains('}')); i; i--)
144 scope_flag &= ~(0x01 << (++scope_block)); 151 scope_flag &= ~(0x01 << (++scope_block));
145 debug_msg(1, "Project Parser: %s:%d : Ignored due to block being false.", 152 debug_msg(1, "Project Parser: %s:%d : Ignored due to block being false.",
146 parser.file.latin1(), parser.line_no); 153 parser.file.latin1(), parser.line_no);
147 return TRUE; 154 return TRUE;
148 } 155 }
149 156
150 QString scope, var, op; 157 QString scope, var, op;
151 QStringList val; 158 QStringList val;
152#define SKIP_WS(d) while(*d && (*d == ' ' || *d == '\t')) d++ 159#define SKIP_WS(d) while(*d && (*d == ' ' || *d == '\t')) d++
153 const char *d = s.latin1(); 160 const char *d = s.latin1();
154 SKIP_WS(d); 161 SKIP_WS(d);
155 bool scope_failed = FALSE, else_line = FALSE, or_op=FALSE; 162 bool scope_failed = FALSE, else_line = FALSE, or_op=FALSE;
156 int parens = 0, scope_count=0; 163 int parens = 0, scope_count=0;
157 while(*d && *d != '=') { 164 while(*d) {
158 if((*d == '+' || *d == '-' || *d == '*' || *d == '~')) { 165 if(!parens) {
159 if(*(d+1) == '=') { 166 if(*d == '=')
160 break; 167 break;
161 } else if(*(d+1) == ' ') { 168 if(*d == '+' || *d == '-' || *d == '*' || *d == '~') {
162 const char *k = d + 1; 169 if(*(d+1) == '=') {
163 SKIP_WS(k); 170 break;
164 if(*k == '=') { 171 } else if(*(d+1) == ' ') {
165 QString msg; 172 const char *k = d + 1;
166 qmake_error_msg(*d + "must be followed immediatly by ="); 173 SKIP_WS(k);
167 return FALSE; 174 if(*k == '=') {
175 QString msg;
176 qmake_error_msg(*d + "must be followed immediately by =");
177 return FALSE;
178 }
168 } 179 }
169 } 180 }
170 } 181 }
171 182
172 if ( *d == '(' ) 183 if ( *d == '(' )
173 ++parens; 184 ++parens;
174 else if ( *d == ')' ) 185 else if ( *d == ')' )
175 --parens; 186 --parens;
176 187
177 if(!parens && (*d == ':' || *d == '{' || *d == ')' || *d == '|')) { 188 if(!parens && (*d == ':' || *d == '{' || *d == ')' || *d == '|')) {
178 scope_count++; 189 scope_count++;
179 scope = var.stripWhiteSpace(); 190 scope = var.stripWhiteSpace();
180 if ( *d == ')' ) 191 if ( *d == ')' )
181 scope += *d; /* need this */ 192 scope += *d; /* need this */
182 var = ""; 193 var = "";
183 194
184 bool test = scope_failed; 195 bool test = scope_failed;
185 if(scope.lower() == "else") { 196 if(scope.lower() == "else") {
186 if(scope_count != 1 || test_status == TestNone) { 197 if(scope_count != 1 || test_status == TestNone) {
187 qmake_error_msg("Unexpected " + scope + " ('" + s + "')"); 198 qmake_error_msg("Unexpected " + scope + " ('" + s + "')");
188 return FALSE; 199 return FALSE;
189 } 200 }
190 else_line = TRUE; 201 else_line = TRUE;
191 test = (test_status == TestSeek); 202 test = (test_status == TestSeek);
@@ -196,49 +207,49 @@ QMakeProject::parse(QString t, QMap<QString, QStringList> &place)
196 QString comp_scope = scope; 207 QString comp_scope = scope;
197 bool invert_test = (comp_scope.left(1) == "!"); 208 bool invert_test = (comp_scope.left(1) == "!");
198 if(invert_test) 209 if(invert_test)
199 comp_scope = comp_scope.right(comp_scope.length()-1); 210 comp_scope = comp_scope.right(comp_scope.length()-1);
200 int lparen = comp_scope.find('('); 211 int lparen = comp_scope.find('(');
201 if(or_op || !scope_failed) { 212 if(or_op || !scope_failed) {
202 if(lparen != -1) { /* if there is an lparen in the scope, it IS a function */ 213 if(lparen != -1) { /* if there is an lparen in the scope, it IS a function */
203 int rparen = comp_scope.findRev(')'); 214 int rparen = comp_scope.findRev(')');
204 if(rparen == -1) { 215 if(rparen == -1) {
205 QCString error; 216 QCString error;
206 error.sprintf("Function missing right paren: %s ('%s')", 217 error.sprintf("Function missing right paren: %s ('%s')",
207 comp_scope.latin1(), s.latin1()); 218 comp_scope.latin1(), s.latin1());
208 qmake_error_msg(error); 219 qmake_error_msg(error);
209 return FALSE; 220 return FALSE;
210 } 221 }
211 QString func = comp_scope.left(lparen); 222 QString func = comp_scope.left(lparen);
212 test = doProjectTest(func, comp_scope.mid(lparen+1, rparen - lparen - 1), place); 223 test = doProjectTest(func, comp_scope.mid(lparen+1, rparen - lparen - 1), place);
213 if ( *d == ')' && !*(d+1) ) { 224 if ( *d == ')' && !*(d+1) ) {
214 if(invert_test) 225 if(invert_test)
215 test = !test; 226 test = !test;
216 test_status = (test ? TestFound : TestSeek); 227 test_status = (test ? TestFound : TestSeek);
217 return TRUE; /* assume we are done */ 228 return TRUE; /* assume we are done */
218 } 229 }
219 } else { 230 } else {
220 test = isActiveConfig(comp_scope.stripWhiteSpace()); 231 test = isActiveConfig(comp_scope.stripWhiteSpace(), TRUE);
221 } 232 }
222 if(invert_test) 233 if(invert_test)
223 test = !test; 234 test = !test;
224 } 235 }
225 } 236 }
226 if(!test && !scope_failed) 237 if(!test && !scope_failed)
227 debug_msg(1, "Project Parser: %s:%d : Test (%s) failed.", parser.file.latin1(), 238 debug_msg(1, "Project Parser: %s:%d : Test (%s) failed.", parser.file.latin1(),
228 parser.line_no, scope.latin1()); 239 parser.line_no, scope.latin1());
229 if(test == or_op) 240 if(test == or_op)
230 scope_failed = !test; 241 scope_failed = !test;
231 or_op = (*d == '|'); 242 or_op = (*d == '|');
232 if(*d == '{') { /* scoping block */ 243 if(*d == '{') { /* scoping block */
233 if(!scope_failed) 244 if(!scope_failed)
234 scope_flag |= (0x01 << (++scope_block)); 245 scope_flag |= (0x01 << (++scope_block));
235 else 246 else
236 scope_flag &= ~(0x01 << (++scope_block)); 247 scope_flag &= ~(0x01 << (++scope_block));
237 debug_msg(1, "Project Parser: %s:%d : Entering block %d (%d).", parser.file.latin1(), 248 debug_msg(1, "Project Parser: %s:%d : Entering block %d (%d).", parser.file.latin1(),
238 parser.line_no, scope_block, !scope_failed); 249 parser.line_no, scope_block, !scope_failed);
239 } 250 }
240 } else { 251 } else {
241 var += *d; 252 var += *d;
242 } 253 }
243 d++; 254 d++;
244 } 255 }
@@ -266,49 +277,49 @@ QMakeProject::parse(QString t, QMap<QString, QStringList> &place)
266 parser.line_no, scope_block); 277 parser.line_no, scope_block);
267 test_status = ((scope_flag & (0x01 << scope_block)) ? TestFound : TestSeek); 278 test_status = ((scope_flag & (0x01 << scope_block)) ? TestFound : TestSeek);
268 scope_block--; 279 scope_block--;
269 vals.truncate(vals.length()-1); 280 vals.truncate(vals.length()-1);
270 } else if(rbraces != lbraces) { 281 } else if(rbraces != lbraces) {
271 warn_msg(WarnParser, "Possible braces mismatch {%s} %s:%d", 282 warn_msg(WarnParser, "Possible braces mismatch {%s} %s:%d",
272 vals.latin1(), parser.file.latin1(), parser.line_no); 283 vals.latin1(), parser.file.latin1(), parser.line_no);
273 } 284 }
274 doVariableReplace(vals, place); 285 doVariableReplace(vals, place);
275 286
276 var = var.stripWhiteSpace(); 287 var = var.stripWhiteSpace();
277#undef SKIP_WS 288#undef SKIP_WS
278 289
279 if(!var.isEmpty() && Option::mkfile::do_preprocess) { 290 if(!var.isEmpty() && Option::mkfile::do_preprocess) {
280 static QString last_file("*none*"); 291 static QString last_file("*none*");
281 if(parser.file != last_file) { 292 if(parser.file != last_file) {
282 fprintf(stderr, "#file %s:%d\n", parser.file.latin1(), parser.line_no); 293 fprintf(stderr, "#file %s:%d\n", parser.file.latin1(), parser.line_no);
283 last_file = parser.file; 294 last_file = parser.file;
284 } 295 }
285 fprintf(stderr, "%s %s %s\n", var.latin1(), op.latin1(), vals.latin1()); 296 fprintf(stderr, "%s %s %s\n", var.latin1(), op.latin1(), vals.latin1());
286 } 297 }
287 var = varMap(var); //backwards compatability 298 var = varMap(var); //backwards compatability
288 299
289 /* vallist is the broken up list of values */ 300 /* vallist is the broken up list of values */
290 QStringList vallist = split_value_list(vals, (var == "DEPENDPATH" || var == "INCLUDEPATH")); 301 QStringList vallist = split_value_list(vals, (var == "DEPENDPATH" || var == "INCLUDEPATH"));
291 if(!vallist.grep("=").isEmpty()) 302 if(!vallist.grep("=").isEmpty())
292 warn_msg(WarnParser, "Detected possible line continuation: {%s} %s:%d", 303 warn_msg(WarnParser, "Detected possible line continuation: {%s} %s:%d",
293 var.latin1(), parser.file.latin1(), parser.line_no); 304 var.latin1(), parser.file.latin1(), parser.line_no);
294 305
295 QStringList &varlist = place[var]; /* varlist is the list in the symbol table */ 306 QStringList &varlist = place[var]; /* varlist is the list in the symbol table */
296 debug_msg(1, "Project Parser: %s:%d :%s: :%s: (%s)", parser.file.latin1(), parser.line_no, 307 debug_msg(1, "Project Parser: %s:%d :%s: :%s: (%s)", parser.file.latin1(), parser.line_no,
297 var.latin1(), op.latin1(), vallist.join(" :: ").latin1()); 308 var.latin1(), op.latin1(), vallist.join(" :: ").latin1());
298 309
299 /* now do the operation */ 310 /* now do the operation */
300 if(op == "~=") { 311 if(op == "~=") {
301 if(vallist.count() != 1) { 312 if(vallist.count() != 1) {
302 qmake_error_msg("~= operator only accepts one right hand paramater ('" + 313 qmake_error_msg("~= operator only accepts one right hand paramater ('" +
303 s + "')"); 314 s + "')");
304 return FALSE; 315 return FALSE;
305 } 316 }
306 QString val(vallist.first()); 317 QString val(vallist.first());
307 if(val.length() < 4 || val.at(0) != 's') { 318 if(val.length() < 4 || val.at(0) != 's') {
308 qmake_error_msg("~= operator only can handle s/// function ('" + 319 qmake_error_msg("~= operator only can handle s/// function ('" +
309 s + "')"); 320 s + "')");
310 return FALSE; 321 return FALSE;
311 } 322 }
312 QChar sep = val.at(1); 323 QChar sep = val.at(1);
313 QStringList func = QStringList::split(sep, val, TRUE); 324 QStringList func = QStringList::split(sep, val, TRUE);
314 if(func.count() < 3 || func.count() > 4) { 325 if(func.count() < 3 || func.count() > 4) {
@@ -334,162 +345,163 @@ QMakeProject::parse(QString t, QMap<QString, QStringList> &place)
334 if(op == "=") { 345 if(op == "=") {
335 if(!varlist.isEmpty()) 346 if(!varlist.isEmpty())
336 warn_msg(WarnParser, "Operator=(%s) clears variables previously set: %s:%d", 347 warn_msg(WarnParser, "Operator=(%s) clears variables previously set: %s:%d",
337 var.latin1(), parser.file.latin1(), parser.line_no); 348 var.latin1(), parser.file.latin1(), parser.line_no);
338 varlist.clear(); 349 varlist.clear();
339 } 350 }
340 for(QStringList::Iterator valit = vallist.begin(); 351 for(QStringList::Iterator valit = vallist.begin();
341 valit != vallist.end(); ++valit) { 352 valit != vallist.end(); ++valit) {
342 if((*valit).isEmpty()) 353 if((*valit).isEmpty())
343 continue; 354 continue;
344 if((op == "*=" && !(*varlist.find((*valit)))) || 355 if((op == "*=" && !(*varlist.find((*valit)))) ||
345 op == "=" || op == "+=") 356 op == "=" || op == "+=")
346 varlist.append((*valit)); 357 varlist.append((*valit));
347 else if(op == "-=") 358 else if(op == "-=")
348 varlist.remove((*valit)); 359 varlist.remove((*valit));
349 } 360 }
350 } 361 }
351 if(var == "REQUIRES") /* special case to get communicated to backends! */ 362 if(var == "REQUIRES") /* special case to get communicated to backends! */
352 doProjectCheckReqs(vallist, place); 363 doProjectCheckReqs(vallist, place);
353 364
354 return TRUE; 365 return TRUE;
355} 366}
356 367
357bool 368bool
358QMakeProject::read(QString file, QMap<QString, QStringList> &place) 369QMakeProject::read(const QString &file, QMap<QString, QStringList> &place)
359{ 370{
360 parser_info pi = parser; 371 parser_info pi = parser;
361 /* scope blocks start at true */ 372 /* scope blocks start at true */
362 test_status = TestNone; 373 test_status = TestNone;
363 scope_flag = 0x01; 374 scope_flag = 0x01;
364 scope_block = 0; 375 scope_block = 0;
365 376
366 file = Option::fixPathToLocalOS(file); 377 QString filename = Option::fixPathToLocalOS(file);
367 doVariableReplace(file, place); 378 doVariableReplace(filename, place);
368 bool ret = FALSE, using_stdin = FALSE; 379 bool ret = FALSE, using_stdin = FALSE;
369 QFile qfile; 380 QFile qfile;
370 if(!strcmp(file, "-")) { 381 if(!strcmp(filename, "-")) {
371 qfile.setName(""); 382 qfile.setName("");
372 ret = qfile.open(IO_ReadOnly, stdin); 383 ret = qfile.open(IO_ReadOnly, stdin);
373 using_stdin = TRUE; 384 using_stdin = TRUE;
374 } else { 385 } else {
375 qfile.setName(file); 386 qfile.setName(filename);
376 ret = qfile.open(IO_ReadOnly); 387 ret = qfile.open(IO_ReadOnly);
377 } 388 }
378 if ( ret ) { 389 if ( ret ) {
379 QTextStream t( &qfile ); 390 QTextStream t( &qfile );
380 QString s, line; 391 QString s, line;
381 parser.file = file; 392 parser.file = filename;
382 parser.line_no = 0; 393 parser.line_no = 0;
383 while ( !t.eof() ) { 394 while ( !t.eof() ) {
384 parser.line_no++; 395 parser.line_no++;
385 line = t.readLine().stripWhiteSpace(); 396 line = t.readLine().stripWhiteSpace();
386 int prelen = line.length(); 397 int prelen = line.length();
387 line.replace(QRegExp("#.*$"), ""); // bye comments 398 {
399 int hash_mark = line.find('#');
400 if(hash_mark != -1) //bye comments
401 line = line.left(hash_mark);
402 }
388 if(!line.isEmpty() && line.right(1) == "\\") { 403 if(!line.isEmpty() && line.right(1) == "\\") {
389 line.truncate(line.length() - 1); 404 line.truncate(line.length() - 1);
390 s += line + " "; 405 s += line + " ";
391 } else if(!line.isEmpty() || (line.isEmpty() && !prelen)) { 406 } else if(!line.isEmpty() || (line.isEmpty() && !prelen)) {
392 if(s.isEmpty() && line.isEmpty()) 407 if(s.isEmpty() && line.isEmpty())
393 continue; 408 continue;
394 if(!line.isEmpty()) 409 if(!line.isEmpty())
395 s += line; 410 s += line;
396 if(!s.isEmpty()) { 411 if(!s.isEmpty()) {
397 if(!(ret = parse(s, place))) 412 if(!(ret = parse(s, place)))
398 break; 413 break;
399 s = ""; 414 s = "";
400 } 415 }
401 } 416 }
402 } 417 }
403 if(!using_stdin) 418 if(!using_stdin)
404 qfile.close(); 419 qfile.close();
405 } 420 }
406 parser = pi; 421 parser = pi;
407 return ret; 422 return ret;
408} 423}
409 424
410bool 425bool
411QMakeProject::read(QString project, QString) 426QMakeProject::read(const QString &project, const QString &, bool just_project)
412{ 427{
428 if(just_project) { //nothing more, nothing less
429 pfile = project;
430 if(pfile != "-" && !QFile::exists(pfile) && pfile.right(4) != ".pro")
431 pfile += ".pro";
432 return read(pfile, vars);
433 }
434
413 if(cfile.isEmpty()) { 435 if(cfile.isEmpty()) {
414 // hack to get the Option stuff in there 436 // hack to get the Option stuff in there
415 base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext; 437 base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext;
416 base_vars["QMAKE_EXT_H"] = Option::h_ext; 438 base_vars["QMAKE_EXT_H"] = Option::h_ext;
439 if(!Option::user_template_prefix.isEmpty())
440 base_vars["TEMPLATE_PREFIX"] = Option::user_template_prefix;
417 441
418 /* parse the cache */ 442 /* parse the cache */
419 if(Option::mkfile::do_cache) { 443 if(Option::mkfile::do_cache) {
420 if(Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified 444 if(Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified
421 QString dir = QDir::convertSeparators(Option::output_dir); 445 QString dir = QDir::convertSeparators(Option::output_dir);
422 while(!QFile::exists((Option::mkfile::cachefile = dir + 446 while(!QFile::exists((Option::mkfile::cachefile = dir +
423 QDir::separator() + ".qmake.cache"))) { 447 QDir::separator() + ".qmake.cache"))) {
424 dir = dir.left(dir.findRev(QDir::separator())); 448 dir = dir.left(dir.findRev(QDir::separator()));
425 if(dir.isEmpty() || dir.find(QDir::separator()) == -1) { 449 if(dir.isEmpty() || dir.find(QDir::separator()) == -1) {
426 Option::mkfile::cachefile = ""; 450 Option::mkfile::cachefile = "";
427 break; 451 break;
428 } 452 }
429 if(Option::mkfile::cachefile_depth == -1) 453 if(Option::mkfile::cachefile_depth == -1)
430 Option::mkfile::cachefile_depth = 1; 454 Option::mkfile::cachefile_depth = 1;
431 else 455 else
432 Option::mkfile::cachefile_depth++; 456 Option::mkfile::cachefile_depth++;
433 } 457 }
434 } 458 }
435 if(!Option::mkfile::cachefile.isEmpty()) { 459 if(!Option::mkfile::cachefile.isEmpty()) {
436 read(Option::mkfile::cachefile, cache); 460 read(Option::mkfile::cachefile, cache);
437 if(Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty()) 461 if(Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty())
438 Option::mkfile::qmakespec = cache["QMAKESPEC"].first(); 462 Option::mkfile::qmakespec = cache["QMAKESPEC"].first();
439 } 463 }
440 } 464 }
441 /* parse mkspec */ 465 /* parse mkspec */
442 QStringList mkspec_roots; 466 QStringList mkspec_roots;
443 /* prefer $QTDIR if it is set */ 467 /* prefer $QTDIR if it is set */
444 /* prefer QMAKESPECSDIR -cl */ 468 if (getenv("QTDIR"))
445
446 if (getenv("QTDIR")) {
447 mkspec_roots << getenv("QTDIR"); 469 mkspec_roots << getenv("QTDIR");
448 }
449 mkspec_roots << qInstallPathData(); 470 mkspec_roots << qInstallPathData();
450
451 if (Option::mkfile::qmakespec.isEmpty() && getenv("QMAKESPECSDIR")){
452 QString mkspec = QString(getenv("QMAKESPECSDIR")) + QDir::separator() +
453 QDir::separator() + "default";
454 if(QFile::exists(mkspec))
455 Option::mkfile::qmakespec = mkspec;
456 }
457
458 if(Option::mkfile::qmakespec.isEmpty()) { 471 if(Option::mkfile::qmakespec.isEmpty()) {
459 for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) { 472 for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
460 QString mkspec = (*it) + QDir::separator() + QString("mkspecs") + 473 QString mkspec = (*it) + QDir::separator() + QString("mkspecs") +
461 QDir::separator() + "default"; 474 QDir::separator() + "default";
462 if(QFile::exists(mkspec)) { 475 if(QFile::exists(mkspec)) {
463 Option::mkfile::qmakespec = mkspec; 476 Option::mkfile::qmakespec = mkspec;
464 break; 477 break;
465 } 478 }
466 } 479 }
467 } 480 if(Option::mkfile::qmakespec.isEmpty()) {
468 481 fprintf(stderr, "QMAKESPEC has not been set, so configuration cannot be deduced.\n");
469 if(Option::mkfile::qmakespec.isEmpty()) { 482 return FALSE;
470 fprintf(stderr, "QMAKESPEC has not been set, so configuration cannot be deduced.\n"); 483 }
471 return FALSE;
472 } 484 }
473 485
474 if(QDir::isRelativePath(Option::mkfile::qmakespec)) { 486 if(QDir::isRelativePath(Option::mkfile::qmakespec)) {
475 bool found_mkspec = FALSE; 487 bool found_mkspec = FALSE;
476 for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) { 488 for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) {
477 QString mkspec = (*it) + QDir::separator() + QString("mkspecs") + 489 QString mkspec = (*it) + QDir::separator() + QString("mkspecs") +
478 QDir::separator() + Option::mkfile::qmakespec; 490 QDir::separator() + Option::mkfile::qmakespec;
479 if(QFile::exists(mkspec)) { 491 if(QFile::exists(mkspec)) {
480 found_mkspec = TRUE; 492 found_mkspec = TRUE;
481 Option::mkfile::qmakespec = mkspec; 493 Option::mkfile::qmakespec = mkspec;
482 break; 494 break;
483 } 495 }
484 } 496 }
485 if(!found_mkspec) { 497 if(!found_mkspec) {
486 fprintf(stderr, "Could not find mkspecs for your QMAKESPEC after trying:\n\t%s\n", 498 fprintf(stderr, "Could not find mkspecs for your QMAKESPEC after trying:\n\t%s\n",
487 mkspec_roots.join("\n\t").latin1()); 499 mkspec_roots.join("\n\t").latin1());
488 return FALSE; 500 return FALSE;
489 } 501 }
490 } 502 }
491 503
492 /* parse qmake configuration */ 504 /* parse qmake configuration */
493 QString spec = Option::mkfile::qmakespec + QDir::separator() + "qmake.conf"; 505 QString spec = Option::mkfile::qmakespec + QDir::separator() + "qmake.conf";
494 debug_msg(1, "QMAKESPEC conf: reading %s", spec.latin1()); 506 debug_msg(1, "QMAKESPEC conf: reading %s", spec.latin1());
495 if(!read(spec, base_vars)) { 507 if(!read(spec, base_vars)) {
@@ -523,196 +535,209 @@ QMakeProject::read(QString project, QString)
523 if(pfile != "-" && !QFile::exists(pfile) && pfile.right(4) != ".pro") 535 if(pfile != "-" && !QFile::exists(pfile) && pfile.right(4) != ".pro")
524 pfile += ".pro"; 536 pfile += ".pro";
525 537
526 if(!read(pfile, vars)) 538 if(!read(pfile, vars))
527 return FALSE; 539 return FALSE;
528 540
529 parser.line_no = 1; //really arg count now.. duh 541 parser.line_no = 1; //really arg count now.. duh
530 parser.file = "(internal)"; 542 parser.file = "(internal)";
531 for(QStringList::Iterator it = Option::after_user_vars.begin(); 543 for(QStringList::Iterator it = Option::after_user_vars.begin();
532 it != Option::after_user_vars.end(); ++it) { 544 it != Option::after_user_vars.end(); ++it) {
533 if(!parse((*it), vars)) { 545 if(!parse((*it), vars)) {
534 fprintf(stderr, "Argument failed to parse: %s\n", (*it).latin1()); 546 fprintf(stderr, "Argument failed to parse: %s\n", (*it).latin1());
535 return FALSE; 547 return FALSE;
536 } 548 }
537 parser.line_no++; 549 parser.line_no++;
538 } 550 }
539 551
540 /* now let the user override the template from an option.. */ 552 /* now let the user override the template from an option.. */
541 if(!Option::user_template.isEmpty()) { 553 if(!Option::user_template.isEmpty()) {
542 debug_msg(1, "Overriding TEMPLATE (%s) with: %s", vars["TEMPLATE"].first().latin1(), Option::user_template.latin1()); 554 debug_msg(1, "Overriding TEMPLATE (%s) with: %s", vars["TEMPLATE"].first().latin1(), Option::user_template.latin1());
543 vars["TEMPLATE"].clear(); 555 vars["TEMPLATE"].clear();
544 vars["TEMPLATE"].append(Option::user_template); 556 vars["TEMPLATE"].append(Option::user_template);
545 } 557 }
546 558
547 if(vars["TEMPLATE"].isEmpty()) 559 QStringList &templ = vars["TEMPLATE"];
548 vars["TEMPLATE"].append(QString("app")); 560 if(templ.isEmpty())
549 else 561 templ.append(QString("app"));
550 vars["TEMPLATE"].first().replace(QRegExp("\\.t$"), ""); 562 else if(vars["TEMPLATE"].first().endsWith(".t"))
551 if(!Option::user_template_prefix.isEmpty()) 563 templ = QStringList(templ.first().left(templ.first().length() - 2));
552 vars["TEMPLATE"].first().prepend(Option::user_template_prefix); 564 if ( !Option::user_template_prefix.isEmpty() ) {
565 templ.first().prepend(Option::user_template_prefix);
566 }
553 567
554 if(vars["TARGET"].isEmpty()) { 568 if(vars["TARGET"].isEmpty()) {
555 // ### why not simply use: 569 // ### why not simply use:
556 // QFileInfo fi(pfile); 570 // QFileInfo fi(pfile);
557 // fi.baseName(); 571 // fi.baseName();
558 QString tmp = pfile; 572 QString tmp = pfile;
559 if(tmp.findRev('/') != -1) 573 if(tmp.findRev('/') != -1)
560 tmp = tmp.right( tmp.length() - tmp.findRev('/') - 1 ); 574 tmp = tmp.right( tmp.length() - tmp.findRev('/') - 1 );
561 if(tmp.findRev('.') != -1) 575 if(tmp.findRev('.') != -1)
562 tmp = tmp.left(tmp.findRev('.')); 576 tmp = tmp.left(tmp.findRev('.'));
563 vars["TARGET"].append(tmp); 577 vars["TARGET"].append(tmp);
564 } 578 }
565 579
566 QString test_version = getenv("QTESTVERSION"); 580 QString test_version = getenv("QTESTVERSION");
567 if (!test_version.isEmpty()) { 581 if (!test_version.isEmpty()) {
568 QString s = vars["TARGET"].first(); 582 QString s = vars["TARGET"].first();
569 if (s == "qt" || s == "qt-mt" || s == "qte" || s == "qte-mt") { 583 if (s == "qt" || s == "qt-mt" || s == "qte" || s == "qte-mt") {
570 QString &ver = vars["VERSION"].first(); 584 QString &ver = vars["VERSION"].first();
571 // fprintf(stderr,"Current QT version number: " + ver + "\n"); 585 // fprintf(stderr,"Current QT version number: " + ver + "\n");
572 if (ver != "" && ver != test_version) { 586 if (ver != "" && ver != test_version) {
573 ver = test_version; 587 ver = test_version;
574 fprintf(stderr,"Changed QT version number to " + test_version + "!\n"); 588 fprintf(stderr,"Changed QT version number to " + test_version + "!\n");
575 } 589 }
576 } 590 }
577 } 591 }
578 return TRUE; 592 return TRUE;
579} 593}
580 594
581bool 595bool
582QMakeProject::isActiveConfig(const QString &x) 596QMakeProject::isActiveConfig(const QString &x, bool regex)
583{ 597{
584 if(x.isEmpty()) 598 if(x.isEmpty())
585 return TRUE; 599 return TRUE;
586 600
587 QRegExp re(x, FALSE, TRUE); 601 if((Option::target_mode == Option::TARG_MACX_MODE || Option::target_mode == Option::TARG_QNX6_MODE ||
588 if((Option::target_mode == Option::TARG_MACX_MODE || Option::target_mode == Option::TARG_QNX6_MODE || Option::target_mode == Option::TARG_UNIX_MODE) && 602 Option::target_mode == Option::TARG_UNIX_MODE) && x == "unix")
589 x == "unix")
590 return TRUE; 603 return TRUE;
591 else if(Option::target_mode == Option::TARG_MACX_MODE && x == "macx") 604 else if(Option::target_mode == Option::TARG_MACX_MODE && x == "macx")
592 return TRUE; 605 return TRUE;
593 else if(Option::target_mode == Option::TARG_QNX6_MODE && x == "qnx6") 606 else if(Option::target_mode == Option::TARG_QNX6_MODE && x == "qnx6")
594 return TRUE; 607 return TRUE;
595 else if(Option::target_mode == Option::TARG_MAC9_MODE && x == "mac9") 608 else if(Option::target_mode == Option::TARG_MAC9_MODE && x == "mac9")
596 return TRUE; 609 return TRUE;
597 else if((Option::target_mode == Option::TARG_MAC9_MODE || Option::target_mode == Option::TARG_MACX_MODE) && 610 else if((Option::target_mode == Option::TARG_MAC9_MODE || Option::target_mode == Option::TARG_MACX_MODE) &&
598 x == "mac") 611 x == "mac")
599 return TRUE; 612 return TRUE;
600 else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32") 613 else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32")
601 return TRUE; 614 return TRUE;
602 615
603 616
617 QRegExp re(x, FALSE, TRUE);
604 QString spec = Option::mkfile::qmakespec.right(Option::mkfile::qmakespec.length() - 618 QString spec = Option::mkfile::qmakespec.right(Option::mkfile::qmakespec.length() -
605 (Option::mkfile::qmakespec.findRev(QDir::separator())+1)); 619 (Option::mkfile::qmakespec.findRev(QDir::separator())+1));
606 if(re.exactMatch(spec)) 620 if((regex && re.exactMatch(spec)) || (!regex && spec == x))
607 return TRUE; 621 return TRUE;
608#ifdef Q_OS_UNIX 622#ifdef Q_OS_UNIX
609 else if(spec == "default") { 623 else if(spec == "default") {
610 static char *buffer = NULL; 624 static char *buffer = NULL;
611 if(!buffer) 625 if(!buffer)
612 buffer = (char *)malloc(1024); 626 buffer = (char *)malloc(1024);
613 int l = readlink(Option::mkfile::qmakespec, buffer, 1024); 627 int l = readlink(Option::mkfile::qmakespec, buffer, 1024);
614 if(l != -1) { 628 if(l != -1) {
615 buffer[l] = '\0'; 629 buffer[l] = '\0';
616 QString r = buffer; 630 QString r = buffer;
617 if(r.findRev('/') != -1) 631 if(r.findRev('/') != -1)
618 r = r.mid(r.findRev('/') + 1); 632 r = r.mid(r.findRev('/') + 1);
619 if(re.exactMatch(r)) 633 if((regex && re.exactMatch(r)) || (!regex && r == x))
620 return TRUE; 634 return TRUE;
621 } 635 }
622 } 636 }
623#endif 637#endif
624 638
625 639
626 QStringList &configs = vars["CONFIG"]; 640 QStringList &configs = vars["CONFIG"];
627 for(QStringList::Iterator it = configs.begin(); it != configs.end(); ++it) { 641 for(QStringList::Iterator it = configs.begin(); it != configs.end(); ++it) {
642 if((regex && re.exactMatch((*it))) || (!regex && (*it) == x))
628 if(re.exactMatch((*it))) 643 if(re.exactMatch((*it)))
629 return TRUE; 644 return TRUE;
630 } 645 }
631 return FALSE; 646 return FALSE;
632} 647}
633 648
634bool 649bool
635QMakeProject::doProjectTest(QString func, const QString &params, QMap<QString, QStringList> &place) 650QMakeProject::doProjectTest(const QString& func, const QString &params, QMap<QString, QStringList> &place)
636{ 651{
637 QStringList args = split_arg_list(params); 652 QStringList args = split_arg_list(params);
638 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { 653 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) {
639 QString tmp = (*arit).stripWhiteSpace(); 654 QString tmp = (*arit).stripWhiteSpace();
640 if((tmp[0] == '\'' || tmp[0] == '"') && tmp.right(1) == tmp.left(1)) 655 if((tmp[0] == '\'' || tmp[0] == '"') && tmp.right(1) == tmp.left(1))
641 tmp = tmp.mid(1, tmp.length() - 2); 656 tmp = tmp.mid(1, tmp.length() - 2);
642 } 657 }
643 return doProjectTest(func.stripWhiteSpace(), args, place); 658 return doProjectTest(func.stripWhiteSpace(), args, place);
644} 659}
645 660
646bool 661bool
647QMakeProject::doProjectTest(QString func, QStringList args, QMap<QString, QStringList> &place) 662QMakeProject::doProjectTest(const QString& func, QStringList args, QMap<QString, QStringList> &place)
648{ 663{
649 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { 664 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) {
650 (*arit) = (*arit).stripWhiteSpace(); // blah, get rid of space 665 (*arit) = (*arit).stripWhiteSpace(); // blah, get rid of space
651 doVariableReplace((*arit), place); 666 doVariableReplace((*arit), place);
652 } 667 }
653 debug_msg(1, "Running project test: %s( %s )", func.latin1(), args.join("::").latin1()); 668 debug_msg(1, "Running project test: %s( %s )", func.latin1(), args.join("::").latin1());
654 669
655 if(func == "requires") { 670 if(func == "requires") {
656 return doProjectCheckReqs(args, place); 671 return doProjectCheckReqs(args, place);
672 } else if(func == "equals") {
673 if(args.count() != 2) {
674 fprintf(stderr, "%s:%d: equals(variable, value) requires two arguments.\n", parser.file.latin1(),
675 parser.line_no);
676 return FALSE;
677 }
678 QString value = args[1];
679 if((value.left(1) == "\"" || value.left(1) == "'") && value.right(1) == value.left(1))
680 value = value.mid(1, value.length()-2);
681 return vars[args[0]].join(" ") == value;
657 } else if(func == "exists") { 682 } else if(func == "exists") {
658 if(args.count() != 1) { 683 if(args.count() != 1) {
659 fprintf(stderr, "%s:%d: exists(file) requires one argument.\n", parser.file.latin1(), 684 fprintf(stderr, "%s:%d: exists(file) requires one argument.\n", parser.file.latin1(),
660 parser.line_no); 685 parser.line_no);
661 return FALSE; 686 return FALSE;
662 } 687 }
663 QString file = args.first(); 688 QString file = args.first();
664 file = Option::fixPathToLocalOS(file); 689 file = Option::fixPathToLocalOS(file);
665 doVariableReplace(file, place); 690 doVariableReplace(file, place);
666 691
667 if(QFile::exists(file)) 692 if(QFile::exists(file))
668 return TRUE; 693 return TRUE;
669 //regular expression I guess 694 //regular expression I guess
670 QString dirstr = QDir::currentDirPath(); 695 QString dirstr = QDir::currentDirPath();
671 int slsh = file.findRev(Option::dir_sep); 696 int slsh = file.findRev(Option::dir_sep);
672 if(slsh != -1) { 697 if(slsh != -1) {
673 dirstr = file.left(slsh+1); 698 dirstr = file.left(slsh+1);
674 file = file.right(file.length() - slsh - 1); 699 file = file.right(file.length() - slsh - 1);
675 } 700 }
676 QDir dir(dirstr, file); 701 QDir dir(dirstr, file);
677 return dir.count() != 0; 702 return dir.count() != 0;
678 } else if(func == "system") { 703 } else if(func == "system") {
679 if(args.count() != 1) { 704 if(args.count() != 1) {
680 fprintf(stderr, "%s:%d: system(exec) requires one argument.\n", parser.file.latin1(), 705 fprintf(stderr, "%s:%d: system(exec) requires one argument.\n", parser.file.latin1(),
681 parser.line_no); 706 parser.line_no);
682 return FALSE; 707 return FALSE;
683 } 708 }
684 return system(args.first().latin1()) == 0; 709 return system(args.first().latin1()) == 0;
685 } else if(func == "contains") { 710 } else if(func == "contains") {
686 if(args.count() != 2) { 711 if(args.count() != 2) {
687 fprintf(stderr, "%s:%d: contains(var, val) requires two arguments.\n", parser.file.latin1(), 712 fprintf(stderr, "%s:%d: contains(var, val) requires two arguments.\n", parser.file.latin1(),
688 parser.line_no); 713 parser.line_no);
689 return FALSE; 714 return FALSE;
690 } 715 }
691 QRegExp regx(args[1]); 716 QRegExp regx(args[1]);
692 QStringList &l = place[args[0]]; 717 QStringList &l = place[args[0]];
693 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { 718 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
694 if(regx.exactMatch((*it))) 719 if(regx.exactMatch((*it)))
695 return TRUE; 720 return TRUE;
696 } 721 }
697 return FALSE; 722 return FALSE;
698 } else if(func == "infile") { 723 } else if(func == "infile") {
699 if(args.count() < 2 || args.count() > 3) { 724 if(args.count() < 2 || args.count() > 3) {
700 fprintf(stderr, "%s:%d: infile(file, var, val) requires at least 2 arguments.\n", 725 fprintf(stderr, "%s:%d: infile(file, var, val) requires at least 2 arguments.\n",
701 parser.file.latin1(), parser.line_no); 726 parser.file.latin1(), parser.line_no);
702 return FALSE; 727 return FALSE;
703 } 728 }
704 QMakeProject proj; 729 QMakeProject proj;
705 QString file = args[0]; 730 QString file = args[0];
706 doVariableReplace(file, place); 731 doVariableReplace(file, place);
707 fixEnvVariables(file); 732 fixEnvVariables(file);
708 int di = file.findRev(Option::dir_sep); 733 int di = file.findRev(Option::dir_sep);
709 QDir sunworkshop42workaround = QDir::current(); 734 QDir sunworkshop42workaround = QDir::current();
710 QString oldpwd = sunworkshop42workaround.currentDirPath(); 735 QString oldpwd = sunworkshop42workaround.currentDirPath();
711 if(di != -1) { 736 if(di != -1) {
712 if(!QDir::setCurrent(file.left(file.findRev(Option::dir_sep)))) { 737 if(!QDir::setCurrent(file.left(file.findRev(Option::dir_sep)))) {
713 fprintf(stderr, "Cannot find directory: %s\n", file.left(di).latin1()); 738 fprintf(stderr, "Cannot find directory: %s\n", file.left(di).latin1());
714 return FALSE; 739 return FALSE;
715 } 740 }
716 file = file.right(file.length() - di - 1); 741 file = file.right(file.length() - di - 1);
717 } 742 }
718 parser_info pi = parser; 743 parser_info pi = parser;
@@ -784,211 +809,269 @@ QMakeProject::doProjectTest(QString func, QStringList args, QMap<QString, QStrin
784#endif 809#endif
785 for(QStringList::Iterator it = feature_roots.begin(); it != feature_roots.end(); ++it) { 810 for(QStringList::Iterator it = feature_roots.begin(); it != feature_roots.end(); ++it) {
786 QString prf = (*it) + QDir::separator() + QString("mkspecs") + 811 QString prf = (*it) + QDir::separator() + QString("mkspecs") +
787 QDir::separator() + QString("features") + QDir::separator() + file; 812 QDir::separator() + QString("features") + QDir::separator() + file;
788 if(QFile::exists(prf)) { 813 if(QFile::exists(prf)) {
789 found = TRUE; 814 found = TRUE;
790 file = prf; 815 file = prf;
791 break; 816 break;
792 } 817 }
793 } 818 }
794 if(!found) { 819 if(!found) {
795 printf("Project LOAD(): Feature %s cannot be found.\n", args.first().latin1()); 820 printf("Project LOAD(): Feature %s cannot be found.\n", args.first().latin1());
796 exit(3); 821 exit(3);
797 } 822 }
798 } 823 }
799 } 824 }
800 } 825 }
801 826
802 debug_msg(1, "Project Parser: %s'ing file %s.", func.latin1(), file.latin1()); 827 debug_msg(1, "Project Parser: %s'ing file %s.", func.latin1(), file.latin1());
803 parser_info pi = parser; 828 parser_info pi = parser;
804 int sb = scope_block; 829 int sb = scope_block;
805 int sf = scope_flag; 830 int sf = scope_flag;
806 TestStatus sc = test_status; 831 TestStatus sc = test_status;
807 bool r = read(file.latin1(), place); 832 bool r = read(file.latin1(), place);
808 if(r) 833 if(r)
809 vars["QMAKE_INTERNAL_INCLUDED_FILES"].append(file); 834 vars["QMAKE_INTERNAL_INCLUDED_FILES"].append(file);
835 else
836 warn_msg(WarnParser, "%s:%d: Failure to include file %s.",
837 pi.file.latin1(), pi.line_no, file.latin1());
810 parser = pi; 838 parser = pi;
811 test_status = sc; 839 test_status = sc;
812 scope_flag = sf; 840 scope_flag = sf;
813 scope_block = sb; 841 scope_block = sb;
814 return r; 842 return r;
815 } else if(func == "error" || func == "message") { 843 } else if(func == "error" || func == "message") {
816 if(args.count() != 1) { 844 if(args.count() != 1) {
817 fprintf(stderr, "%s:%d: %s(message) requires one argument.\n", parser.file.latin1(), 845 fprintf(stderr, "%s:%d: %s(message) requires one argument.\n", parser.file.latin1(),
818 parser.line_no, func.latin1()); 846 parser.line_no, func.latin1());
819 return FALSE; 847 return FALSE;
820 } 848 }
821 QString msg = args.first(); 849 QString msg = args.first();
850 if((msg.startsWith("\"") || msg.startsWith("'")) && msg.endsWith(msg.left(1)))
851 msg = msg.mid(1, msg.length()-2);
852 msg.replace(QString("${QMAKE_FILE}"), parser.file.latin1());
853 msg.replace(QString("${QMAKE_LINE_NUMBER}"), QString::number(parser.line_no));
854 msg.replace(QString("${QMAKE_DATE}"), QDateTime::currentDateTime().toString());
822 doVariableReplace(msg, place); 855 doVariableReplace(msg, place);
823 fixEnvVariables(msg); 856 fixEnvVariables(msg);
824 printf("Project %s: %s\n", func.upper().latin1(), msg.latin1()); 857 printf("Project %s: %s\n", func.upper().latin1(), msg.latin1());
825 if(func == "message") 858 if(func == "message")
826 return TRUE; 859 return TRUE;
827 exit(2); 860 exit(2);
828 } else { 861 } else {
829 fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.latin1(), parser.line_no, 862 fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.latin1(), parser.line_no,
830 func.latin1()); 863 func.latin1());
831 } 864 }
832 return FALSE; 865 return FALSE;
833} 866}
834 867
835bool 868bool
836QMakeProject::doProjectCheckReqs(const QStringList &deps, QMap<QString, QStringList> &place) 869QMakeProject::doProjectCheckReqs(const QStringList &deps, QMap<QString, QStringList> &place)
837{ 870{
838 bool ret = FALSE; 871 bool ret = FALSE;
839 for(QStringList::ConstIterator it = deps.begin(); it != deps.end(); ++it) { 872 for(QStringList::ConstIterator it = deps.begin(); it != deps.end(); ++it) {
840 QString chk = (*it); 873 QString chk = (*it);
841 if(chk.isEmpty()) 874 if(chk.isEmpty())
842 continue; 875 continue;
843 bool invert_test = (chk.left(1) == "!"); 876 bool invert_test = (chk.left(1) == "!");
844 if(invert_test) 877 if(invert_test)
845 chk = chk.right(chk.length() - 1); 878 chk = chk.right(chk.length() - 1);
846 879
847 bool test; 880 bool test;
848 int lparen = chk.find('('); 881 int lparen = chk.find('(');
849 if(lparen != -1) { /* if there is an lparen in the chk, it IS a function */ 882 if(lparen != -1) { /* if there is an lparen in the chk, it IS a function */
850 int rparen = chk.findRev(')'); 883 int rparen = chk.findRev(')');
851 if(rparen == -1) { 884 if(rparen == -1) {
852 QCString error; 885 QCString error;
853 error.sprintf("Function (in REQUIRES) missing right paren: %s", chk.latin1()); 886 error.sprintf("Function (in REQUIRES) missing right paren: %s", chk.latin1());
854 qmake_error_msg(error); 887 qmake_error_msg(error);
855 } else { 888 } else {
856 QString func = chk.left(lparen); 889 QString func = chk.left(lparen);
857 test = doProjectTest(func, chk.mid(lparen+1, rparen - lparen - 1), place); 890 test = doProjectTest(func, chk.mid(lparen+1, rparen - lparen - 1), place);
858 } 891 }
859 } else { 892 } else {
860 test = isActiveConfig(chk); 893 test = isActiveConfig(chk, TRUE);
861 } 894 }
862 if(invert_test) { 895 if(invert_test) {
863 chk.prepend("!"); 896 chk.prepend("!");
864 test = !test; 897 test = !test;
865 } 898 }
866 if(!test) { 899 if(!test) {
867 debug_msg(1, "Project Parser: %s:%d Failed test: REQUIRES = %s", 900 debug_msg(1, "Project Parser: %s:%d Failed test: REQUIRES = %s",
868 parser.file.latin1(), parser.line_no, chk.latin1()); 901 parser.file.latin1(), parser.line_no, chk.latin1());
869 place["QMAKE_FAILED_REQUIREMENTS"].append(chk); 902 place["QMAKE_FAILED_REQUIREMENTS"].append(chk);
870 ret = FALSE; 903 ret = FALSE;
871 } 904 }
872 } 905 }
873 return ret; 906 return ret;
874} 907}
875 908
876 909
877QString 910QString
878QMakeProject::doVariableReplace(QString &str, const QMap<QString, QStringList> &place) 911QMakeProject::doVariableReplace(QString &str, const QMap<QString, QStringList> &place)
879{ 912{
880 for(int x = 0, rep; x < 5; x++) { 913 for(int var_begin, var_last=0; (var_begin = str.find("$$", var_last)) != -1; var_last = var_begin) {
881 QRegExp reg_var; 914 if(var_begin >= int( str.length() + 2 ) ) {
882 reg_var.setMinimal(TRUE); 915 break;
883 if( x == 0 ) //function blocked out by {}'s 916 } else if(var_begin != 0 && str[var_begin-1] == '\\') {
884 reg_var = QRegExp("\\$\\$\\{([a-zA-Z0-9_]*)\\((\\(.|(.*)\\)*)\\)\\}"); 917 str.replace(var_begin-1, 1, "");
885 else if( x == 1 ) //variables blocked out by {}'s 918 var_begin += 1;
886 reg_var = QRegExp("\\$\\$\\{([a-zA-Z0-9_\\.-]*)\\}"); 919 continue;
887 else if(x == 2) //environment 920 }
888 reg_var = QRegExp("\\$\\$\\(([a-zA-Z0-9_\\.-]*)\\)"); 921
889 else if(x == 3) //function 922 int var_incr = var_begin + 2;
890 reg_var = QRegExp("\\$\\$([a-zA-Z0-9_]*)\\((\\(.|(.*)\\)*)\\)"); 923 bool in_braces = FALSE, as_env = FALSE;
891 else if(x == 4) //normal variable 924 if(str[var_incr] == '{') {
892 reg_var = QRegExp("\\$\\$([a-zA-Z0-9_\\.-]*)"); 925 in_braces = TRUE;
893 while((rep = reg_var.search(str)) != -1) { 926 var_incr++;
894 QString replacement; 927 while(var_incr < int( str.length() ) &&
895 if(x == 2) {//environment 928 (str[var_incr] == ' ' || str[var_incr] == '\t' || str[var_incr] == '\n'))
896 replacement = getenv(reg_var.cap(1)); 929 var_incr++;
897 } else if(x == 0 || x == 3) { //function 930 }
898 QStringList args = split_arg_list(reg_var.cap(2)); 931 if(str[var_incr] == '(') {
899 for(QStringList::Iterator arit = args.begin(); arit != args.end(); ++arit) { 932 as_env = TRUE;
900 (*arit) = (*arit).stripWhiteSpace(); // blah, get rid of space 933 var_incr++;
901 doVariableReplace((*arit), place); 934 }
902 } 935 QString val, args;
903 debug_msg(1, "Running function: %s( %s )", reg_var.cap(1).latin1(), args.join("::").latin1()); 936 while(var_incr < int( str.length() ) &&
904 if(reg_var.cap(1).lower() == "member") { 937 (str[var_incr].isLetter() || str[var_incr].isNumber() || str[var_incr] == '.' || str[var_incr] == '_'))
905 if(args.count() < 1 || args.count() > 2) { 938 val += str[var_incr++];
906 fprintf(stderr, "%s:%d: member(var, place) requires two arguments.\n", 939 if(as_env) {
907 parser.file.latin1(), parser.line_no); 940 if(str[var_incr] != ')') {
908 } else { 941 var_incr++;
909 uint pos = 0; 942 warn_msg(WarnParser, "%s:%d: Unterminated env-variable replacement '%s' (%s)",
910 if(args.count() == 2) 943 parser.file.latin1(), parser.line_no,
911 pos = args[1].toInt(); 944 str.mid(var_begin, QMAX(var_incr - var_begin, int(str.length()))).latin1(), str.latin1());
912 const QStringList &var = place[varMap(args.first())]; 945 var_begin += var_incr;
913 if(var.count() >= pos) 946 continue;
914 replacement = var[pos]; 947 }
915 } 948 var_incr++;
916 } else if(reg_var.cap(1).lower() == "list") { 949 } else if(str[var_incr] == '(') { //args
917 if(args.count() != 1) { 950 for(int parens = 0; var_incr < int( str.length() ); var_incr++) {
918 fprintf(stderr, "%s:%d: list(vals) requires one" 951 if(str[var_incr] == '(') {
919 "argument.\n", parser.file.latin1(), parser.line_no); 952 parens++;
920 } else { 953 if(parens == 1)
921 static int x = 0; 954 continue;
922 replacement.sprintf(".QMAKE_INTERNAL_TMP_VAR_%d", x++); 955 } else if(str[var_incr] == ')') {
923 (*((QMap<QString, QStringList>*)&place))[replacement] = split_value_list(args.first()); 956 parens--;
924 } 957 if(!parens) {
925 } else if(reg_var.cap(1).lower() == "join") { 958 var_incr++;
926 if(args.count() < 1 || args.count() > 4) { 959 break;
927 fprintf(stderr, "%s:%d: join(var, glue, before, after) requires four"
928 "arguments.\n", parser.file.latin1(), parser.line_no);
929 } else {
930 QString glue, before, after;
931 if(args.count() >= 2)
932 glue = args[1].replace("\"", "" );
933 if(args.count() >= 3)
934 before = args[2].replace("\"", "" );
935 if(args.count() == 4)
936 after = args[3].replace("\"", "" );
937 const QStringList &var = place[varMap(args.first())];
938 if(!var.isEmpty())
939 replacement = before + var.join(glue) + after;
940 } 960 }
941 } else if(reg_var.cap(1).lower() == "find") { 961 }
942 if(args.count() != 2) { 962 args += str[var_incr];
943 fprintf(stderr, "%s:%d find(var, str) requires two arguments\n", 963 }
944 parser.file.latin1(), parser.line_no); 964 }
945 } else { 965 if(var_incr > int( str.length() ) || (in_braces && str[var_incr] != '}')) {
946 QRegExp regx(args[1]); 966 var_incr++;
947 const QStringList &var = place[varMap(args.first())]; 967 warn_msg(WarnParser, "%s:%d: Unterminated variable replacement '%s' (%s)",
948 for(QStringList::ConstIterator vit = var.begin(); 968 parser.file.latin1(), parser.line_no,
949 vit != var.end(); ++vit) { 969 str.mid(var_begin, QMAX(var_incr - var_begin, int( str.length() ))).latin1(), str.latin1());
950 if(regx.search(*vit) != -1) { 970 var_begin += var_incr;
951 if(!replacement.isEmpty()) 971 continue;
952 replacement += " "; 972 } else if(in_braces) {
953 replacement += (*vit); 973 var_incr++;
954 } 974 }
975
976 QString replacement;
977 if(as_env) {
978 replacement = getenv(val);
979 } else if(args.isEmpty()) {
980 if(val.left(1) == ".")
981 replacement = "";
982 else if(val == "LITERAL_WHITESPACE")
983 replacement = "\t";
984 else
985 replacement = place[varMap(val)].join(" ");
986 } else {
987 QStringList arg_list = split_arg_list(args);
988 for(QStringList::Iterator arit = arg_list.begin(); arit != arg_list.end(); ++arit) {
989 (*arit) = (*arit).stripWhiteSpace(); // blah, get rid of space
990 doVariableReplace((*arit), place);
991 }
992 debug_msg(1, "Running function: %s( %s )", val.latin1(), arg_list.join("::").latin1());
993 if(val.lower() == "member") {
994 if(arg_list.count() < 1 || arg_list.count() > 2) {
995 fprintf(stderr, "%s:%d: member(var, place) requires two arguments.\n",
996 parser.file.latin1(), parser.line_no);
997 } else {
998 uint pos = 0;
999 if(arg_list.count() == 2)
1000 pos = arg_list[1].toInt();
1001 const QStringList &var = place[varMap(arg_list.first())];
1002 if(var.count() >= pos)
1003 replacement = var[pos];
1004 }
1005 } else if(val.lower() == "list") {
1006 static int x = 0;
1007 replacement.sprintf(".QMAKE_INTERNAL_TMP_VAR_%d", x++);
1008 QStringList &lst = (*((QMap<QString, QStringList>*)&place))[replacement];
1009 lst.clear();
1010 for(QStringList::ConstIterator arg_it = arg_list.begin();
1011 arg_it != arg_list.end(); ++arg_it)
1012 lst += split_value_list((*arg_it));
1013 } else if(val.lower() == "join") {
1014 if(arg_list.count() < 1 || arg_list.count() > 4) {
1015 fprintf(stderr, "%s:%d: join(var, glue, before, after) requires four"
1016 "arguments.\n", parser.file.latin1(), parser.line_no);
1017 } else {
1018 QString glue, before, after;
1019 if(arg_list.count() >= 2)
1020 glue = arg_list[1].replace("\"", "" );
1021 if(arg_list.count() >= 3)
1022 before = arg_list[2].replace("\"", "" );
1023 if(arg_list.count() == 4)
1024 after = arg_list[3].replace("\"", "" );
1025 const QStringList &var = place[varMap(arg_list.first())];
1026 if(!var.isEmpty())
1027 replacement = before + var.join(glue) + after;
1028 }
1029 } else if(val.lower() == "find") {
1030 if(arg_list.count() != 2) {
1031 fprintf(stderr, "%s:%d find(var, str) requires two arguments\n",
1032 parser.file.latin1(), parser.line_no);
1033 } else {
1034 QRegExp regx(arg_list[1]);
1035 const QStringList &var = place[varMap(arg_list.first())];
1036 for(QStringList::ConstIterator vit = var.begin();
1037 vit != var.end(); ++vit) {
1038 if(regx.search(*vit) != -1) {
1039 if(!replacement.isEmpty())
1040 replacement += " ";
1041 replacement += (*vit);
955 } 1042 }
956 } 1043 }
957 } else if(reg_var.cap(1).lower() == "system") { 1044 }
958 if(args.count() != 1) { 1045 } else if(val.lower() == "system") {
959 fprintf(stderr, "%s:%d system(execut) requires one argument\n", 1046 if(arg_list.count() != 1) {
960 parser.file.latin1(), parser.line_no); 1047 fprintf(stderr, "%s:%d system(execut) requires one argument\n",
961 } else { 1048 parser.file.latin1(), parser.line_no);
962 char buff[256]; 1049 } else {
963 FILE *proc = QT_POPEN(args.join(" ").latin1(), "r"); 1050 char buff[256];
964 while(proc && !feof(proc)) { 1051 FILE *proc = QT_POPEN(arg_list.join(" ").latin1(), "r");
965 int read_in = fread(buff, 1, 255, proc); 1052 while(proc && !feof(proc)) {
966 if(!read_in) 1053 int read_in = fread(buff, 1, 255, proc);
967 break; 1054 if(!read_in)
968 for(int i = 0; i < read_in; i++) { 1055 break;
969 if(buff[i] == '\n' || buff[i] == '\t') 1056 for(int i = 0; i < read_in; i++) {
970 buff[i] = ' '; 1057 if(buff[i] == '\n' || buff[i] == '\t')
971 } 1058 buff[i] = ' ';
972 buff[read_in] = '\0';
973 replacement += buff;
974 } 1059 }
1060 buff[read_in] = '\0';
1061 replacement += buff;
975 } 1062 }
976 } else {
977 fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
978 parser.file.latin1(), parser.line_no, reg_var.cap(1).latin1());
979 } 1063 }
980 } else { //variable 1064 } else {
981 if(reg_var.cap(1).left(1) == ".") 1065 fprintf(stderr, "%s:%d: Unknown replace function: %s\n",
982 replacement = ""; 1066 parser.file.latin1(), parser.line_no, val.latin1());
983 else if(reg_var.cap(1) == "LITERAL_WHITESPACE")
984 replacement = "\t";
985 else
986 replacement = place[varMap(reg_var.cap(1))].join(" ");
987 } 1067 }
988 debug_msg(2, "Project parser: %d (%s) :: %s -> %s", x, str.latin1(),
989 reg_var.capturedTexts().join("::").latin1(), replacement.latin1());
990 str.replace(rep, reg_var.matchedLength(), replacement);
991 } 1068 }
1069 //actually do replacement now..
1070 int mlen = var_incr - var_begin;
1071 debug_msg(2, "Project Parser [var replace]: '%s' :: %s -> %s", str.latin1(),
1072 str.mid(var_begin, mlen).latin1(), replacement.latin1());
1073 str.replace(var_begin, mlen, replacement);
1074 var_begin += replacement.length();
992 } 1075 }
993 return str; 1076 return str;
994} 1077}
diff --git a/qmake/project.h b/qmake/project.h
index 201e63c..ec19f0c 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -1,114 +1,114 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of ________ class. 4** Definition of ________ class.
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this 21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided 22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software. 23** with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#ifndef __QMAKE_H__ 37#ifndef __PROJECT_H__
38#define __QMAKE_H__ 38#define __PROJECT_H__
39 39
40#include <qstringlist.h> 40#include <qstringlist.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qmap.h> 42#include <qmap.h>
43 43
44class QMakeProject 44class QMakeProject
45{ 45{
46 enum TestStatus { TestNone, TestFound, TestSeek } test_status; 46 enum TestStatus { TestNone, TestFound, TestSeek } test_status;
47 int scope_block, scope_flag; 47 int scope_block, scope_flag;
48 48
49 QString pfile, cfile; 49 QString pfile, cfile;
50 QMap<QString, QStringList> vars, base_vars, cache; 50 QMap<QString, QStringList> vars, base_vars, cache;
51 bool parse(QString text, QMap<QString, QStringList> &place); 51 bool parse(const QString &text, QMap<QString, QStringList> &place);
52 bool doProjectTest(QString func, const QString &params, QMap<QString, QStringList> &place); 52 bool doProjectTest(const QString &func, const QString &params, QMap<QString, QStringList> &place);
53 bool doProjectTest(QString func, QStringList args, QMap<QString, QStringList> &place); 53 bool doProjectTest(const QString &func, QStringList args, QMap<QString, QStringList> &place);
54 bool doProjectCheckReqs(const QStringList &deps, QMap<QString, QStringList> &place); 54 bool doProjectCheckReqs(const QStringList &deps, QMap<QString, QStringList> &place);
55 QString doVariableReplace(QString &str, const QMap<QString, QStringList> &place); 55 QString doVariableReplace(QString &str, const QMap<QString, QStringList> &place);
56 56
57public: 57public:
58 QMakeProject(); 58 QMakeProject();
59 59
60 bool read(QString project, QString pwd); 60 bool read(const QString &project, const QString &pwd, bool just_project=FALSE);
61 QString projectFile(); 61 QString projectFile();
62 QString configFile(); 62 QString configFile();
63 63
64 bool isEmpty(const QString &v); 64 bool isEmpty(const QString &v);
65 QStringList &values(const QString &v); 65 QStringList &values(const QString &v);
66 QString first(const QString &v); 66 QString first(const QString &v);
67 QMap<QString, QStringList> &variables(); 67 QMap<QString, QStringList> &variables();
68 bool isActiveConfig(const QString &x); 68 bool isActiveConfig(const QString &x, bool regex=FALSE);
69 69
70protected: 70protected:
71 friend class MakefileGenerator; 71 friend class MakefileGenerator;
72 bool read(QString file, QMap<QString, QStringList> &place); 72 bool read(const QString &file, QMap<QString, QStringList> &place);
73 73
74}; 74};
75 75
76inline QString QMakeProject::projectFile() 76inline QString QMakeProject::projectFile()
77{ 77{
78#if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP) 78#if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP)
79 // workaround for Sun WorkShop 5.0 bug fixed in Forte 6 79 // workaround for Sun WorkShop 5.0 bug fixed in Forte 6
80 if (pfile == "-") 80 if (pfile == "-")
81 return QString("(stdin)"); 81 return QString("(stdin)");
82 else 82 else
83 return pfile; 83 return pfile;
84#else 84#else
85 return pfile == "-" ? QString("(stdin)") : pfile; 85 return pfile == "-" ? QString("(stdin)") : pfile;
86#endif 86#endif
87} 87}
88 88
89inline QString QMakeProject::configFile() 89inline QString QMakeProject::configFile()
90{ return cfile; } 90{ return cfile; }
91 91
92inline bool QMakeProject::isEmpty(const QString &v) 92inline bool QMakeProject::isEmpty(const QString &v)
93{ return !vars.contains(v) || vars[v].isEmpty(); } 93{ return !vars.contains(v) || vars[v].isEmpty(); }
94 94
95inline QStringList &QMakeProject::values(const QString &v) 95inline QStringList &QMakeProject::values(const QString &v)
96{ return vars[v]; } 96{ return vars[v]; }
97 97
98inline QString QMakeProject::first(const QString &v) 98inline QString QMakeProject::first(const QString &v)
99{ 99{
100#if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP) 100#if defined(Q_CC_SUN) && (__SUNPRO_CC == 0x500) || defined(Q_CC_HP)
101 // workaround for Sun WorkShop 5.0 bug fixed in Forte 6 101 // workaround for Sun WorkShop 5.0 bug fixed in Forte 6
102 if (isEmpty(v)) 102 if (isEmpty(v))
103 return QString(""); 103 return QString("");
104 else 104 else
105 return vars[v].first(); 105 return vars[v].first();
106#else 106#else
107 return isEmpty(v) ? QString("") : vars[v].first(); 107 return isEmpty(v) ? QString("") : vars[v].first();
108#endif 108#endif
109} 109}
110 110
111inline QMap<QString, QStringList> &QMakeProject::variables() 111inline QMap<QString, QStringList> &QMakeProject::variables()
112{ return vars; } 112{ return vars; }
113 113
114#endif /* __QMAKE_H__ */ 114#endif /* __PROJECT_H__ */
diff --git a/qmake/tools/qbitarray.cpp b/qmake/tools/qbitarray.cpp
index 4f4e14b..1aaf963 100644
--- a/qmake/tools/qbitarray.cpp
+++ b/qmake/tools/qbitarray.cpp
@@ -176,49 +176,50 @@ QBitArray::QBitArray( uint size ) : QByteArray( 0, 0 )
176*/ 176*/
177 177
178 178
179/*! 179/*!
180 Pad last byte with 0-bits. 180 Pad last byte with 0-bits.
181*/ 181*/
182void QBitArray::pad0() 182void QBitArray::pad0()
183{ 183{
184 uint sz = size(); 184 uint sz = size();
185 if ( sz && sz%8 ) 185 if ( sz && sz%8 )
186 *(data()+sz/8) &= (1 << (sz%8)) - 1; 186 *(data()+sz/8) &= (1 << (sz%8)) - 1;
187} 187}
188 188
189 189
190/*! 190/*!
191 \fn uint QBitArray::size() const 191 \fn uint QBitArray::size() const
192 192
193 Returns the bit array's size (number of bits). 193 Returns the bit array's size (number of bits).
194 194
195 \sa resize() 195 \sa resize()
196*/ 196*/
197 197
198/*! 198/*!
199 Resizes the bit array to \a size bits and returns TRUE if the bit 199 Resizes the bit array to \a size bits and returns TRUE if the bit
200 array could be resized; otherwise returns FALSE. 200 array could be resized; otherwise returns FALSE. The array becomes
201 a null array if \a size == 0.
201 202
202 If the array is expanded, the new bits are set to 0. 203 If the array is expanded, the new bits are set to 0.
203 204
204 \sa size() 205 \sa size()
205*/ 206*/
206 207
207bool QBitArray::resize( uint size ) 208bool QBitArray::resize( uint size )
208{ 209{
209 uint s = this->size(); 210 uint s = this->size();
210 if ( !QByteArray::resize( (size+7)/8 ) ) 211 if ( !QByteArray::resize( (size+7)/8 ) )
211 return FALSE; // cannot resize 212 return FALSE; // cannot resize
212 SHBLOCK->nbits = size; 213 SHBLOCK->nbits = size;
213 if ( size != 0 ) { // not null array 214 if ( size != 0 ) { // not null array
214 int ds = (int)(size+7)/8 - (int)(s+7)/8;// number of bytes difference 215 int ds = (int)(size+7)/8 - (int)(s+7)/8;// number of bytes difference
215 if ( ds > 0 ) // expanding array 216 if ( ds > 0 ) // expanding array
216 memset( data() + (s+7)/8, 0, ds );// reset new data 217 memset( data() + (s+7)/8, 0, ds );// reset new data
217 } 218 }
218 return TRUE; 219 return TRUE;
219} 220}
220 221
221 222
222/*! 223/*!
223 Fills the bit array with \a v (1's if \a v is TRUE, or 0's if \a v 224 Fills the bit array with \a v (1's if \a v is TRUE, or 0's if \a v
224 is FALSE). 225 is FALSE).
diff --git a/qmake/tools/qbuffer.cpp b/qmake/tools/qbuffer.cpp
index b213dd9..0fc90e4 100644
--- a/qmake/tools/qbuffer.cpp
+++ b/qmake/tools/qbuffer.cpp
@@ -175,50 +175,50 @@ bool QBuffer::setBuffer( QByteArray buf )
175 otherwise returns FALSE. The buffer must be opened before use. 175 otherwise returns FALSE. The buffer must be opened before use.
176 176
177 The mode parameter \a m must be a combination of the following flags. 177 The mode parameter \a m must be a combination of the following flags.
178 \list 178 \list
179 \i \c IO_ReadOnly opens the buffer in read-only mode. 179 \i \c IO_ReadOnly opens the buffer in read-only mode.
180 \i \c IO_WriteOnly opens the buffer in write-only mode. 180 \i \c IO_WriteOnly opens the buffer in write-only mode.
181 \i \c IO_ReadWrite opens the buffer in read/write mode. 181 \i \c IO_ReadWrite opens the buffer in read/write mode.
182 \i \c IO_Append sets the buffer index to the end of the buffer. 182 \i \c IO_Append sets the buffer index to the end of the buffer.
183 \i \c IO_Truncate truncates the buffer. 183 \i \c IO_Truncate truncates the buffer.
184 \endlist 184 \endlist
185 185
186 \sa close(), isOpen() 186 \sa close(), isOpen()
187*/ 187*/
188 188
189bool QBuffer::open( int m ) 189bool QBuffer::open( int m )
190{ 190{
191 if ( isOpen() ) { // buffer already open 191 if ( isOpen() ) { // buffer already open
192#if defined(QT_CHECK_STATE) 192#if defined(QT_CHECK_STATE)
193 qWarning( "QBuffer::open: Buffer already open" ); 193 qWarning( "QBuffer::open: Buffer already open" );
194#endif 194#endif
195 return FALSE; 195 return FALSE;
196 } 196 }
197 setMode( m ); 197 setMode( m );
198 if ( m & IO_Truncate ) { // truncate buffer 198 if ( m & IO_Truncate ) { // truncate buffer
199 a.resize( 0 ); 199 a.resize( 1 );
200 a_len = 0; 200 a_len = 1;
201 } 201 }
202 if ( m & IO_Append ) { // append to end of buffer 202 if ( m & IO_Append ) { // append to end of buffer
203 ioIndex = a.size(); 203 ioIndex = a.size();
204 } else { 204 } else {
205 ioIndex = 0; 205 ioIndex = 0;
206 } 206 }
207 a_inc = 16; 207 a_inc = 16;
208 setState( IO_Open ); 208 setState( IO_Open );
209 setStatus( 0 ); 209 setStatus( 0 );
210 return TRUE; 210 return TRUE;
211} 211}
212 212
213/*! 213/*!
214 \reimp 214 \reimp
215 215
216 Closes an open buffer. 216 Closes an open buffer.
217 217
218 \sa open() 218 \sa open()
219*/ 219*/
220 220
221void QBuffer::close() 221void QBuffer::close()
222{ 222{
223 if ( isOpen() ) { 223 if ( isOpen() ) {
224 setFlags( IO_Direct ); 224 setFlags( IO_Direct );
diff --git a/qmake/tools/qcomlibrary.cpp b/qmake/tools/qcomlibrary.cpp
index a7162fc..2a1b75a 100644
--- a/qmake/tools/qcomlibrary.cpp
+++ b/qmake/tools/qcomlibrary.cpp
@@ -42,48 +42,52 @@
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qcleanuphandler.h> 43#include <qcleanuphandler.h>
44#include <errno.h> 44#include <errno.h>
45 45
46#ifdef QT_THREAD_SUPPORT 46#ifdef QT_THREAD_SUPPORT
47# include "qmutexpool_p.h" 47# include "qmutexpool_p.h"
48#endif // QT_THREAD_SUPPORT 48#endif // QT_THREAD_SUPPORT
49 49
50#ifndef QT_DEBUG_COMPONENT 50#ifndef QT_DEBUG_COMPONENT
51# if defined(QT_DEBUG) 51# if defined(QT_DEBUG)
52# define QT_DEBUG_COMPONENT 1 52# define QT_DEBUG_COMPONENT 1
53# endif 53# endif
54#endif 54#endif
55 55
56 56
57QComLibrary::QComLibrary( const QString &filename ) 57QComLibrary::QComLibrary( const QString &filename )
58 : QLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 ) 58 : QLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 )
59{ 59{
60} 60}
61 61
62QComLibrary::~QComLibrary() 62QComLibrary::~QComLibrary()
63{ 63{
64 if ( autoUnload() ) 64 if ( autoUnload() )
65 unload(); 65 unload();
66 if ( libiface )
67 libiface->release();
68 if ( entry )
69 entry->release();
66} 70}
67 71
68bool QComLibrary::unload() 72bool QComLibrary::unload()
69{ 73{
70 if ( libiface ) { 74 if ( libiface ) {
71 libiface->cleanup(); 75 libiface->cleanup();
72 if ( !libiface->canUnload() ) 76 if ( !libiface->canUnload() )
73 return FALSE; 77 return FALSE;
74 libiface->release(); 78 libiface->release();
75 libiface = 0; 79 libiface = 0;
76 } 80 }
77 int refs = entry ? entry->release() : 0; 81 int refs = entry ? entry->release() : 0;
78 if ( refs ) 82 if ( refs )
79 return FALSE; 83 return FALSE;
80 84
81 entry = 0; 85 entry = 0;
82 86
83 return QLibrary::unload(); 87 return QLibrary::unload();
84} 88}
85 89
86static bool qt_verify( const QString& library, uint version, uint flags, 90static bool qt_verify( const QString& library, uint version, uint flags,
87 const QCString &key, bool warn ) 91 const QCString &key, bool warn )
88{ 92{
89 uint our_flags = 1; 93 uint our_flags = 1;
@@ -370,123 +374,116 @@ static bool qt_unix_query( const QString &library, uint *version, uint *flags,
370 374
371#endif // Q_OS_UNIX 375#endif // Q_OS_UNIX
372 376
373 377
374static QSettings *cache = 0; 378static QSettings *cache = 0;
375static QSingleCleanupHandler<QSettings> cleanup_cache; 379static QSingleCleanupHandler<QSettings> cleanup_cache;
376 380
377void QComLibrary::createInstanceInternal() 381void QComLibrary::createInstanceInternal()
378{ 382{
379 if ( library().isEmpty() ) 383 if ( library().isEmpty() )
380 return; 384 return;
381 385
382 QFileInfo fileinfo( library() ); 386 QFileInfo fileinfo( library() );
383 QString lastModified = fileinfo.lastModified().toString(); 387 QString lastModified = fileinfo.lastModified().toString();
384 QString regkey = QString("/Qt Plugins %1.%2/%3") 388 QString regkey = QString("/Qt Plugins %1.%2/%3")
385 .arg( ( QT_VERSION & 0xff0000 ) >> 16 ) 389 .arg( ( QT_VERSION & 0xff0000 ) >> 16 )
386 .arg( ( QT_VERSION & 0xff00 ) >> 8 ) 390 .arg( ( QT_VERSION & 0xff00 ) >> 8 )
387 .arg( library() ); 391 .arg( library() );
388 QStringList reg; 392 QStringList reg;
389 uint flags = 0; 393 uint flags = 0;
390 QCString key; 394 QCString key;
391 bool query_done = FALSE; 395 bool query_done = FALSE;
392 bool warn_mismatch = TRUE; 396 bool warn_mismatch = TRUE;
393 397
394 if ( ! query_done ) {
395
396#ifdef QT_THREAD_SUPPORT 398#ifdef QT_THREAD_SUPPORT
397 QMutexLocker locker( qt_global_mutexpool->get( &cache ) ); 399 QMutexLocker locker( qt_global_mutexpool ?
400 qt_global_mutexpool->get( &cache ) : 0 );
398#endif // QT_THREAD_SUPPORT 401#endif // QT_THREAD_SUPPORT
399 402
400 if ( ! cache ) { 403 if ( ! cache ) {
401 cache = new QSettings; 404 cache = new QSettings;
402 cache->insertSearchPath( QSettings::Windows, "/Trolltech" ); 405 cache->insertSearchPath( QSettings::Windows, "/Trolltech" );
403 cleanup_cache.set( &cache ); 406 cleanup_cache.set( &cache );
404 } 407 }
405 408
406 reg = cache->readListEntry( regkey ); 409 reg = cache->readListEntry( regkey );
407 if ( reg.count() == 4 ) { 410 if ( reg.count() == 4 ) {
408 // check timestamp 411 // check timestamp
409 if ( lastModified == reg[3] ) { 412 if ( lastModified == reg[3] ) {
410 qt_version = reg[0].toUInt(0, 16); 413 qt_version = reg[0].toUInt(0, 16);
411 flags = reg[1].toUInt(0, 16); 414 flags = reg[1].toUInt(0, 16);
412 key = reg[2].latin1(); 415 key = reg[2].latin1();
413 416
414 query_done = TRUE; 417 query_done = TRUE;
415 warn_mismatch = FALSE; 418 warn_mismatch = FALSE;
416 }
417 } 419 }
418 } 420 }
419 421
420#if defined(Q_OS_UNIX) 422#if defined(Q_OS_UNIX)
421 if ( ! query_done ) { 423 if ( ! query_done ) {
422 // get the query information directly from the plugin without loading 424 // get the query information directly from the plugin without loading
423 if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) { 425 if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) {
424 // info read succesfully from library 426 // info read succesfully from library
425 query_done = TRUE; 427 query_done = TRUE;
426 } 428 }
427 } 429 }
428#else // !Q_OS_UNIX 430#else // !Q_OS_UNIX
429 if ( ! query_done ) { 431 if ( ! query_done ) {
430 // get the query information by loading the plugin 432 // get the query information by loading the plugin
431 if ( !isLoaded() ) { 433 if ( !isLoaded() ) {
432 Q_ASSERT( entry == 0 ); 434 Q_ASSERT( entry == 0 );
433 if ( !load() ) 435 if ( !load() )
434 return; 436 return;
435 } 437 }
436 438
437# ifdef Q_CC_BOR 439# ifdef Q_CC_BOR
438 typedef const char * __stdcall (*UCMQueryVerificationDataProc)(); 440 typedef const char * __stdcall (*UCMQueryVerificationDataProc)();
439# else 441# else
440 typedef const char * (*UCMQueryVerificationDataProc)(); 442 typedef const char * (*UCMQueryVerificationDataProc)();
441# endif 443# endif
442 UCMQueryVerificationDataProc ucmQueryVerificationdataProc; 444 UCMQueryVerificationDataProc ucmQueryVerificationdataProc;
443 ucmQueryVerificationdataProc = 445 ucmQueryVerificationdataProc =
444 (UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" ); 446 (UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" );
445 447
446 if ( !ucmQueryVerificationdataProc || 448 if ( !ucmQueryVerificationdataProc ||
447 !qt_parse_pattern( ucmQueryVerificationdataProc(), 449 !qt_parse_pattern( ucmQueryVerificationdataProc(),
448 &qt_version, &flags, &key ) ) { 450 &qt_version, &flags, &key ) ) {
449 qt_version = flags = 0; 451 qt_version = flags = 0;
450 key = "unknown"; 452 key = "unknown";
451 } else { 453 } else {
452 query_done = TRUE; 454 query_done = TRUE;
453 } 455 }
454 } 456 }
455#endif // Q_OS_UNIX 457#endif // Q_OS_UNIX
456 458
457 QStringList queried; 459 QStringList queried;
458 queried << QString::number( qt_version,16 ) 460 queried << QString::number( qt_version,16 )
459 << QString::number( flags, 16 ) 461 << QString::number( flags, 16 )
460 << key 462 << key
461 << lastModified; 463 << lastModified;
462 464
463 if ( queried != reg ) { 465 if ( queried != reg ) {
464
465#ifdef QT_THREAD_SUPPORT
466 QMutexLocker locker( qt_global_mutexpool->get( &cache ) );
467#endif // QT_THREAD_SUPPORT
468
469 cache->writeEntry( regkey, queried ); 466 cache->writeEntry( regkey, queried );
470 // delete the cache, which forces the settings to be written 467 // delete the cache, which forces the settings to be written
471 delete cache; 468 delete cache;
472 cache = 0; 469 cache = 0;
473 } 470 }
474 471
475 if ( ! query_done ) { 472 if ( ! query_done ) {
476 if ( warn_mismatch ) { 473 if ( warn_mismatch ) {
477 qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!", 474 qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!",
478 (const char*) QFile::encodeName( library() ) ); 475 (const char*) QFile::encodeName( library() ) );
479 } 476 }
480 unload(); 477 unload();
481 return; 478 return;
482 } 479 }
483 480
484 if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) { 481 if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) {
485 unload(); 482 unload();
486 return; 483 return;
487 } else if ( !isLoaded() ) { 484 } else if ( !isLoaded() ) {
488 Q_ASSERT( entry == 0 ); 485 Q_ASSERT( entry == 0 );
489 if ( !load() ) 486 if ( !load() )
490 return; 487 return;
491 } 488 }
492 489
diff --git a/qmake/tools/qconfig.cpp b/qmake/tools/qconfig.cpp
index 433827c..5297a4e 100644
--- a/qmake/tools/qconfig.cpp
+++ b/qmake/tools/qconfig.cpp
@@ -1,17 +1,17 @@
1/* Install paths from configure */ 1/* Install paths from configure */
2 2
3static const char QT_INSTALL_PREFIX [256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2"; 3static const char QT_INSTALL_PREFIX [256] = "/opt/qt-x11-free-3.1.2";
4static const char QT_INSTALL_BINS [256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2/bin"; 4static const char QT_INSTALL_BINS [256] = "/opt/qt-x11-free-3.1.2/bin";
5static const char QT_INSTALL_DOCS [256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2/doc"; 5static const char QT_INSTALL_DOCS [256] = "/opt/qt-x11-free-3.1.2/doc";
6static const char QT_INSTALL_HEADERS[256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2/include"; 6static const char QT_INSTALL_HEADERS[256] = "/opt/qt-x11-free-3.1.2/include";
7static const char QT_INSTALL_LIBS [256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2/lib"; 7static const char QT_INSTALL_LIBS [256] = "/opt/qt-x11-free-3.1.2/lib";
8static const char QT_INSTALL_PLUGINS[256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2/plugins"; 8static const char QT_INSTALL_PLUGINS[256] = "/opt/qt-x11-free-3.1.2/plugins";
9static const char QT_INSTALL_DATA [256] = "/usr/src/coding/projects/userspace/qt-embedded-free-3.1.0-b2"; 9static const char QT_INSTALL_DATA [256] = "/opt/qt-x11-free-3.1.2";
10 10
11const char *qInstallPath() { return QT_INSTALL_PREFIX; } 11const char *qInstallPath() { return QT_INSTALL_PREFIX; }
12const char *qInstallPathDocs() { return QT_INSTALL_DOCS; } 12const char *qInstallPathDocs() { return QT_INSTALL_DOCS; }
13const char *qInstallPathHeaders() { return QT_INSTALL_HEADERS; } 13const char *qInstallPathHeaders() { return QT_INSTALL_HEADERS; }
14const char *qInstallPathLibs() { return QT_INSTALL_LIBS; } 14const char *qInstallPathLibs() { return QT_INSTALL_LIBS; }
15const char *qInstallPathBins() { return QT_INSTALL_BINS; } 15const char *qInstallPathBins() { return QT_INSTALL_BINS; }
16const char *qInstallPathPlugins() { return QT_INSTALL_PLUGINS; } 16const char *qInstallPathPlugins() { return QT_INSTALL_PLUGINS; }
17const char *qInstallPathData() { return QT_INSTALL_DATA; } 17const char *qInstallPathData() { return QT_INSTALL_DATA; }
diff --git a/qmake/tools/qcriticalsection_p.cpp b/qmake/tools/qcriticalsection_p.cpp
index 60fc8bd..c375730 100644
--- a/qmake/tools/qcriticalsection_p.cpp
+++ b/qmake/tools/qcriticalsection_p.cpp
@@ -1,31 +1,29 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QCriticalSection class 4** Implementation of QCriticalSection class
5** 5**
6** Created :
7**
8** Copyright (C) 2001 Trolltech AS. All rights reserved. 6** Copyright (C) 2001 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the tools module of the Qt GUI Toolkit. 8** This file is part of the tools module of the Qt GUI Toolkit.
11** 9**
12** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
15** 13**
16** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 17** packaging of this file.
20** 18**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 21** Agreement provided with the Software.
24** 22**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 25**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
diff --git a/qmake/tools/qcstring.cpp b/qmake/tools/qcstring.cpp
index cf1b853..4651b97 100644
--- a/qmake/tools/qcstring.cpp
+++ b/qmake/tools/qcstring.cpp
@@ -120,48 +120,59 @@ char *qstrdup( const char *src )
120/*! 120/*!
121 \relates QCString 121 \relates QCString
122 122
123 A safe strncpy() function. 123 A safe strncpy() function.
124 124
125 Copies at most \a len bytes from \a src (stopping at \a len or the 125 Copies at most \a len bytes from \a src (stopping at \a len or the
126 terminating '\0' whichever comes first) into \a dst and returns a 126 terminating '\0' whichever comes first) into \a dst and returns a
127 pointer to \a dst. Guarantees that \a dst is '\0'-terminated. If 127 pointer to \a dst. Guarantees that \a dst is '\0'-terminated. If
128 \a src or \a dst is 0, returns 0 immediately. 128 \a src or \a dst is 0, returns 0 immediately.
129 129
130 \sa qstrcpy() 130 \sa qstrcpy()
131*/ 131*/
132 132
133char *qstrncpy( char *dst, const char *src, uint len ) 133char *qstrncpy( char *dst, const char *src, uint len )
134{ 134{
135 if ( !src || !dst ) 135 if ( !src || !dst )
136 return 0; 136 return 0;
137 strncpy( dst, src, len ); 137 strncpy( dst, src, len );
138 if ( len > 0 ) 138 if ( len > 0 )
139 dst[len-1] = '\0'; 139 dst[len-1] = '\0';
140 return dst; 140 return dst;
141} 141}
142 142
143/*! 143/*!
144 \fn uint qstrlen( const char *str );
145
146 \relates QCString
147
148 A safe strlen function.
149
150 Returns the number of characters that precede the terminating '\0'.
151 or 0 if \a str is 0.
152*/
153
154/*!
144 \fn int qstrcmp( const char *str1, const char *str2 ); 155 \fn int qstrcmp( const char *str1, const char *str2 );
145 156
146 \relates QCString 157 \relates QCString
147 158
148 A safe strcmp() function. 159 A safe strcmp() function.
149 160
150 Compares \a str1 and \a str2. Returns a negative value if \a str1 161 Compares \a str1 and \a str2. Returns a negative value if \a str1
151 is less than \a str2, 0 if \a str1 is equal to \a str2 or a 162 is less than \a str2, 0 if \a str1 is equal to \a str2 or a
152 positive value if \a str1 is greater than \a str2. 163 positive value if \a str1 is greater than \a str2.
153 164
154 Special case I: Returns 0 if \a str1 and \a str2 are both 0. 165 Special case I: Returns 0 if \a str1 and \a str2 are both 0.
155 166
156 Special case II: Returns a random nonzero value if \a str1 is 0 167 Special case II: Returns a random nonzero value if \a str1 is 0
157 or \a str2 is 0 (but not both). 168 or \a str2 is 0 (but not both).
158 169
159 \sa qstrncmp() qstricmp() qstrnicmp() 170 \sa qstrncmp() qstricmp() qstrnicmp()
160 \link #asciinotion Note on character comparisons \endlink 171 \link #asciinotion Note on character comparisons \endlink
161*/ 172*/
162 173
163/*! 174/*!
164 \fn int qstrncmp( const char *str1, const char *str2, uint len ); 175 \fn int qstrncmp( const char *str1, const char *str2, uint len );
165 176
166 \relates QCString 177 \relates QCString
167 178
@@ -278,142 +289,161 @@ static void createCRC16Table() // build CRC16 lookup table
278 SET_BIT( j, 13, v1 ); 289 SET_BIT( j, 13, v1 );
279 SET_BIT( j, 2, v2 ); 290 SET_BIT( j, 2, v2 );
280 SET_BIT( j, 9, v2 ); 291 SET_BIT( j, 9, v2 );
281 SET_BIT( j, 14, v2 ); 292 SET_BIT( j, 14, v2 );
282 SET_BIT( j, 3, v3 ); 293 SET_BIT( j, 3, v3 );
283 SET_BIT( j, 10, v3 ); 294 SET_BIT( j, 10, v3 );
284 SET_BIT( j, 15, v3 ); 295 SET_BIT( j, 15, v3 );
285 crc_tbl[i] = j; 296 crc_tbl[i] = j;
286 } 297 }
287} 298}
288 299
289/*! 300/*!
290 \relates QMemArray 301 \relates QMemArray
291 302
292 Returns the CRC-16 checksum of \a len bytes starting at \a data. 303 Returns the CRC-16 checksum of \a len bytes starting at \a data.
293 304
294 The checksum is independent of the byte order (endianness). 305 The checksum is independent of the byte order (endianness).
295*/ 306*/
296 307
297Q_UINT16 qChecksum( const char *data, uint len ) 308Q_UINT16 qChecksum( const char *data, uint len )
298{ 309{
299 if ( !crc_tbl_init ) { // create lookup table 310 if ( !crc_tbl_init ) { // create lookup table
300 311
301#ifdef QT_THREAD_SUPPORT 312#ifdef QT_THREAD_SUPPORT
302 QMutexLocker locker( qt_global_mutexpool->get( &crc_tbl_init ) ); 313 QMutexLocker locker( qt_global_mutexpool ?
314 qt_global_mutexpool->get( &crc_tbl_init ) : 0 );
303#endif // QT_THREAD_SUPPORT 315#endif // QT_THREAD_SUPPORT
304 316
305 if ( !crc_tbl_init ) { 317 if ( !crc_tbl_init ) {
306 createCRC16Table(); 318 createCRC16Table();
307 crc_tbl_init = TRUE; 319 crc_tbl_init = TRUE;
308 } 320 }
309 } 321 }
310 register Q_UINT16 crc = 0xffff; 322 register Q_UINT16 crc = 0xffff;
311 uchar c; 323 uchar c;
312 uchar *p = (uchar *)data; 324 uchar *p = (uchar *)data;
313 while ( len-- ) { 325 while ( len-- ) {
314 c = *p++; 326 c = *p++;
315 crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)]; 327 crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)];
316 c >>= 4; 328 c >>= 4;
317 crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)]; 329 crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)];
318 } 330 }
319 return ~crc & 0xffff; 331 return ~crc & 0xffff;
320} 332}
321 333
322/*! \fn QByteArray qCompress( const QByteArray& data) 334/*!
323 \relates QByteArray 335 \fn QByteArray qCompress( const QByteArray& data )
324 \overload 336
337 \relates QByteArray
338
339 Compresses the array \a data and returns the compressed byte
340 array.
341
342 \sa qUncompress()
325*/ 343*/
326 344
327/*! 345/*!
328 \relates QByteArray 346 \relates QByteArray
329 347
330 Compresses the array \a data which is \a nbytes long and returns the 348 \overload
331 compressed byte array.
332 349
333 \sa qUncompress() 350 Compresses the array \a data which is \a nbytes long and returns the
351 compressed byte array.
334*/ 352*/
335 353
336#ifndef QT_NO_COMPRESS 354#ifndef QT_NO_COMPRESS
337QByteArray qCompress( const uchar* data, int nbytes ) 355QByteArray qCompress( const uchar* data, int nbytes )
338{ 356{
339 if ( nbytes == 0 ) { 357 if ( nbytes == 0 ) {
340 QByteArray tmp( 4 ); 358 QByteArray tmp( 4 );
341 tmp.fill( 0 ); 359 tmp.fill( 0 );
342 return tmp; 360 return tmp;
343 } 361 }
344 if ( !data ) { 362 if ( !data ) {
345#if defined(QT_CHECK_RANGE) 363#if defined(QT_CHECK_RANGE)
346 qWarning( "qCompress: data is NULL." ); 364 qWarning( "qCompress: data is NULL." );
347#endif 365#endif
348 return QByteArray(); 366 return QByteArray();
349 } 367 }
350 368
351 ulong len = nbytes * 2; 369 ulong len = nbytes * 2;
352 QByteArray bazip; 370 QByteArray bazip;
353 int res; 371 int res;
354 do { 372 do {
355 bazip.resize( len + 4 ); 373 bazip.resize( len + 4 );
356 res = ::compress( (uchar*)bazip.data()+4, &len, (uchar*)data, nbytes ); 374 res = ::compress( (uchar*)bazip.data()+4, &len, (uchar*)data, nbytes );
357 375
358 switch ( res ) { 376 switch ( res ) {
359 case Z_OK: 377 case Z_OK:
360 bazip.resize( len + 4 ); 378 bazip.resize( len + 4 );
361 bazip[0] = ( nbytes & 0xff000000 ) >> 24; 379 bazip[0] = ( nbytes & 0xff000000 ) >> 24;
362 bazip[1] = ( nbytes & 0x00ff0000 ) >> 16; 380 bazip[1] = ( nbytes & 0x00ff0000 ) >> 16;
363 bazip[2] = ( nbytes & 0x0000ff00 ) >> 8; 381 bazip[2] = ( nbytes & 0x0000ff00 ) >> 8;
364 bazip[3] = ( nbytes & 0x000000ff ); 382 bazip[3] = ( nbytes & 0x000000ff );
365 break; 383 break;
366 case Z_MEM_ERROR: 384 case Z_MEM_ERROR:
367#if defined(QT_CHECK_RANGE) 385#if defined(QT_CHECK_RANGE)
368 qWarning( "qCompress: Z_MEM_ERROR: Not enough memory." ); 386 qWarning( "qCompress: Z_MEM_ERROR: Not enough memory." );
369#endif 387#endif
370 bazip.resize( 0 ); 388 bazip.resize( 0 );
371 break; 389 break;
372 case Z_BUF_ERROR: 390 case Z_BUF_ERROR:
373 len *= 2; 391 len *= 2;
374 break; 392 break;
375 } 393 }
376 } while ( res == Z_BUF_ERROR ); 394 } while ( res == Z_BUF_ERROR );
377 395
378 return bazip; 396 return bazip;
379} 397}
380#endif 398#endif
381 399
382/*! \fn QByteArray qUncompress( const QByteArray& data ) 400/*!
383 \relates QByteArray 401 \fn QByteArray qUncompress( const QByteArray& data )
384 \overload 402
403 \relates QByteArray
404
405 Uncompresses the array \a data and returns the uncompressed byte
406 array.
407
408 Returns an empty QByteArray if the input data was corrupt.
409 \omit
410 ADD THE FOLLOWING FOR Qt 4.0
411 This function will uncompress data compressed with qCompress()
412 from this and any earlier Qt version, back to Qt 3.1 when this
413 feature was added.
414 \endomit
415
416 \sa qCompress()
385*/ 417*/
386 418
387/*! 419/*!
388 \relates QByteArray 420 \relates QByteArray
389
390 Uncompresses the array \a data which is \a nbytes long and returns
391 the uncompressed byte array.
392 421
393 Returns an empty QByteArray if the input data was corrupt. 422 \overload
394 423
395 \sa qCompress() 424 Uncompresses the array \a data which is \a nbytes long and returns
425 the uncompressed byte array.
396*/ 426*/
397 427
398#ifndef QT_NO_COMPRESS 428#ifndef QT_NO_COMPRESS
399QByteArray qUncompress( const uchar* data, int nbytes ) 429QByteArray qUncompress( const uchar* data, int nbytes )
400{ 430{
401 if ( !data ) { 431 if ( !data ) {
402#if defined(QT_CHECK_RANGE) 432#if defined(QT_CHECK_RANGE)
403 qWarning( "qUncompress: data is NULL." ); 433 qWarning( "qUncompress: data is NULL." );
404#endif 434#endif
405 return QByteArray(); 435 return QByteArray();
406 } 436 }
407 if ( nbytes <= 4 ) { 437 if ( nbytes <= 4 ) {
408#if defined(QT_CHECK_RANGE) 438#if defined(QT_CHECK_RANGE)
409 if ( nbytes < 4 || ( data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0 ) ) 439 if ( nbytes < 4 || ( data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0 ) )
410 qWarning( "qUncompress: Input data is corrupted." ); 440 qWarning( "qUncompress: Input data is corrupted." );
411#endif 441#endif
412 return QByteArray(); 442 return QByteArray();
413 } 443 }
414 ulong expectedSize = ( data[0] << 24 ) | ( data[1] << 16 ) | ( data[2] << 8 ) | data[3]; 444 ulong expectedSize = ( data[0] << 24 ) | ( data[1] << 16 ) | ( data[2] << 8 ) | data[3];
415 ulong len = QMAX( expectedSize, 1 ); 445 ulong len = QMAX( expectedSize, 1 );
416 QByteArray baunzip; 446 QByteArray baunzip;
417 int res; 447 int res;
418 do { 448 do {
419 baunzip.resize( len ); 449 baunzip.resize( len );
@@ -915,55 +945,59 @@ int QCString::find( char c, int index, bool cs ) const
915} 945}
916 946
917#define REHASH( a ) \ 947#define REHASH( a ) \
918 if ( sl_minus_1 < sizeof(uint) * CHAR_BIT ) \ 948 if ( sl_minus_1 < sizeof(uint) * CHAR_BIT ) \
919 hashHaystack -= (a) << sl_minus_1; \ 949 hashHaystack -= (a) << sl_minus_1; \
920 hashHaystack <<= 1 950 hashHaystack <<= 1
921 951
922/*! 952/*!
923 \overload 953 \overload
924 954
925 Finds the first occurrence of the string \a str, starting at 955 Finds the first occurrence of the string \a str, starting at
926 position \a index. 956 position \a index.
927 957
928 The search is case sensitive if \a cs is TRUE, or case insensitive 958 The search is case sensitive if \a cs is TRUE, or case insensitive
929 if \a cs is FALSE. 959 if \a cs is FALSE.
930 960
931 Returns the position of \a str, or -1 if \a str could not be 961 Returns the position of \a str, or -1 if \a str could not be
932 found. 962 found.
933 963
934 \sa \link #asciinotion Note on character comparisons \endlink 964 \sa \link #asciinotion Note on character comparisons \endlink
935*/ 965*/
936 966
937int QCString::find( const char *str, int index, bool cs ) const 967int QCString::find( const char *str, int index, bool cs ) const
938{ 968{
969 return find( str, index, cs, length() );
970}
971
972int QCString::find( const char *str, int index, bool cs, uint l ) const
973{
939 if ( (uint)index >= size() ) 974 if ( (uint)index >= size() )
940 return -1; 975 return -1;
941 if ( !str ) 976 if ( !str )
942 return -1; 977 return -1;
943 if ( !*str ) 978 if ( !*str )
944 return index; 979 return index;
945 const uint l = length();
946 const uint sl = qstrlen( str ); 980 const uint sl = qstrlen( str );
947 if ( sl + index > l ) 981 if ( sl + index > l )
948 return -1; 982 return -1;
949 983
950 if ( sl == 1 ) 984 if ( sl == 1 )
951 return find( *str, index, cs ); 985 return find( *str, index, cs );
952 986
953 /* 987 /*
954 See QString::find() for details. 988 See QString::find() for details.
955 */ 989 */
956 const char* needle = str; 990 const char* needle = str;
957 const char* haystack = data() + index; 991 const char* haystack = data() + index;
958 const char* end = data() + (l-sl); 992 const char* end = data() + (l-sl);
959 const uint sl_minus_1 = sl-1; 993 const uint sl_minus_1 = sl-1;
960 uint hashNeedle = 0, hashHaystack = 0,i; 994 uint hashNeedle = 0, hashHaystack = 0,i;
961 995
962 if ( cs ) { 996 if ( cs ) {
963 for ( i = 0; i < sl; ++i ) { 997 for ( i = 0; i < sl; ++i ) {
964 hashNeedle = ((hashNeedle<<1) + needle[i] ); 998 hashNeedle = ((hashNeedle<<1) + needle[i] );
965 hashHaystack = ((hashHaystack<<1) + haystack[i] ); 999 hashHaystack = ((hashHaystack<<1) + haystack[i] );
966 } 1000 }
967 hashHaystack -= *(haystack+sl_minus_1); 1001 hashHaystack -= *(haystack+sl_minus_1);
968 1002
969 while ( haystack <= end ) { 1003 while ( haystack <= end ) {
@@ -1131,70 +1165,70 @@ int QCString::contains( char c, bool cs ) const
1131 } 1165 }
1132 } 1166 }
1133 return count; 1167 return count;
1134} 1168}
1135 1169
1136/*! 1170/*!
1137 \overload 1171 \overload
1138 1172
1139 Returns the number of times \a str occurs in the string. 1173 Returns the number of times \a str occurs in the string.
1140 1174
1141 The match is case sensitive if \a cs is TRUE, or case insensitive 1175 The match is case sensitive if \a cs is TRUE, or case insensitive
1142 if \a cs if FALSE. 1176 if \a cs if FALSE.
1143 1177
1144 This function counts overlapping substrings, for example, "banana" 1178 This function counts overlapping substrings, for example, "banana"
1145 contains two occurrences of "ana". 1179 contains two occurrences of "ana".
1146 1180
1147 \sa findRev() 1181 \sa findRev()
1148 \link #asciinotion Note on character comparisons \endlink 1182 \link #asciinotion Note on character comparisons \endlink
1149*/ 1183*/
1150 1184
1151int QCString::contains( const char *str, bool cs ) const 1185int QCString::contains( const char *str, bool cs ) const
1152{ 1186{
1153 int count = 0; 1187 int count = 0;
1154 int i = -1; 1188 int i = -1;
1189 uint l = length();
1155 // use find for the faster hashing algorithm 1190 // use find for the faster hashing algorithm
1156 while ( ( i = find ( str, i+1, cs ) ) != -1 ) 1191 while ( ( i = find ( str, i+1, cs, l ) ) != -1 )
1157 count++; 1192 count++;
1158 return count; 1193 return count;
1159} 1194}
1160 1195
1161/*! 1196/*!
1162 Returns a substring that contains the \a len leftmost characters 1197 Returns a substring that contains the \a len leftmost characters
1163 of the string. 1198 of the string.
1164 1199
1165 The whole string is returned if \a len exceeds the length of the 1200 The whole string is returned if \a len exceeds the length of the
1166 string. 1201 string.
1167 1202
1168 Example: 1203 Example:
1169 \code 1204 \code
1170 QCString s = "Pineapple"; 1205 QCString s = "Pineapple";
1171 QCString t = s.left( 4 ); // t == "Pine" 1206 QCString t = s.left( 4 ); // t == "Pine"
1172 \endcode 1207 \endcode
1173 1208
1174 \sa right(), mid() 1209 \sa right(), mid()
1175*/ 1210*/
1176
1177QCString QCString::left( uint len ) const 1211QCString QCString::left( uint len ) const
1178{ 1212{
1179 if ( isEmpty() ) { 1213 if ( isEmpty() ) {
1180 QCString empty; 1214 QCString empty;
1181 return empty; 1215 return empty;
1182 } else if ( len >= size() ) { 1216 } else if ( len >= size() ) {
1183 QCString same( data() ); 1217 QCString same( data() );
1184 return same; 1218 return same;
1185 } else { 1219 } else {
1186 QCString s( len+1 ); 1220 QCString s( len+1 );
1187 strncpy( s.data(), data(), len ); 1221 strncpy( s.data(), data(), len );
1188 *(s.data()+len) = '\0'; 1222 *(s.data()+len) = '\0';
1189 return s; 1223 return s;
1190 } 1224 }
1191} 1225}
1192 1226
1193/*! 1227/*!
1194 Returns a substring that contains the \a len rightmost characters 1228 Returns a substring that contains the \a len rightmost characters
1195 of the string. 1229 of the string.
1196 1230
1197 The whole string is returned if \a len exceeds the length of the 1231 The whole string is returned if \a len exceeds the length of the
1198 string. 1232 string.
1199 1233
1200 Example: 1234 Example:
@@ -1476,56 +1510,58 @@ QCString QCString::simplifyWhiteSpace() const
1476 Inserts string \a s into the string at position \a index. 1510 Inserts string \a s into the string at position \a index.
1477 1511
1478 If \a index is beyond the end of the string, the string is 1512 If \a index is beyond the end of the string, the string is
1479 padded with spaces (ASCII 32) to length \a index and then \a s 1513 padded with spaces (ASCII 32) to length \a index and then \a s
1480 is appended. 1514 is appended.
1481 1515
1482 \code 1516 \code
1483 QCString s = "I like fish"; 1517 QCString s = "I like fish";
1484 s.insert( 2, "don't "); // s == "I don't like fish" 1518 s.insert( 2, "don't "); // s == "I don't like fish"
1485 1519
1486 s = "x"; // index 01234 1520 s = "x"; // index 01234
1487 s.insert( 3, "yz" ); // s == "x yz" 1521 s.insert( 3, "yz" ); // s == "x yz"
1488 \endcode 1522 \endcode
1489*/ 1523*/
1490 1524
1491QCString &QCString::insert( uint index, const char *s ) 1525QCString &QCString::insert( uint index, const char *s )
1492{ 1526{
1493 int len = qstrlen(s); 1527 int len = qstrlen(s);
1494 if ( len == 0 ) 1528 if ( len == 0 )
1495 return *this; 1529 return *this;
1496 uint olen = length(); 1530 uint olen = length();
1497 int nlen = olen + len; 1531 int nlen = olen + len;
1498 if ( index >= olen ) { // insert after end of string 1532 if ( index >= olen ) { // insert after end of string
1499 detach(); 1533 detach();
1500 if ( QByteArray::resize(nlen+index-olen+1) ) { 1534 if ( QByteArray::resize(nlen+index-olen+1, QByteArray::SpeedOptim ) ) {
1501 memset( data()+olen, ' ', index-olen ); 1535 memset( data()+olen, ' ', index-olen );
1502 memcpy( data()+index, s, len+1 ); 1536 memcpy( data()+index, s, len+1 );
1503 } 1537 }
1504 } else if ( QByteArray::resize(nlen+1) ) {// normal insert 1538 } else {
1505 detach(); 1539 detach();
1506 memmove( data()+index+len, data()+index, olen-index+1 ); 1540 if ( QByteArray::resize(nlen+1, QByteArray::SpeedOptim ) ) {// normal insert
1507 memcpy( data()+index, s, len ); 1541 memmove( data()+index+len, data()+index, olen-index+1 );
1542 memcpy( data()+index, s, len );
1543 }
1508 } 1544 }
1509 return *this; 1545 return *this;
1510} 1546}
1511 1547
1512/*! 1548/*!
1513 Inserts character \a c into the string at position \a index and 1549 Inserts character \a c into the string at position \a index and
1514 returns a reference to the string. 1550 returns a reference to the string.
1515 1551
1516 If \a index is beyond the end of the string, the string is 1552 If \a index is beyond the end of the string, the string is
1517 padded with spaces (ASCII 32) to length \a index and then \a c 1553 padded with spaces (ASCII 32) to length \a index and then \a c
1518 is appended. 1554 is appended.
1519 1555
1520 Example: 1556 Example:
1521 \code 1557 \code
1522 QCString s = "Yes"; 1558 QCString s = "Yes";
1523 s.insert( 3, '!'); // s == "Yes!" 1559 s.insert( 3, '!'); // s == "Yes!"
1524 \endcode 1560 \endcode
1525 1561
1526 \sa remove(), replace() 1562 \sa remove(), replace()
1527*/ 1563*/
1528 1564
1529 QCString &QCString::insert( uint index, char c )// insert char 1565 QCString &QCString::insert( uint index, char c )// insert char
1530{ 1566{
1531 char buf[2]; 1567 char buf[2];
@@ -1548,49 +1584,49 @@ QCString &QCString::insert( uint index, char c ) // insert char
1548 1584
1549 If \a index is out of range, nothing happens. If \a index is 1585 If \a index is out of range, nothing happens. If \a index is
1550 valid, but \a index + \a len is larger than the length of the 1586 valid, but \a index + \a len is larger than the length of the
1551 string, the string is truncated at position \a index. 1587 string, the string is truncated at position \a index.
1552 1588
1553 \code 1589 \code
1554 QCString s = "Montreal"; 1590 QCString s = "Montreal";
1555 s.remove( 1, 4 ); // s == "Meal" 1591 s.remove( 1, 4 ); // s == "Meal"
1556 \endcode 1592 \endcode
1557 1593
1558 \sa insert(), replace() 1594 \sa insert(), replace()
1559*/ 1595*/
1560 1596
1561QCString &QCString::remove( uint index, uint len ) 1597QCString &QCString::remove( uint index, uint len )
1562{ 1598{
1563 uint olen = length(); 1599 uint olen = length();
1564 if ( index + len >= olen ) { // range problems 1600 if ( index + len >= olen ) { // range problems
1565 if ( index < olen ) { // index ok 1601 if ( index < olen ) { // index ok
1566 detach(); 1602 detach();
1567 resize( index+1 ); 1603 resize( index+1 );
1568 } 1604 }
1569 } else if ( len != 0 ) { 1605 } else if ( len != 0 ) {
1570 detach(); 1606 detach();
1571 memmove( data()+index, data()+index+len, olen-index-len+1 ); 1607 memmove( data()+index, data()+index+len, olen-index-len+1 );
1572 QByteArray::resize(olen-len+1); 1608 QByteArray::resize(olen-len+1, QByteArray::SpeedOptim );
1573 } 1609 }
1574 return *this; 1610 return *this;
1575} 1611}
1576 1612
1577/*! 1613/*!
1578 Replaces \a len characters from the string, starting at position 1614 Replaces \a len characters from the string, starting at position
1579 \a index, with \a str, and returns a reference to the string. 1615 \a index, with \a str, and returns a reference to the string.
1580 1616
1581 If \a index is out of range, nothing is removed and \a str is 1617 If \a index is out of range, nothing is removed and \a str is
1582 appended at the end of the string. If \a index is valid, but \a 1618 appended at the end of the string. If \a index is valid, but \a
1583 index + \a len is larger than the length of the string, \a str 1619 index + \a len is larger than the length of the string, \a str
1584 replaces the rest of the string from position \a index. 1620 replaces the rest of the string from position \a index.
1585 1621
1586 \code 1622 \code
1587 QCString s = "Say yes!"; 1623 QCString s = "Say yes!";
1588 s.replace( 4, 3, "NO" ); // s == "Say NO!" 1624 s.replace( 4, 3, "NO" ); // s == "Say NO!"
1589 \endcode 1625 \endcode
1590 1626
1591 \sa insert(), remove() 1627 \sa insert(), remove()
1592*/ 1628*/
1593 1629
1594QCString &QCString::replace( uint index, uint len, const char *str ) 1630QCString &QCString::replace( uint index, uint len, const char *str )
1595{ 1631{
1596 remove( index, len ); 1632 remove( index, len );
@@ -1610,104 +1646,105 @@ QCString &QCString::replace( uint index, uint len, const char *str )
1610 s.replace( ',', " or " ); 1646 s.replace( ',', " or " );
1611 // s == "a or b or c" 1647 // s == "a or b or c"
1612 \endcode 1648 \endcode
1613*/ 1649*/
1614QCString &QCString::replace( char c, const char *after ) 1650QCString &QCString::replace( char c, const char *after )
1615{ 1651{
1616 char str[2]; 1652 char str[2];
1617 str[0] = c; 1653 str[0] = c;
1618 str[1] = '\0'; 1654 str[1] = '\0';
1619 return replace( str, after ); 1655 return replace( str, after );
1620} 1656}
1621 1657
1622/*! \overload 1658/*! \overload
1623 1659
1624 Replaces every occurrence of the string \a before in the string 1660 Replaces every occurrence of the string \a before in the string
1625 with the string \a after. Returns a reference to the string. 1661 with the string \a after. Returns a reference to the string.
1626 1662
1627 Example: 1663 Example:
1628 \code 1664 \code
1629 QCString s = "Greek is Greek"; 1665 QCString s = "Greek is Greek";
1630 s.replace( "Greek", "English" ); 1666 s.replace( "Greek", "English" );
1631 // s == "English is English" 1667 // s == "English is English"
1632 \endcode 1668 \endcode
1633*/ 1669*/
1670
1634QCString &QCString::replace( const char *before, const char *after ) 1671QCString &QCString::replace( const char *before, const char *after )
1635{ 1672{
1636 if ( before == after || isNull() ) 1673 if ( before == after || isNull() )
1637 return *this; 1674 return *this;
1638 1675
1639 detach(); 1676 detach();
1640 1677
1641 int index = 0; 1678 int index = 0;
1642 const int bl = before ? strlen( before ) : 0; 1679 const int bl = before ? strlen( before ) : 0;
1643 const int al = after ? strlen( after ) : 0; 1680 const int al = after ? strlen( after ) : 0;
1644 char *d = data(); 1681 char *d = data();
1645 uint len = length(); 1682 uint len = length();
1646 1683
1647 if ( bl == al ) { 1684 if ( bl == al ) {
1648 if ( bl ) { 1685 if ( bl ) {
1649 while( (index = find( before, index ) ) != -1 ) { 1686 while( (index = find( before, index, TRUE, len ) ) != -1 ) {
1650 memcpy( d+index, after, al ); 1687 memcpy( d+index, after, al );
1651 index += bl; 1688 index += bl;
1652 } 1689 }
1653 } 1690 }
1654 } else if ( al < bl ) { 1691 } else if ( al < bl ) {
1655 uint to = 0; 1692 uint to = 0;
1656 uint movestart = 0; 1693 uint movestart = 0;
1657 uint num = 0; 1694 uint num = 0;
1658 while( (index = find( before, index ) ) != -1 ) { 1695 while( (index = find( before, index, TRUE, len ) ) != -1 ) {
1659 if ( num ) { 1696 if ( num ) {
1660 int msize = index - movestart; 1697 int msize = index - movestart;
1661 if ( msize > 0 ) { 1698 if ( msize > 0 ) {
1662 memmove( d + to, d + movestart, msize ); 1699 memmove( d + to, d + movestart, msize );
1663 to += msize; 1700 to += msize;
1664 } 1701 }
1665 } else { 1702 } else {
1666 to = index; 1703 to = index;
1667 } 1704 }
1668 if ( al ) { 1705 if ( al ) {
1669 memcpy( d + to, after, al ); 1706 memcpy( d + to, after, al );
1670 to += al; 1707 to += al;
1671 } 1708 }
1672 index += bl; 1709 index += bl;
1673 movestart = index; 1710 movestart = index;
1674 num++; 1711 num++;
1675 } 1712 }
1676 if ( num ) { 1713 if ( num ) {
1677 int msize = len - movestart; 1714 int msize = len - movestart;
1678 if ( msize > 0 ) 1715 if ( msize > 0 )
1679 memmove( d + to, d + movestart, msize ); 1716 memmove( d + to, d + movestart, msize );
1680 resize( len - num*(bl-al) + 1 ); 1717 resize( len - num*(bl-al) + 1 );
1681 } 1718 }
1682 } else { 1719 } else {
1683 // the most complex case. We don't want to loose performance by doing repeated 1720 // the most complex case. We don't want to loose performance by doing repeated
1684 // copies and reallocs of the string. 1721 // copies and reallocs of the string.
1685 while( index != -1 ) { 1722 while( index != -1 ) {
1686 uint indices[4096]; 1723 uint indices[4096];
1687 uint pos = 0; 1724 uint pos = 0;
1688 while( pos < 4095 ) { 1725 while( pos < 4095 ) {
1689 index = find(before, index); 1726 index = find(before, index, TRUE, len);
1690 if ( index == -1 ) 1727 if ( index == -1 )
1691 break; 1728 break;
1692 indices[pos++] = index; 1729 indices[pos++] = index;
1693 index += bl; 1730 index += bl;
1694 // avoid infinite loop 1731 // avoid infinite loop
1695 if ( !bl ) 1732 if ( !bl )
1696 index++; 1733 index++;
1697 } 1734 }
1698 if ( !pos ) 1735 if ( !pos )
1699 break; 1736 break;
1700 1737
1701 // we have a table of replacement positions, use them for fast replacing 1738 // we have a table of replacement positions, use them for fast replacing
1702 int adjust = pos*(al-bl); 1739 int adjust = pos*(al-bl);
1703 // index has to be adjusted in case we get back into the loop above. 1740 // index has to be adjusted in case we get back into the loop above.
1704 if ( index != -1 ) 1741 if ( index != -1 )
1705 index += adjust; 1742 index += adjust;
1706 uint newlen = len + adjust; 1743 uint newlen = len + adjust;
1707 int moveend = len; 1744 int moveend = len;
1708 if ( newlen > len ) { 1745 if ( newlen > len ) {
1709 resize( newlen + 1 ); 1746 resize( newlen + 1 );
1710 len = newlen; 1747 len = newlen;
1711 } 1748 }
1712 d = data(); 1749 d = data();
1713 1750
@@ -1742,125 +1779,125 @@ QCString &QCString::replace( char c1, char c2 )
1742 d[i] = c2; 1779 d[i] = c2;
1743 i++; 1780 i++;
1744 } 1781 }
1745 return *this; 1782 return *this;
1746} 1783}
1747 1784
1748 1785
1749#ifndef QT_NO_REGEXP_CAPTURE 1786#ifndef QT_NO_REGEXP_CAPTURE
1750/*! 1787/*!
1751 \overload 1788 \overload
1752 1789
1753 Finds the first occurrence of the regular expression \a rx, 1790 Finds the first occurrence of the regular expression \a rx,
1754 starting at position \a index. 1791 starting at position \a index.
1755 1792
1756 Returns the position of the next match, or -1 if \a rx was not 1793 Returns the position of the next match, or -1 if \a rx was not
1757 found. 1794 found.
1758 1795
1759 \warning If you want to apply this function repeatedly to the same 1796 \warning If you want to apply this function repeatedly to the same
1760 string it is more efficient to convert the string to a QString and 1797 string it is more efficient to convert the string to a QString and
1761 apply the function to that. 1798 apply the function to that.
1762*/ 1799*/
1763 1800
1764int QCString::find( const QRegExp& rx, int index ) const 1801int QCString::find( const QRegExp& rx, int index ) const
1765{ 1802{
1766 QString d = QString::fromLatin1( data() ); 1803 QString d = QString::fromAscii( data() );
1767 return d.find( rx, index ); 1804 return d.find( rx, index );
1768} 1805}
1769 1806
1770/*! 1807/*!
1771 \overload 1808 \overload
1772 1809
1773 Finds the first occurrence of the regular expression \a rx, 1810 Finds the first occurrence of the regular expression \a rx,
1774 starting at position \a index and searching backwards. 1811 starting at position \a index and searching backwards.
1775 1812
1776 Returns the position of the next match (backwards), or -1 if \a rx 1813 Returns the position of the next match (backwards), or -1 if \a rx
1777 was not found. 1814 was not found.
1778 1815
1779 \warning If you want to apply this function repeatedly to the same 1816 \warning If you want to apply this function repeatedly to the same
1780 string it is more efficient to convert the string to a QString and 1817 string it is more efficient to convert the string to a QString and
1781 apply the function to that. 1818 apply the function to that.
1782*/ 1819*/
1783 1820
1784int QCString::findRev( const QRegExp& rx, int index ) const 1821int QCString::findRev( const QRegExp& rx, int index ) const
1785{ 1822{
1786 QString d = QString::fromLatin1( data() ); 1823 QString d = QString::fromAscii( data() );
1787 return d.findRev( rx, index ); 1824 return d.findRev( rx, index );
1788} 1825}
1789 1826
1790/*! 1827/*!
1791 \overload 1828 \overload
1792 1829
1793 Counts the number of overlapping occurrences of \a rx in the string. 1830 Counts the number of overlapping occurrences of \a rx in the string.
1794 1831
1795 Example: 1832 Example:
1796 \code 1833 \code
1797 QString s = "banana and panama"; 1834 QString s = "banana and panama";
1798 QRegExp r = QRegExp( "a[nm]a", TRUE, FALSE ); 1835 QRegExp r = QRegExp( "a[nm]a", TRUE, FALSE );
1799 s.contains( r ); // 4 matches 1836 s.contains( r ); // 4 matches
1800 \endcode 1837 \endcode
1801 1838
1802 \sa find(), findRev() 1839 \sa find(), findRev()
1803 1840
1804 \warning If you want to apply this function repeatedly to the same 1841 \warning If you want to apply this function repeatedly to the same
1805 string it is more efficient to convert the string to a QString and 1842 string it is more efficient to convert the string to a QString and
1806 apply the function to that. 1843 apply the function to that.
1807*/ 1844*/
1808 1845
1809int QCString::contains( const QRegExp &rx ) const 1846int QCString::contains( const QRegExp &rx ) const
1810{ 1847{
1811 QString d = QString::fromLatin1( data() ); 1848 QString d = QString::fromAscii( data() );
1812 return d.contains( rx ); 1849 return d.contains( rx );
1813} 1850}
1814 1851
1815 1852
1816/*! 1853/*!
1817 \overload 1854 \overload
1818 1855
1819 Replaces every occurrence of \a rx in the string with \a str. 1856 Replaces every occurrence of \a rx in the string with \a str.
1820 Returns a reference to the string. 1857 Returns a reference to the string.
1821 1858
1822 Example: 1859 Example:
1823 \code 1860 \code
1824 QString s = "banana"; 1861 QString s = "banana";
1825 s.replace( QRegExp("a.*a"), "" ); // becomes "b" 1862 s.replace( QRegExp("a.*a"), "" ); // becomes "b"
1826 1863
1827 s = "banana"; 1864 s = "banana";
1828 s.replace( QRegExp("^[bn]a"), "X" ); // becomes "Xnana" 1865 s.replace( QRegExp("^[bn]a"), "X" ); // becomes "Xnana"
1829 1866
1830 s = "banana"; 1867 s = "banana";
1831 s.replace( QRegExp("^[bn]a"), "" ); // becomes "nana" 1868 s.replace( QRegExp("^[bn]a"), "" ); // becomes "nana"
1832 \endcode 1869 \endcode
1833 1870
1834 \warning If you want to apply this function repeatedly to the same 1871 \warning If you want to apply this function repeatedly to the same
1835 string it is more efficient to convert the string to a QString and 1872 string it is more efficient to convert the string to a QString and
1836 apply the function to that. 1873 apply the function to that.
1837*/ 1874*/
1838 1875
1839QCString &QCString::replace( const QRegExp &rx, const char *str ) 1876QCString &QCString::replace( const QRegExp &rx, const char *str )
1840{ 1877{
1841 QString d = QString::fromLatin1( data() ); 1878 QString d = QString::fromAscii( data() );
1842 QString r = QString::fromLatin1( str ); 1879 QString r = QString::fromAscii( str );
1843 d.replace( rx, r ); 1880 d.replace( rx, r );
1844 setStr( d.ascii() ); 1881 setStr( d.ascii() );
1845 return *this; 1882 return *this;
1846} 1883}
1847#endif //QT_NO_REGEXP 1884#endif //QT_NO_REGEXP
1848 1885
1849/*! 1886/*!
1850 Returns the string converted to a \c long value. 1887 Returns the string converted to a \c long value.
1851 1888
1852 If \a ok is not 0: \a *ok is set to FALSE if the string is not a 1889 If \a ok is not 0: \a *ok is set to FALSE if the string is not a
1853 number, or if it has trailing garbage; otherwise \a *ok is set to 1890 number, or if it has trailing garbage; otherwise \a *ok is set to
1854 TRUE. 1891 TRUE.
1855*/ 1892*/
1856 1893
1857long QCString::toLong( bool *ok ) const 1894long QCString::toLong( bool *ok ) const
1858{ 1895{
1859 char *p = data(); 1896 char *p = data();
1860 long val=0; 1897 long val=0;
1861 const long max_mult = 214748364; 1898 const long max_mult = 214748364;
1862 bool is_ok = FALSE; 1899 bool is_ok = FALSE;
1863 int neg = 0; 1900 int neg = 0;
1864 if ( !p ) 1901 if ( !p )
1865 goto bye; 1902 goto bye;
1866 while ( isspace((uchar) *p) ) // skip leading space 1903 while ( isspace((uchar) *p) ) // skip leading space
@@ -2178,65 +2215,65 @@ bool QCString::setExpand( uint index, char c )
2178 \fn QCString::operator const char *() const 2215 \fn QCString::operator const char *() const
2179 2216
2180 Returns the string data. 2217 Returns the string data.
2181*/ 2218*/
2182 2219
2183 2220
2184/*! 2221/*!
2185 \fn QCString& QCString::append( const char *str ) 2222 \fn QCString& QCString::append( const char *str )
2186 2223
2187 Appends string \a str to the string and returns a reference to the 2224 Appends string \a str to the string and returns a reference to the
2188 string. Equivalent to operator+=(). 2225 string. Equivalent to operator+=().
2189*/ 2226*/
2190 2227
2191/*! 2228/*!
2192 Appends string \a str to the string and returns a reference to the string. 2229 Appends string \a str to the string and returns a reference to the string.
2193*/ 2230*/
2194 2231
2195QCString& QCString::operator+=( const char *str ) 2232QCString& QCString::operator+=( const char *str )
2196{ 2233{
2197 if ( !str ) 2234 if ( !str )
2198 return *this; // nothing to append 2235 return *this; // nothing to append
2199 detach(); 2236 detach();
2200 uint len1 = length(); 2237 uint len1 = length();
2201 uint len2 = qstrlen(str); 2238 uint len2 = qstrlen(str);
2202 if ( !QByteArray::resize( len1 + len2 + 1 ) ) 2239 if ( !QByteArray::resize( len1 + len2 + 1, QByteArray::SpeedOptim ) )
2203 return *this; // no memory 2240 return *this; // no memory
2204 memcpy( data() + len1, str, len2 + 1 ); 2241 memcpy( data() + len1, str, len2 + 1 );
2205 return *this; 2242 return *this;
2206} 2243}
2207 2244
2208/*! 2245/*!
2209 \overload 2246 \overload
2210 2247
2211 Appends character \a c to the string and returns a reference to the string. 2248 Appends character \a c to the string and returns a reference to the string.
2212*/ 2249*/
2213 2250
2214QCString &QCString::operator+=( char c ) 2251QCString &QCString::operator+=( char c )
2215{ 2252{
2216 detach(); 2253 detach();
2217 uint len = length(); 2254 uint len = length();
2218 if ( !QByteArray::resize( len + 2 ) ) 2255 if ( !QByteArray::resize( len + 2, QByteArray::SpeedOptim ) )
2219 return *this; // no memory 2256 return *this; // no memory
2220 *(data() + len) = c; 2257 *(data() + len) = c;
2221 *(data() + len+1) = '\0'; 2258 *(data() + len+1) = '\0';
2222 return *this; 2259 return *this;
2223} 2260}
2224 2261
2225 2262
2226/***************************************************************************** 2263/*****************************************************************************
2227 QCString stream functions 2264 QCString stream functions
2228 *****************************************************************************/ 2265 *****************************************************************************/
2229#ifndef QT_NO_DATASTREAM 2266#ifndef QT_NO_DATASTREAM
2230/*! 2267/*!
2231 \relates QCString 2268 \relates QCString
2232 2269
2233 Writes string \a str to the stream \a s. 2270 Writes string \a str to the stream \a s.
2234 2271
2235 \sa \link datastreamformat.html Format of the QDataStream operators \endlink 2272 \sa \link datastreamformat.html Format of the QDataStream operators \endlink
2236*/ 2273*/
2237QDataStream &operator<<( QDataStream &s, const QCString &str ) 2274QDataStream &operator<<( QDataStream &s, const QCString &str )
2238{ 2275{
2239 return s.writeBytes( str.data(), str.size() ); 2276 return s.writeBytes( str.data(), str.size() );
2240} 2277}
2241 2278
2242/*! 2279/*!
diff --git a/qmake/tools/qdatastream.cpp b/qmake/tools/qdatastream.cpp
index 9c573c7..51a1448 100644
--- a/qmake/tools/qdatastream.cpp
+++ b/qmake/tools/qdatastream.cpp
@@ -729,50 +729,58 @@ QDataStream &QDataStream::readBytes( char *&s, uint &l )
729 } else { 729 } else {
730 s = new char[len]; // create char array 730 s = new char[len]; // create char array
731 Q_CHECK_PTR( s ); 731 Q_CHECK_PTR( s );
732 if ( !s ) // no memory 732 if ( !s ) // no memory
733 return *this; 733 return *this;
734 return readRawBytes( s, (uint)len ); 734 return readRawBytes( s, (uint)len );
735 } 735 }
736} 736}
737 737
738 738
739/*! 739/*!
740 Reads \a len bytes from the stream into \a s and returns a 740 Reads \a len bytes from the stream into \a s and returns a
741 reference to the stream. 741 reference to the stream.
742 742
743 The buffer \a s must be preallocated. The data is \e not encoded. 743 The buffer \a s must be preallocated. The data is \e not encoded.
744 744
745 \sa readBytes(), QIODevice::readBlock(), writeRawBytes() 745 \sa readBytes(), QIODevice::readBlock(), writeRawBytes()
746*/ 746*/
747 747
748QDataStream &QDataStream::readRawBytes( char *s, uint len ) 748QDataStream &QDataStream::readRawBytes( char *s, uint len )
749{ 749{
750 CHECK_STREAM_PRECOND 750 CHECK_STREAM_PRECOND
751 if ( printable ) { // printable data 751 if ( printable ) { // printable data
752 register Q_INT8 *p = (Q_INT8*)s; 752 register Q_INT8 *p = (Q_INT8*)s;
753 while ( len-- ) 753 if ( version() < 4 ) {
754 *this >> *p++; 754 while ( len-- ) {
755 Q_INT32 tmp;
756 *this >> tmp;
757 *p++ = tmp;
758 }
759 } else {
760 while ( len-- )
761 *this >> *p++;
762 }
755 } else { // read data char array 763 } else { // read data char array
756 dev->readBlock( s, len ); 764 dev->readBlock( s, len );
757 } 765 }
758 return *this; 766 return *this;
759} 767}
760 768
761 769
762/***************************************************************************** 770/*****************************************************************************
763 QDataStream write functions 771 QDataStream write functions
764 *****************************************************************************/ 772 *****************************************************************************/
765 773
766 774
767/*! 775/*!
768 \overload QDataStream &QDataStream::operator<<( Q_UINT8 i ) 776 \overload QDataStream &QDataStream::operator<<( Q_UINT8 i )
769 777
770 Writes an unsigned byte, \a i, to the stream and returns a 778 Writes an unsigned byte, \a i, to the stream and returns a
771 reference to the stream. 779 reference to the stream.
772*/ 780*/
773 781
774/*! 782/*!
775 Writes a signed byte, \a i, to the stream and returns a reference 783 Writes a signed byte, \a i, to the stream and returns a reference
776 to the stream. 784 to the stream.
777*/ 785*/
778 786
@@ -991,34 +999,40 @@ QDataStream &QDataStream::operator<<( const char *s )
991 \sa writeRawBytes(), readBytes() 999 \sa writeRawBytes(), readBytes()
992*/ 1000*/
993 1001
994QDataStream &QDataStream::writeBytes(const char *s, uint len) 1002QDataStream &QDataStream::writeBytes(const char *s, uint len)
995{ 1003{
996 CHECK_STREAM_PRECOND 1004 CHECK_STREAM_PRECOND
997 *this << (Q_UINT32)len; // write length specifier 1005 *this << (Q_UINT32)len; // write length specifier
998 if ( len ) 1006 if ( len )
999 writeRawBytes( s, len ); 1007 writeRawBytes( s, len );
1000 return *this; 1008 return *this;
1001} 1009}
1002 1010
1003 1011
1004/*! 1012/*!
1005 Writes \a len bytes from \a s to the stream and returns a 1013 Writes \a len bytes from \a s to the stream and returns a
1006 reference to the stream. The data is \e not encoded. 1014 reference to the stream. The data is \e not encoded.
1007 1015
1008 \sa writeBytes(), QIODevice::writeBlock(), readRawBytes() 1016 \sa writeBytes(), QIODevice::writeBlock(), readRawBytes()
1009*/ 1017*/
1010 1018
1011QDataStream &QDataStream::writeRawBytes( const char *s, uint len ) 1019QDataStream &QDataStream::writeRawBytes( const char *s, uint len )
1012{ 1020{
1013 CHECK_STREAM_PRECOND 1021 CHECK_STREAM_PRECOND
1014 if ( printable ) { // write printable 1022 if ( printable ) { // write printable
1015 register Q_INT8 *p = (Q_INT8*)s; 1023 if ( version() < 4 ) {
1016 while ( len-- ) 1024 register char *p = (char *)s;
1017 *this << *p++; 1025 while ( len-- )
1026 *this << *p++;
1027 } else {
1028 register Q_INT8 *p = (Q_INT8*)s;
1029 while ( len-- )
1030 *this << *p++;
1031 }
1018 } else { // write data char array 1032 } else { // write data char array
1019 dev->writeBlock( s, len ); 1033 dev->writeBlock( s, len );
1020 } 1034 }
1021 return *this; 1035 return *this;
1022} 1036}
1023 1037
1024#endif // QT_NO_DATASTREAM 1038#endif // QT_NO_DATASTREAM
diff --git a/qmake/tools/qdatetime.cpp b/qmake/tools/qdatetime.cpp
index 93e40a8..3137877 100644
--- a/qmake/tools/qdatetime.cpp
+++ b/qmake/tools/qdatetime.cpp
@@ -1,62 +1,61 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of date and time classes 4** Implementation of date and time classes
5** 5**
6** Created : 940124 6** Created : 940124
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38// Get the system specific includes and defines
39#include "qplatformdefs.h" 38#include "qplatformdefs.h"
40 39
41#include "qdatetime.h" 40#include "qdatetime.h"
42#include "qdatastream.h" 41#include "qdatastream.h"
43#include "qregexp.h" 42#include "qregexp.h"
44 43
45#include <stdio.h> 44#include <stdio.h>
46#ifndef Q_OS_TEMP 45#ifndef Q_OS_TEMP
47#include <time.h> 46#include <time.h>
48#endif 47#endif
49 48
50#if defined(Q_OS_WIN32) 49#if defined(Q_OS_WIN32)
51#include <windows.h> 50#include <windows.h>
52#endif 51#endif
53 52
54 static const uint FIRST_DAY = 2361222;// Julian day for 1752-09-14 53 static const uint FIRST_DAY = 2361222;// Julian day for 1752-09-14
55 static const int FIRST_YEAR = 1752; // ### wrong for many countries 54 static const int FIRST_YEAR = 1752; // ### wrong for many countries
56 static const uint SECS_PER_DAY= 86400; 55 static const uint SECS_PER_DAY= 86400;
57static const uint MSECS_PER_DAY = 86400000; 56static const uint MSECS_PER_DAY = 86400000;
58static const uint SECS_PER_HOUR = 3600; 57static const uint SECS_PER_HOUR = 3600;
59static const uint MSECS_PER_HOUR= 3600000; 58static const uint MSECS_PER_HOUR= 3600000;
60 static const uint SECS_PER_MIN= 60; 59 static const uint SECS_PER_MIN= 60;
61static const uint MSECS_PER_MIN = 60000; 60static const uint MSECS_PER_MIN = 60000;
62 61
@@ -874,48 +873,54 @@ QDate QDate::addMonths( int nmonths ) const
874 } 873 }
875 874
876 QDate tmp(y,m,1); 875 QDate tmp(y,m,1);
877 876
878 if( d > tmp.daysInMonth() ) 877 if( d > tmp.daysInMonth() )
879 d = tmp.daysInMonth(); 878 d = tmp.daysInMonth();
880 879
881 QDate date(y, m, d); 880 QDate date(y, m, d);
882 return date; 881 return date;
883 882
884} 883}
885 884
886/*! 885/*!
887 Returns a QDate object containing a date \a nyears later than the 886 Returns a QDate object containing a date \a nyears later than the
888 date of this object (or earlier if \a nyears is negative). 887 date of this object (or earlier if \a nyears is negative).
889 888
890 \sa addDays(), addMonths() 889 \sa addDays(), addMonths()
891*/ 890*/
892 891
893QDate QDate::addYears( int nyears ) const 892QDate QDate::addYears( int nyears ) const
894{ 893{
895 int y, m, d; 894 int y, m, d;
896 julianToGregorian( jd, y, m, d ); 895 julianToGregorian( jd, y, m, d );
897 y += nyears; 896 y += nyears;
897
898 QDate tmp(y,m,1);
899
900 if( d > tmp.daysInMonth() )
901 d = tmp.daysInMonth();
902
898 QDate date(y, m, d); 903 QDate date(y, m, d);
899 return date; 904 return date;
900} 905}
901 906
902 907
903 908
904/*! 909/*!
905 Returns the number of days from this date to \a d (which is 910 Returns the number of days from this date to \a d (which is
906 negative if \a d is earlier than this date). 911 negative if \a d is earlier than this date).
907 912
908 Example: 913 Example:
909 \code 914 \code
910 QDate d1( 1995, 5, 17 ); // May 17th 1995 915 QDate d1( 1995, 5, 17 ); // May 17th 1995
911 QDate d2( 1995, 5, 20 ); // May 20th 1995 916 QDate d2( 1995, 5, 20 ); // May 20th 1995
912 d1.daysTo( d2 ); // returns 3 917 d1.daysTo( d2 ); // returns 3
913 d2.daysTo( d1 ); // returns -3 918 d2.daysTo( d1 ); // returns -3
914 \endcode 919 \endcode
915 920
916 \sa addDays() 921 \sa addDays()
917*/ 922*/
918 923
919int QDate::daysTo( const QDate &d ) const 924int QDate::daysTo( const QDate &d ) const
920{ 925{
921 return d.jd - jd; 926 return d.jd - jd;
@@ -969,55 +974,67 @@ int QDate::daysTo( const QDate &d ) const
969 974
970QDate QDate::currentDate() 975QDate QDate::currentDate()
971{ 976{
972 return currentDate( Qt::LocalTime ); 977 return currentDate( Qt::LocalTime );
973} 978}
974 979
975/*! 980/*!
976 Returns the current date, as reported by the system clock, for the 981 Returns the current date, as reported by the system clock, for the
977 TimeSpec \a ts. The default TimeSpec is LocalTime. 982 TimeSpec \a ts. The default TimeSpec is LocalTime.
978 983
979 \sa QTime::currentTime(), QDateTime::currentDateTime(), Qt::TimeSpec 984 \sa QTime::currentTime(), QDateTime::currentDateTime(), Qt::TimeSpec
980*/ 985*/
981QDate QDate::currentDate( Qt::TimeSpec ts ) 986QDate QDate::currentDate( Qt::TimeSpec ts )
982{ 987{
983 QDate d; 988 QDate d;
984#if defined(Q_OS_WIN32) 989#if defined(Q_OS_WIN32)
985 SYSTEMTIME t; 990 SYSTEMTIME t;
986 memset( &t, 0, sizeof(SYSTEMTIME) ); 991 memset( &t, 0, sizeof(SYSTEMTIME) );
987 if ( ts == Qt::LocalTime ) 992 if ( ts == Qt::LocalTime )
988 GetLocalTime( &t ); 993 GetLocalTime( &t );
989 else 994 else
990 GetSystemTime( &t ); 995 GetSystemTime( &t );
991 d.jd = gregorianToJulian( t.wYear, t.wMonth, t.wDay ); 996 d.jd = gregorianToJulian( t.wYear, t.wMonth, t.wDay );
992#else 997#else
998 // posix compliant system
993 time_t ltime; 999 time_t ltime;
994 time( &ltime ); 1000 time( &ltime );
995 tm *t; 1001 tm *t;
1002
1003# if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
1004 // use the reentrant versions of localtime() and gmtime() where available
1005 tm res;
1006 if ( ts == Qt::LocalTime )
1007 t = localtime_r( &ltime, &res );
1008 else
1009 t = gmtime_r( &ltime, &res );
1010# else
996 if ( ts == Qt::LocalTime ) 1011 if ( ts == Qt::LocalTime )
997 t = localtime( &ltime ); 1012 t = localtime( &ltime );
998 else 1013 else
999 t = gmtime( &ltime ); 1014 t = gmtime( &ltime );
1015# endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS
1016
1000 d.jd = gregorianToJulian( t->tm_year + 1900, t->tm_mon + 1, t->tm_mday ); 1017 d.jd = gregorianToJulian( t->tm_year + 1900, t->tm_mon + 1, t->tm_mday );
1001#endif 1018#endif
1002 return d; 1019 return d;
1003} 1020}
1004 1021
1005#ifndef QT_NO_DATESTRING 1022#ifndef QT_NO_DATESTRING
1006/*! 1023/*!
1007 Returns the QDate represented by the string \a s, using the format 1024 Returns the QDate represented by the string \a s, using the format
1008 \a f, or an invalid date if the string cannot be parsed. 1025 \a f, or an invalid date if the string cannot be parsed.
1009 1026
1010 Note for \c Qt::TextDate: It is recommended that you use the 1027 Note for \c Qt::TextDate: It is recommended that you use the
1011 English short month names (e.g. "Jan"). Although localized month 1028 English short month names (e.g. "Jan"). Although localized month
1012 names can also be used, they depend on the user's locale settings. 1029 names can also be used, they depend on the user's locale settings.
1013 1030
1014 \warning \c Qt::LocalDate cannot be used here. 1031 \warning \c Qt::LocalDate cannot be used here.
1015*/ 1032*/
1016QDate QDate::fromString( const QString& s, Qt::DateFormat f ) 1033QDate QDate::fromString( const QString& s, Qt::DateFormat f )
1017{ 1034{
1018 if ( ( s.isEmpty() ) || ( f == Qt::LocalDate ) ) { 1035 if ( ( s.isEmpty() ) || ( f == Qt::LocalDate ) ) {
1019#if defined(QT_CHECK_RANGE) 1036#if defined(QT_CHECK_RANGE)
1020 qWarning( "QDate::fromString: Parameter out of range." ); 1037 qWarning( "QDate::fromString: Parameter out of range." );
1021#endif 1038#endif
1022 return QDate(); 1039 return QDate();
1023 } 1040 }
@@ -1534,49 +1551,49 @@ int QTime::msecsTo( const QTime &t ) const
1534*/ 1551*/
1535 1552
1536/*! 1553/*!
1537 \fn bool QTime::operator<=( const QTime &t ) const 1554 \fn bool QTime::operator<=( const QTime &t ) const
1538 1555
1539 Returns TRUE if this time is earlier than or equal to \a t; 1556 Returns TRUE if this time is earlier than or equal to \a t;
1540 otherwise returns FALSE. 1557 otherwise returns FALSE.
1541*/ 1558*/
1542 1559
1543/*! 1560/*!
1544 \fn bool QTime::operator>( const QTime &t ) const 1561 \fn bool QTime::operator>( const QTime &t ) const
1545 1562
1546 Returns TRUE if this time is later than \a t; otherwise returns FALSE. 1563 Returns TRUE if this time is later than \a t; otherwise returns FALSE.
1547*/ 1564*/
1548 1565
1549/*! 1566/*!
1550 \fn bool QTime::operator>=( const QTime &t ) const 1567 \fn bool QTime::operator>=( const QTime &t ) const
1551 1568
1552 Returns TRUE if this time is later than or equal to \a t; 1569 Returns TRUE if this time is later than or equal to \a t;
1553 otherwise returns FALSE. 1570 otherwise returns FALSE.
1554*/ 1571*/
1555 1572
1556 1573
1557 1574
1558/*! 1575/*!
1559 \overload 1576 \overload
1560 1577
1561 Returns the current time as reported by the system clock. 1578 Returns the current time as reported by the system clock.
1562 1579
1563 Note that the accuracy depends on the accuracy of the underlying 1580 Note that the accuracy depends on the accuracy of the underlying
1564 operating system; not all systems provide 1-millisecond accuracy. 1581 operating system; not all systems provide 1-millisecond accuracy.
1565*/ 1582*/
1566 1583
1567QTime QTime::currentTime() 1584QTime QTime::currentTime()
1568{ 1585{
1569 return currentTime( Qt::LocalTime ); 1586 return currentTime( Qt::LocalTime );
1570} 1587}
1571 1588
1572/*! 1589/*!
1573 Returns the current time as reported by the system clock, for the 1590 Returns the current time as reported by the system clock, for the
1574 TimeSpec \a ts. The default TimeSpec is LocalTime. 1591 TimeSpec \a ts. The default TimeSpec is LocalTime.
1575 1592
1576 Note that the accuracy depends on the accuracy of the underlying 1593 Note that the accuracy depends on the accuracy of the underlying
1577 operating system; not all systems provide 1-millisecond accuracy. 1594 operating system; not all systems provide 1-millisecond accuracy.
1578 1595
1579 \sa Qt::TimeSpec 1596 \sa Qt::TimeSpec
1580*/ 1597*/
1581QTime QTime::currentTime( Qt::TimeSpec ts ) 1598QTime QTime::currentTime( Qt::TimeSpec ts )
1582{ 1599{
@@ -1632,104 +1649,115 @@ bool QTime::currentTime( QTime *ct )
1632 return value is used by QDateTime::currentDateTime() to ensure that 1649 return value is used by QDateTime::currentDateTime() to ensure that
1633 the date there is correct. The default TimeSpec is LocalTime. 1650 the date there is correct. The default TimeSpec is LocalTime.
1634 1651
1635 \sa Qt::TimeSpec 1652 \sa Qt::TimeSpec
1636*/ 1653*/
1637bool QTime::currentTime( QTime *ct, Qt::TimeSpec ts ) 1654bool QTime::currentTime( QTime *ct, Qt::TimeSpec ts )
1638{ 1655{
1639 if ( !ct ) { 1656 if ( !ct ) {
1640#if defined(QT_CHECK_NULL) 1657#if defined(QT_CHECK_NULL)
1641 qWarning( "QTime::currentTime(QTime *): Null pointer not allowed" ); 1658 qWarning( "QTime::currentTime(QTime *): Null pointer not allowed" );
1642#endif 1659#endif
1643 return FALSE; 1660 return FALSE;
1644 } 1661 }
1645 1662
1646#if defined(Q_OS_WIN32) 1663#if defined(Q_OS_WIN32)
1647 SYSTEMTIME t; 1664 SYSTEMTIME t;
1648 if ( ts == Qt::LocalTime ) { 1665 if ( ts == Qt::LocalTime ) {
1649 GetLocalTime( &t ); 1666 GetLocalTime( &t );
1650 } else { 1667 } else {
1651 GetSystemTime( &t ); 1668 GetSystemTime( &t );
1652 } 1669 }
1653 ct->ds = (uint)( MSECS_PER_HOUR*t.wHour + MSECS_PER_MIN*t.wMinute + 1670 ct->ds = (uint)( MSECS_PER_HOUR*t.wHour + MSECS_PER_MIN*t.wMinute +
1654 1000*t.wSecond + t.wMilliseconds ); 1671 1000*t.wSecond + t.wMilliseconds );
1655#elif defined(Q_OS_UNIX) 1672#elif defined(Q_OS_UNIX)
1673 // posix compliant system
1656 struct timeval tv; 1674 struct timeval tv;
1657 gettimeofday( &tv, 0 ); 1675 gettimeofday( &tv, 0 );
1658 time_t ltime = tv.tv_sec; 1676 time_t ltime = tv.tv_sec;
1659 tm *t; 1677 tm *t;
1660 if ( ts == Qt::LocalTime ) { 1678
1679# if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
1680 // use the reentrant versions of localtime() and gmtime() where available
1681 tm res;
1682 if ( ts == Qt::LocalTime )
1683 t = localtime_r( &ltime, &res );
1684 else
1685 t = gmtime_r( &ltime, &res );
1686# else
1687 if ( ts == Qt::LocalTime )
1661 t = localtime( &ltime ); 1688 t = localtime( &ltime );
1662 } else { 1689 else
1663 t = gmtime( &ltime ); 1690 t = gmtime( &ltime );
1664 } 1691# endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS
1692
1665 ct->ds = (uint)( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1693 ct->ds = (uint)( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min +
1666 1000 * t->tm_sec + tv.tv_usec / 1000 ); 1694 1000 * t->tm_sec + tv.tv_usec / 1000 );
1667#else 1695#else
1668 time_t ltime; // no millisecond resolution 1696 time_t ltime; // no millisecond resolution
1669 ::time( &ltime ); 1697 ::time( &ltime );
1670 tm *t; 1698 tm *t;
1671 if ( ts == Qt::LocalTime ) 1699 if ( ts == Qt::LocalTime )
1672 localtime( &ltime ); 1700 localtime( &ltime );
1673 else 1701 else
1674 gmtime( &ltime ); 1702 gmtime( &ltime );
1675 ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1703 ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min +
1676 1000 * t->tm_sec ); 1704 1000 * t->tm_sec );
1677#endif 1705#endif
1678 // 00:00.00 to 00:00.59.999 is considered as "midnight or right after" 1706 // 00:00.00 to 00:00.59.999 is considered as "midnight or right after"
1679 return ct->ds < (uint) MSECS_PER_MIN; 1707 return ct->ds < (uint) MSECS_PER_MIN;
1680} 1708}
1681 1709
1682/*! 1710/*!
1683 \overload 1711 \overload
1684 1712
1685 Returns TRUE if the specified time is valid; otherwise returns 1713 Returns TRUE if the specified time is valid; otherwise returns
1686 FALSE. 1714 FALSE.
1687 1715
1688 The time is valid if \a h is in the range 0..23, \a m and \a s are 1716 The time is valid if \a h is in the range 0..23, \a m and \a s are
1689 in the range 0..59, and \a ms is in the range 0..999. 1717 in the range 0..59, and \a ms is in the range 0..999.
1690 1718
1691 Example: 1719 Example:
1692 \code 1720 \code
1693 QTime::isValid(21, 10, 30); // returns TRUE 1721 QTime::isValid(21, 10, 30); // returns TRUE
1694 QTime::isValid(22, 5, 62); // returns FALSE 1722 QTime::isValid(22, 5, 62); // returns FALSE
1695 \endcode 1723 \endcode
1696*/ 1724*/
1697 1725
1698bool QTime::isValid( int h, int m, int s, int ms ) 1726bool QTime::isValid( int h, int m, int s, int ms )
1699{ 1727{
1700 return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000; 1728 return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
1701} 1729}
1702 1730
1703 1731
1704/*! 1732/*!
1705 Sets this time to the current time. This is practical for timing: 1733 Sets this time to the current time. This is practical for timing:
1706 1734
1707 \code 1735 \code
1708 QTime t; 1736 QTime t;
1709 t.start(); // start clock 1737 t.start();
1710 ... // some lengthy task 1738 some_lengthy_task();
1711 qDebug( "%d\n", t.elapsed() ); // prints the number of msecs elapsed 1739 qDebug( "Time elapsed: %d ms", t.elapsed() );
1712 \endcode 1740 \endcode
1713 1741
1714 \sa restart(), elapsed(), currentTime() 1742 \sa restart(), elapsed(), currentTime()
1715*/ 1743*/
1716 1744
1717void QTime::start() 1745void QTime::start()
1718{ 1746{
1719 *this = currentTime(); 1747 *this = currentTime();
1720} 1748}
1721 1749
1722/*! 1750/*!
1723 Sets this time to the current time and returns the number of 1751 Sets this time to the current time and returns the number of
1724 milliseconds that have elapsed since the last time start() or 1752 milliseconds that have elapsed since the last time start() or
1725 restart() was called. 1753 restart() was called.
1726 1754
1727 This function is guaranteed to be atomic and is thus very handy 1755 This function is guaranteed to be atomic and is thus very handy
1728 for repeated measurements. Call start() to start the first 1756 for repeated measurements. Call start() to start the first
1729 measurement and then restart() for each later measurement. 1757 measurement and then restart() for each later measurement.
1730 1758
1731 Note that the counter wraps to zero 24 hours after the last call 1759 Note that the counter wraps to zero 24 hours after the last call
1732 to start() or restart(). 1760 to start() or restart().
1733 1761
1734 \warning If the system's clock setting has been changed since the 1762 \warning If the system's clock setting has been changed since the
1735 last time start() or restart() was called, the result is 1763 last time start() or restart() was called, the result is
@@ -1939,58 +1967,76 @@ uint QDateTime::toTime_t() const
1939 based on the given UTC time. 1967 based on the given UTC time.
1940*/ 1968*/
1941 1969
1942void QDateTime::setTime_t( uint secsSince1Jan1970UTC ) 1970void QDateTime::setTime_t( uint secsSince1Jan1970UTC )
1943{ 1971{
1944 setTime_t( secsSince1Jan1970UTC, Qt::LocalTime ); 1972 setTime_t( secsSince1Jan1970UTC, Qt::LocalTime );
1945} 1973}
1946 1974
1947/*! 1975/*!
1948 Sets the date and time to \a ts time (\c Qt::LocalTime or \c 1976 Sets the date and time to \a ts time (\c Qt::LocalTime or \c
1949 Qt::UTC) given the number of seconds that have passed since 1977 Qt::UTC) given the number of seconds that have passed since
1950 1970-01-01T00:00:00, Coordinated Universal Time (UTC). On systems 1978 1970-01-01T00:00:00, Coordinated Universal Time (UTC). On systems
1951 that do not support timezones this function will behave as if 1979 that do not support timezones this function will behave as if
1952 local time were UTC. 1980 local time were UTC.
1953 1981
1954 On Windows, only a subset of \a secsSince1Jan1970UTC values are 1982 On Windows, only a subset of \a secsSince1Jan1970UTC values are
1955 supported, as Windows starts counting from 1980. 1983 supported, as Windows starts counting from 1980.
1956 1984
1957 \sa toTime_t() 1985 \sa toTime_t()
1958*/ 1986*/
1959void QDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts ) 1987void QDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
1960{ 1988{
1961 time_t tmp = (time_t) secsSince1Jan1970UTC; 1989 time_t tmp = (time_t) secsSince1Jan1970UTC;
1962 tm *brokenDown = 0; 1990 tm *brokenDown = 0;
1991
1992#if defined(Q_OS_UNIX) && defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
1993 // posix compliant system
1994 // use the reentrant versions of localtime() and gmtime() where available
1995 tm res;
1996 if ( ts == Qt::LocalTime )
1997 brokenDown = localtime_r( &tmp, &res );
1998 if ( !brokenDown ) {
1999 brokenDown = gmtime_r( &tmp, &res );
2000 if ( !brokenDown ) {
2001 d.jd = QDate::gregorianToJulian( 1970, 1, 1 );
2002 t.ds = 0;
2003 return;
2004 }
2005 }
2006#else
1963 if ( ts == Qt::LocalTime ) 2007 if ( ts == Qt::LocalTime )
1964 brokenDown = localtime( &tmp ); 2008 brokenDown = localtime( &tmp );
1965 if ( !brokenDown ) { 2009 if ( !brokenDown ) {
1966 brokenDown = gmtime( &tmp ); 2010 brokenDown = gmtime( &tmp );
1967 if ( !brokenDown ) { 2011 if ( !brokenDown ) {
1968 d.jd = QDate::gregorianToJulian( 1970, 1, 1 ); 2012 d.jd = QDate::gregorianToJulian( 1970, 1, 1 );
1969 t.ds = 0; 2013 t.ds = 0;
1970 return; 2014 return;
1971 } 2015 }
1972 } 2016 }
2017#endif
2018
1973 d.jd = QDate::gregorianToJulian( brokenDown->tm_year + 1900, 2019 d.jd = QDate::gregorianToJulian( brokenDown->tm_year + 1900,
1974 brokenDown->tm_mon + 1, 2020 brokenDown->tm_mon + 1,
1975 brokenDown->tm_mday ); 2021 brokenDown->tm_mday );
1976 t.ds = MSECS_PER_HOUR * brokenDown->tm_hour + 2022 t.ds = MSECS_PER_HOUR * brokenDown->tm_hour +
1977 MSECS_PER_MIN * brokenDown->tm_min + 2023 MSECS_PER_MIN * brokenDown->tm_min +
1978 1000 * brokenDown->tm_sec; 2024 1000 * brokenDown->tm_sec;
1979} 2025}
1980#ifndef QT_NO_DATESTRING 2026#ifndef QT_NO_DATESTRING
1981#ifndef QT_NO_SPRINTF 2027#ifndef QT_NO_SPRINTF
1982/*! 2028/*!
1983 \overload 2029 \overload
1984 2030
1985 Returns the datetime as a string. The \a f parameter determines 2031 Returns the datetime as a string. The \a f parameter determines
1986 the format of the string. 2032 the format of the string.
1987 2033
1988 If \a f is \c Qt::TextDate, the string format is "Wed May 20 2034 If \a f is \c Qt::TextDate, the string format is "Wed May 20
1989 03:40:13 1998" (using QDate::shortDayName(), QDate::shortMonthName(), 2035 03:40:13 1998" (using QDate::shortDayName(), QDate::shortMonthName(),
1990 and QTime::toString() to generate the string, so the day and month 2036 and QTime::toString() to generate the string, so the day and month
1991 names will have localized names). 2037 names will have localized names).
1992 2038
1993 If \a f is \c Qt::ISODate, the string format corresponds to the 2039 If \a f is \c Qt::ISODate, the string format corresponds to the
1994 ISO 8601 extended specification for representations of dates and 2040 ISO 8601 extended specification for representations of dates and
1995 times, which is YYYY-MM-DDTHH:MM:SS. 2041 times, which is YYYY-MM-DDTHH:MM:SS.
1996 2042
@@ -2279,49 +2325,49 @@ bool QDateTime::operator<=( const QDateTime &dt ) const
2279 returns FALSE. 2325 returns FALSE.
2280*/ 2326*/
2281 2327
2282bool QDateTime::operator>( const QDateTime &dt ) const 2328bool QDateTime::operator>( const QDateTime &dt ) const
2283{ 2329{
2284 if ( d > dt.d ) 2330 if ( d > dt.d )
2285 return TRUE; 2331 return TRUE;
2286 return d == dt.d ? t > dt.t : FALSE; 2332 return d == dt.d ? t > dt.t : FALSE;
2287} 2333}
2288 2334
2289/*! 2335/*!
2290 Returns TRUE if this datetime is later than or equal to \a dt; 2336 Returns TRUE if this datetime is later than or equal to \a dt;
2291 otherwise returns FALSE. 2337 otherwise returns FALSE.
2292*/ 2338*/
2293 2339
2294bool QDateTime::operator>=( const QDateTime &dt ) const 2340bool QDateTime::operator>=( const QDateTime &dt ) const
2295{ 2341{
2296 if ( d > dt.d ) 2342 if ( d > dt.d )
2297 return TRUE; 2343 return TRUE;
2298 return d == dt.d ? t >= dt.t : FALSE; 2344 return d == dt.d ? t >= dt.t : FALSE;
2299} 2345}
2300 2346
2301/*! 2347/*!
2302 \overload 2348 \overload
2303 2349
2304 Returns the current datetime, as reported by the system clock. 2350 Returns the current datetime, as reported by the system clock.
2305 2351
2306 \sa QDate::currentDate(), QTime::currentTime() 2352 \sa QDate::currentDate(), QTime::currentTime()
2307*/ 2353*/
2308 2354
2309QDateTime QDateTime::currentDateTime() 2355QDateTime QDateTime::currentDateTime()
2310{ 2356{
2311 return currentDateTime( Qt::LocalTime ); 2357 return currentDateTime( Qt::LocalTime );
2312} 2358}
2313 2359
2314/*! 2360/*!
2315 Returns the current datetime, as reported by the system clock, for the 2361 Returns the current datetime, as reported by the system clock, for the
2316 TimeSpec \a ts. The default TimeSpec is LocalTime. 2362 TimeSpec \a ts. The default TimeSpec is LocalTime.
2317 2363
2318 \sa QDate::currentDate(), QTime::currentTime(), Qt::TimeSpec 2364 \sa QDate::currentDate(), QTime::currentTime(), Qt::TimeSpec
2319*/ 2365*/
2320 2366
2321QDateTime QDateTime::currentDateTime( Qt::TimeSpec ts ) 2367QDateTime QDateTime::currentDateTime( Qt::TimeSpec ts )
2322{ 2368{
2323 QDateTime dt; 2369 QDateTime dt;
2324 QTime t; 2370 QTime t;
2325 dt.setDate( QDate::currentDate(ts) ); 2371 dt.setDate( QDate::currentDate(ts) );
2326 if ( QTime::currentTime(&t, ts) ) // midnight or right after? 2372 if ( QTime::currentTime(&t, ts) ) // midnight or right after?
2327 dt.setDate( QDate::currentDate(ts) ); // fetch date again 2373 dt.setDate( QDate::currentDate(ts) ); // fetch date again
diff --git a/qmake/tools/qdir.cpp b/qmake/tools/qdir.cpp
index 418ea49..5714878 100644
--- a/qmake/tools/qdir.cpp
+++ b/qmake/tools/qdir.cpp
@@ -1,76 +1,81 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QDir class 4** Implementation of QDir class
5** 5**
6** Created : 950427 6** Created : 950427
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qplatformdefs.h" 38#include "qplatformdefs.h"
39#include "qdir.h" 39#include "qdir.h"
40 40
41#ifndef QT_NO_DIR 41#ifndef QT_NO_DIR
42#include <private/qdir_p.h> 42#include <private/qdir_p.h>
43#include "qfileinfo.h" 43#include "qfileinfo.h"
44#include "qregexp.h" 44#include "qregexp.h"
45#include "qstringlist.h" 45#include "qstringlist.h"
46#include <stdlib.h> 46#include <limits.h>
47#include <ctype.h>
48 47
48#if defined(Q_FS_FAT) && !defined(Q_OS_UNIX)
49const bool CaseSensitiveFS = FALSE;
50#else
51const bool CaseSensitiveFS = TRUE;
52#endif
49 53
50 54
51/*! 55/*!
52 \class QDir 56 \class QDir
57 \reentrant
53 \brief The QDir class provides access to directory structures and their contents in a platform-independent way. 58 \brief The QDir class provides access to directory structures and their contents in a platform-independent way.
54 59
55 \ingroup io 60 \ingroup io
56 \mainclass 61 \mainclass
57 62
58 A QDir is used to manipulate path names, access information 63 A QDir is used to manipulate path names, access information
59 regarding paths and files, and manipulate the underlying file 64 regarding paths and files, and manipulate the underlying file
60 system. 65 system.
61 66
62 A QDir can point to a file using either a relative or an absolute 67 A QDir can point to a file using either a relative or an absolute
63 path. Absolute paths begin with the directory separator "/" 68 path. Absolute paths begin with the directory separator "/"
64 (optionally preceded by a drive specification under Windows). If 69 (optionally preceded by a drive specification under Windows). If
65 you always use "/" as a directory separator, Qt will translate 70 you always use "/" as a directory separator, Qt will translate
66 your paths to conform to the underlying operating system. Relative 71 your paths to conform to the underlying operating system. Relative
67 file names begin with a directory name or a file name and specify 72 file names begin with a directory name or a file name and specify
68 a path relative to the current directory. 73 a path relative to the current directory.
69 74
70 The "current" path refers to the application's working directory. 75 The "current" path refers to the application's working directory.
71 A QDir's own path is set and retrieved with setPath() and path(). 76 A QDir's own path is set and retrieved with setPath() and path().
72 77
73 An example of an absolute path is the string "/tmp/quartz", a 78 An example of an absolute path is the string "/tmp/quartz", a
74 relative path might look like "src/fatlib". You can use the 79 relative path might look like "src/fatlib". You can use the
75 function isRelative() to check if a QDir is using a relative or an 80 function isRelative() to check if a QDir is using a relative or an
76 absolute file path. Call convertToAbs() to convert a relative QDir 81 absolute file path. Call convertToAbs() to convert a relative QDir
@@ -209,48 +214,56 @@ QDir::QDir( const QString &path, const QString &nameFilter,
209 if ( nameFilt.isEmpty() ) 214 if ( nameFilt.isEmpty() )
210 nameFilt = QString::fromLatin1("*"); 215 nameFilt = QString::fromLatin1("*");
211 filtS = (FilterSpec)filterSpec; 216 filtS = (FilterSpec)filterSpec;
212 sortS = (SortSpec)sortSpec; 217 sortS = (SortSpec)sortSpec;
213} 218}
214 219
215/*! 220/*!
216 Constructs a QDir that is a copy of the directory \a d. 221 Constructs a QDir that is a copy of the directory \a d.
217 222
218 \sa operator=() 223 \sa operator=()
219*/ 224*/
220 225
221QDir::QDir( const QDir &d ) 226QDir::QDir( const QDir &d )
222{ 227{
223 dPath = d.dPath; 228 dPath = d.dPath;
224 fList = 0; 229 fList = 0;
225 fiList = 0; 230 fiList = 0;
226 nameFilt = d.nameFilt; 231 nameFilt = d.nameFilt;
227 dirty = TRUE; 232 dirty = TRUE;
228 allDirs = d.allDirs; 233 allDirs = d.allDirs;
229 filtS = d.filtS; 234 filtS = d.filtS;
230 sortS = d.sortS; 235 sortS = d.sortS;
231} 236}
232 237
238/*!
239 Refreshes the directory information.
240*/
241void QDir::refresh() const
242{
243 QDir* that = (QDir*) this;
244 that->dirty = TRUE;
245}
233 246
234void QDir::init() 247void QDir::init()
235{ 248{
236 fList = 0; 249 fList = 0;
237 fiList = 0; 250 fiList = 0;
238 nameFilt = QString::fromLatin1("*"); 251 nameFilt = QString::fromLatin1("*");
239 dirty = TRUE; 252 dirty = TRUE;
240 allDirs = FALSE; 253 allDirs = FALSE;
241 filtS = All; 254 filtS = All;
242 sortS = SortSpec(Name | IgnoreCase); 255 sortS = SortSpec(Name | IgnoreCase);
243} 256}
244 257
245/*! 258/*!
246 Destroys the QDir frees up its resources. 259 Destroys the QDir frees up its resources.
247*/ 260*/
248 261
249QDir::~QDir() 262QDir::~QDir()
250{ 263{
251 delete fList; 264 delete fList;
252 delete fiList; 265 delete fiList;
253} 266}
254 267
255 268
256/*! 269/*!
@@ -361,52 +374,78 @@ QString QDir::filePath( const QString &fileName,
361 return tmp; 374 return tmp;
362} 375}
363 376
364/*! 377/*!
365 Returns the absolute path name of a file in the directory. Does \e 378 Returns the absolute path name of a file in the directory. Does \e
366 not check if the file actually exists in the directory. Redundant 379 not check if the file actually exists in the directory. Redundant
367 multiple separators or "." and ".." directories in \a fileName 380 multiple separators or "." and ".." directories in \a fileName
368 will not be removed (see cleanDirPath()). 381 will not be removed (see cleanDirPath()).
369 382
370 If \a acceptAbsPath is TRUE a \a fileName starting with a 383 If \a acceptAbsPath is TRUE a \a fileName starting with a
371 separator "/" will be returned without change. If \a acceptAbsPath 384 separator "/" will be returned without change. If \a acceptAbsPath
372 is FALSE an absolute path will be prepended to the fileName and 385 is FALSE an absolute path will be prepended to the fileName and
373 the resultant string returned. 386 the resultant string returned.
374 387
375 \sa filePath() 388 \sa filePath()
376*/ 389*/
377 390
378QString QDir::absFilePath( const QString &fileName, 391QString QDir::absFilePath( const QString &fileName,
379 bool acceptAbsPath ) const 392 bool acceptAbsPath ) const
380{ 393{
381 if ( acceptAbsPath && !isRelativePath( fileName ) ) 394 if ( acceptAbsPath && !isRelativePath( fileName ) )
382 return fileName; 395 return fileName;
383 396
384 QString tmp = absPath(); 397 QString tmp = absPath();
385 if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName && 398#ifdef Q_OS_WIN32
386 fileName[0] != '/') ) 399 if ( fileName[0].isLetter() && fileName[1] == ':' ) {
387 tmp += '/'; 400 int drv = fileName.upper()[0].latin1() - 'A' + 1;
388 tmp += fileName; 401 if ( _getdrive() != drv ) {
402 if ( qt_winunicode ) {
403 TCHAR buf[PATH_MAX];
404 ::_tgetdcwd( drv, buf, PATH_MAX );
405 tmp.setUnicodeCodes( (ushort*)buf, ::_tcslen(buf) );
406 } else {
407 char buf[PATH_MAX];
408 ::_getdcwd( drv, buf, PATH_MAX );
409 tmp = buf;
410 }
411 if ( !tmp.endsWith("\\") )
412 tmp += "\\";
413 tmp += fileName.right( fileName.length() - 2 );
414 int x;
415 for ( x = 0; x < (int) tmp.length(); x++ ) {
416 if ( tmp[x] == '\\' )
417 tmp[x] = '/';
418 }
419 }
420 } else
421#endif
422 {
423 if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
424 fileName[0] != '/') )
425 tmp += '/';
426 tmp += fileName;
427 }
389 return tmp; 428 return tmp;
390} 429}
391 430
392 431
393/*! 432/*!
394 Returns \a pathName with the '/' separators converted to 433 Returns \a pathName with the '/' separators converted to
395 separators that are appropriate for the underlying operating 434 separators that are appropriate for the underlying operating
396 system. 435 system.
397 436
398 On Windows, convertSeparators("c:/winnt/system32") returns 437 On Windows, convertSeparators("c:/winnt/system32") returns
399 "c:\winnt\system32". 438 "c:\winnt\system32".
400 439
401 The returned string may be the same as the argument on some 440 The returned string may be the same as the argument on some
402 operating systems, for example on Unix. 441 operating systems, for example on Unix.
403*/ 442*/
404 443
405QString QDir::convertSeparators( const QString &pathName ) 444QString QDir::convertSeparators( const QString &pathName )
406{ 445{
407 QString n( pathName ); 446 QString n( pathName );
408#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) 447#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX)
409 for ( int i=0; i<(int)n.length(); i++ ) { 448 for ( int i=0; i<(int)n.length(); i++ ) {
410 if ( n[i] == '/' ) 449 if ( n[i] == '/' )
411 n[i] = '\\'; 450 n[i] = '\\';
412 } 451 }
@@ -913,64 +952,66 @@ QDir &QDir::operator=( const QDir &d )
913 952
914 Sets the directory path to be the given \a path. 953 Sets the directory path to be the given \a path.
915*/ 954*/
916 955
917QDir &QDir::operator=( const QString &path ) 956QDir &QDir::operator=( const QString &path )
918{ 957{
919 dPath = cleanDirPath( path ); 958 dPath = cleanDirPath( path );
920 dirty = TRUE; 959 dirty = TRUE;
921 return *this; 960 return *this;
922} 961}
923 962
924 963
925/*! 964/*!
926 \fn bool QDir::operator!=( const QDir &d ) const 965 \fn bool QDir::operator!=( const QDir &d ) const
927 966
928 Returns TRUE if directory \a d and this directory have different 967 Returns TRUE if directory \a d and this directory have different
929 paths or different sort or filter settings; otherwise returns 968 paths or different sort or filter settings; otherwise returns
930 FALSE. 969 FALSE.
931 970
932 Example: 971 Example:
933 \code 972 \code
934 // The current directory is "/usr/local" 973 // The current directory is "/usr/local"
935 QDir d1( "/usr/local/bin" ); 974 QDir d1( "/usr/local/bin" );
936 QDir d2( "bin" ); 975 QDir d2( "bin" );
937 if ( d1 != d2 ) qDebug( "They differ\n" ); // This is printed 976 if ( d1 != d2 )
977 qDebug( "They differ" );
938 \endcode 978 \endcode
939*/ 979*/
940 980
941/*! 981/*!
942 Returns TRUE if directory \a d and this directory have the same 982 Returns TRUE if directory \a d and this directory have the same
943 path and their sort and filter settings are the same; otherwise 983 path and their sort and filter settings are the same; otherwise
944 returns FALSE. 984 returns FALSE.
945 985
946 Example: 986 Example:
947 \code 987 \code
948 // The current directory is "/usr/local" 988 // The current directory is "/usr/local"
949 QDir d1( "/usr/local/bin" ); 989 QDir d1( "/usr/local/bin" );
950 QDir d2( "bin" ); 990 QDir d2( "bin" );
951 d2.convertToAbs(); 991 d2.convertToAbs();
952 if ( d1 == d2 ) qDebug( "They're the same\n" ); // This is printed 992 if ( d1 == d2 )
993 qDebug( "They're the same" );
953 \endcode 994 \endcode
954*/ 995*/
955 996
956bool QDir::operator==( const QDir &d ) const 997bool QDir::operator==( const QDir &d ) const
957{ 998{
958 return dPath == d.dPath && 999 return dPath == d.dPath &&
959 nameFilt == d.nameFilt && 1000 nameFilt == d.nameFilt &&
960 allDirs == d.allDirs && 1001 allDirs == d.allDirs &&
961 filtS == d.filtS && 1002 filtS == d.filtS &&
962 sortS == d.sortS; 1003 sortS == d.sortS;
963} 1004}
964 1005
965 1006
966/*! 1007/*!
967 Removes the file, \a fileName. 1008 Removes the file, \a fileName.
968 1009
969 If \a acceptAbsPath is TRUE a path starting with separator "/" 1010 If \a acceptAbsPath is TRUE a path starting with separator "/"
970 will remove the file with the absolute path. If \a acceptAbsPath 1011 will remove the file with the absolute path. If \a acceptAbsPath
971 is FALSE any number of separators at the beginning of \a fileName 1012 is FALSE any number of separators at the beginning of \a fileName
972 will be removed and the resultant file name will be removed. 1013 will be removed and the resultant file name will be removed.
973 1014
974 Returns TRUE if the file is removed successfully; otherwise 1015 Returns TRUE if the file is removed successfully; otherwise
975 returns FALSE. 1016 returns FALSE.
976*/ 1017*/
@@ -1066,110 +1107,117 @@ QDir QDir::current()
1066QDir QDir::home() 1107QDir QDir::home()
1067{ 1108{
1068 return QDir( homeDirPath() ); 1109 return QDir( homeDirPath() );
1069} 1110}
1070 1111
1071/*! 1112/*!
1072 Returns the root directory. 1113 Returns the root directory.
1073 1114
1074 \sa rootDirPath() drives() 1115 \sa rootDirPath() drives()
1075*/ 1116*/
1076 1117
1077QDir QDir::root() 1118QDir QDir::root()
1078{ 1119{
1079 return QDir( rootDirPath() ); 1120 return QDir( rootDirPath() );
1080} 1121}
1081 1122
1082/*! 1123/*!
1083 \fn QString QDir::homeDirPath() 1124 \fn QString QDir::homeDirPath()
1084 1125
1085 Returns the absolute path of the user's home directory. 1126 Returns the absolute path of the user's home directory.
1086 1127
1087 \sa home() 1128 \sa home()
1088*/ 1129*/
1089 1130
1090QStringList qt_makeFilterList( const QString &filter ) 1131QValueList<QRegExp> qt_makeFilterList( const QString &filter )
1091{ 1132{
1133 QValueList<QRegExp> regExps;
1092 if ( filter.isEmpty() ) 1134 if ( filter.isEmpty() )
1093 return QStringList(); 1135 return regExps;
1094 1136
1095 QChar sep( ';' ); 1137 QChar sep( ';' );
1096 int i = filter.find( sep, 0 ); 1138 int i = filter.find( sep, 0 );
1097 if ( i == -1 && filter.find( ' ', 0 ) != -1 ) 1139 if ( i == -1 && filter.find( ' ', 0 ) != -1 )
1098 sep = QChar( ' ' ); 1140 sep = QChar( ' ' );
1099 1141
1100 QStringList list = QStringList::split( sep, filter ); 1142 QStringList list = QStringList::split( sep, filter );
1101 QStringList::Iterator it = list.begin(); 1143 QStringList::Iterator it = list.begin();
1102 QStringList list2; 1144 while ( it != list.end() ) {
1145 regExps << QRegExp( (*it).stripWhiteSpace(), CaseSensitiveFS, TRUE );
1146 ++it;
1147 }
1148 return regExps;
1149}
1103 1150
1104 for ( ; it != list.end(); ++it ) { 1151bool qt_matchFilterList( const QValueList<QRegExp>& filters,
1105 QString s = *it; 1152 const QString &fileName )
1106 list2 << s.stripWhiteSpace(); 1153{
1154 QValueList<QRegExp>::ConstIterator rit = filters.begin();
1155 while ( rit != filters.end() ) {
1156 if ( (*rit).exactMatch(fileName) )
1157 return TRUE;
1158 ++rit;
1107 } 1159 }
1108 return list2; 1160 return FALSE;
1109} 1161}
1110 1162
1163
1111/*! 1164/*!
1112 \overload 1165 \overload
1113 1166
1114 Returns TRUE if the \a fileName matches any of the wildcard (glob) 1167 Returns TRUE if the \a fileName matches any of the wildcard (glob)
1115 patterns in the list of \a filters; otherwise returns FALSE. 1168 patterns in the list of \a filters; otherwise returns FALSE.
1116 1169
1117 (See \link qregexp.html#wildcard-matching QRegExp wildcard 1170 (See \link qregexp.html#wildcard-matching QRegExp wildcard
1118 matching.\endlink) 1171 matching.\endlink)
1119 \sa QRegExp::match() 1172 \sa QRegExp::match()
1120*/ 1173*/
1121 1174
1122bool QDir::match( const QStringList &filters, const QString &fileName ) 1175bool QDir::match( const QStringList &filters, const QString &fileName )
1123{ 1176{
1124 QStringList::ConstIterator sit = filters.begin(); 1177 QStringList::ConstIterator sit = filters.begin();
1125 while ( sit != filters.end() ) { 1178 while ( sit != filters.end() ) {
1126#if defined(Q_FS_FAT) && !defined(Q_OS_UNIX) 1179 QRegExp rx( *sit, CaseSensitiveFS, TRUE );
1127 QRegExp rx( *sit, FALSE, TRUE ); // The FAT FS is not case sensitive..
1128#else
1129 QRegExp rx( *sit, TRUE, TRUE ); // ..while others are.
1130#endif
1131 if ( rx.exactMatch(fileName) ) 1180 if ( rx.exactMatch(fileName) )
1132 return TRUE; 1181 return TRUE;
1133 ++sit; 1182 ++sit;
1134 } 1183 }
1135 return FALSE; 1184 return FALSE;
1136} 1185}
1137 1186
1138/*! 1187/*!
1139 Returns TRUE if the \a fileName matches the wildcard (glob) 1188 Returns TRUE if the \a fileName matches the wildcard (glob)
1140 pattern \a filter; otherwise returns FALSE. The \a filter may 1189 pattern \a filter; otherwise returns FALSE. The \a filter may
1141 contain multiple patterns separated by spaces or semicolons. 1190 contain multiple patterns separated by spaces or semicolons.
1142 1191
1143 (See \link qregexp.html#wildcard-matching QRegExp wildcard 1192 (See \link qregexp.html#wildcard-matching QRegExp wildcard
1144 matching.\endlink) 1193 matching.\endlink)
1145 \sa QRegExp::match() 1194 \sa QRegExp::match()
1146*/ 1195*/
1147 1196
1148bool QDir::match( const QString &filter, const QString &fileName ) 1197bool QDir::match( const QString &filter, const QString &fileName )
1149{ 1198{
1150 QStringList lst = qt_makeFilterList( filter ); 1199 return qt_matchFilterList( qt_makeFilterList(filter), fileName );
1151 return match( lst, fileName );
1152} 1200}
1153 1201
1154 1202
1155/*! 1203/*!
1156 Removes all multiple directory separators "/" and resolves any 1204 Removes all multiple directory separators "/" and resolves any
1157 "."s or ".."s found in the path, \a filePath. 1205 "."s or ".."s found in the path, \a filePath.
1158 1206
1159 Symbolic links are kept. This function does not return the 1207 Symbolic links are kept. This function does not return the
1160 canonical path, but rather the simplest version of the input. 1208 canonical path, but rather the simplest version of the input.
1161 For example, "./local" becomes "local", "local/../bin" becomes 1209 For example, "./local" becomes "local", "local/../bin" becomes
1162 "bin" and "/local/usr/../bin" becomes "/local/bin". 1210 "bin" and "/local/usr/../bin" becomes "/local/bin".
1163 1211
1164 \sa absPath() canonicalPath() 1212 \sa absPath() canonicalPath()
1165*/ 1213*/
1166 1214
1167QString QDir::cleanDirPath( const QString &filePath ) 1215QString QDir::cleanDirPath( const QString &filePath )
1168{ 1216{
1169 QString name = filePath; 1217 QString name = filePath;
1170 QString newPath; 1218 QString newPath;
1171 1219
1172 if ( name.isEmpty() ) 1220 if ( name.isEmpty() )
1173 return name; 1221 return name;
1174 1222
1175 slashify( name ); 1223 slashify( name );
diff --git a/qmake/tools/qdir_unix.cpp b/qmake/tools/qdir_unix.cpp
index 57fe3c5..6a7adda 100644
--- a/qmake/tools/qdir_unix.cpp
+++ b/qmake/tools/qdir_unix.cpp
@@ -1,122 +1,123 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QDir class 4** Implementation of QDir class
5** 5**
6** Created : 950628 6** Created : 950628
7** 7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses for Unix/X11 or for Qt/Embedded may use this file in accordance 22** licenses for Unix/X11 or for Qt/Embedded may use this file in accordance
23** with the Qt Commercial License Agreement provided with the Software. 23** with the Qt Commercial License Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qplatformdefs.h" 38#include "qplatformdefs.h"
39#include "qdir.h" 39#include "qdir.h"
40 40
41#ifndef QT_NO_DIR 41#ifndef QT_NO_DIR
42 42
43#include "qdir_p.h" 43#include "qdir_p.h"
44#include "qfileinfo.h" 44#include "qfileinfo.h"
45#include "qregexp.h" 45#include "qregexp.h"
46#include "qstringlist.h" 46#include "qstringlist.h"
47 47
48#ifdef QT_THREAD_SUPPORT 48#ifdef QT_THREAD_SUPPORT
49# include <private/qmutexpool_p.h> 49# include <private/qmutexpool_p.h>
50#endif // QT_THREAD_SUPPORT 50#endif // QT_THREAD_SUPPORT
51 51
52#include <stdlib.h> 52#include <stdlib.h>
53#include <limits.h> 53#include <limits.h>
54#include <errno.h>
54 55
55 56
56void QDir::slashify( QString& ) 57void QDir::slashify( QString& )
57{ 58{
58} 59}
59 60
60QString QDir::homeDirPath() 61QString QDir::homeDirPath()
61{ 62{
62 QString d; 63 QString d;
63 d = QFile::decodeName(getenv("HOME")); 64 d = QFile::decodeName(getenv("HOME"));
64 slashify( d ); 65 slashify( d );
65 if ( d.isNull() ) 66 if ( d.isNull() )
66 d = rootDirPath(); 67 d = rootDirPath();
67 return d; 68 return d;
68} 69}
69 70
70QString QDir::canonicalPath() const 71QString QDir::canonicalPath() const
71{ 72{
72 QString r; 73 QString r;
73
74 char cur[PATH_MAX+1]; 74 char cur[PATH_MAX+1];
75 if ( ::getcwd( cur, PATH_MAX ) ) 75 if ( ::getcwd( cur, PATH_MAX ) ) {
76 if ( ::chdir(QFile::encodeName(dPath)) >= 0 ) { 76 char tmp[PATH_MAX+1];
77 char tmp[PATH_MAX+1]; 77 if( ::realpath( QFile::encodeName( dPath ), tmp ) )
78 if ( ::getcwd( tmp, PATH_MAX ) ) 78 r = QFile::decodeName( tmp );
79 r = QFile::decodeName(tmp); 79 slashify( r );
80 ::chdir( cur ); 80
81 } 81 // always make sure we go back to the current dir
82 82 ::chdir( cur );
83 slashify( r ); 83 }
84 return r; 84 return r;
85} 85}
86 86
87bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const 87bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const
88{ 88{
89#if defined(Q_OS_MACX) // Mac X doesn't support trailing /'s 89#if defined(Q_OS_MACX) // Mac X doesn't support trailing /'s
90 QString name = dirName; 90 QString name = dirName;
91 if (dirName[dirName.length() - 1] == "/") 91 if (dirName[dirName.length() - 1] == "/")
92 name = dirName.left( dirName.length() - 1 ); 92 name = dirName.left( dirName.length() - 1 );
93 return ::mkdir( QFile::encodeName(filePath(name,acceptAbsPath)), 0777 ) 93 int status =
94 == 0; 94 ::mkdir( QFile::encodeName(filePath(name,acceptAbsPath)), 0777 );
95#else 95#else
96 return ::mkdir( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 ) 96 int status =
97 == 0; 97 ::mkdir( QFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 );
98#endif 98#endif
99 return status == 0;
99} 100}
100 101
101bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const 102bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const
102{ 103{
103 return ::rmdir( QFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0; 104 return ::rmdir( QFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0;
104} 105}
105 106
106bool QDir::isReadable() const 107bool QDir::isReadable() const
107{ 108{
108 return ::access( QFile::encodeName(dPath), R_OK | X_OK ) == 0; 109 return ::access( QFile::encodeName(dPath), R_OK | X_OK ) == 0;
109} 110}
110 111
111bool QDir::isRoot() const 112bool QDir::isRoot() const
112{ 113{
113 return dPath == QString::fromLatin1("/"); 114 return dPath == QString::fromLatin1("/");
114} 115}
115 116
116bool QDir::rename( const QString &name, const QString &newName, 117bool QDir::rename( const QString &name, const QString &newName,
117 bool acceptAbsPaths) 118 bool acceptAbsPaths)
118{ 119{
119 if ( name.isEmpty() || newName.isEmpty() ) { 120 if ( name.isEmpty() || newName.isEmpty() ) {
120#if defined(QT_CHECK_NULL) 121#if defined(QT_CHECK_NULL)
121 qWarning( "QDir::rename: Empty or null file name(s)" ); 122 qWarning( "QDir::rename: Empty or null file name(s)" );
122#endif 123#endif
@@ -165,76 +166,80 @@ QString QDir::rootDirPath()
165 166
166bool QDir::isRelativePath( const QString &path ) 167bool QDir::isRelativePath( const QString &path )
167{ 168{
168 int len = path.length(); 169 int len = path.length();
169 if ( len == 0 ) 170 if ( len == 0 )
170 return TRUE; 171 return TRUE;
171 return path[0] != '/'; 172 return path[0] != '/';
172} 173}
173 174
174bool QDir::readDirEntries( const QString &nameFilter, 175bool QDir::readDirEntries( const QString &nameFilter,
175 int filterSpec, int sortSpec ) 176 int filterSpec, int sortSpec )
176{ 177{
177 int i; 178 int i;
178 if ( !fList ) { 179 if ( !fList ) {
179 fList = new QStringList; 180 fList = new QStringList;
180 Q_CHECK_PTR( fList ); 181 Q_CHECK_PTR( fList );
181 fiList = new QFileInfoList; 182 fiList = new QFileInfoList;
182 Q_CHECK_PTR( fiList ); 183 Q_CHECK_PTR( fiList );
183 fiList->setAutoDelete( TRUE ); 184 fiList->setAutoDelete( TRUE );
184 } else { 185 } else {
185 fList->clear(); 186 fList->clear();
186 fiList->clear(); 187 fiList->clear();
187 } 188 }
188 189
189 QStringList filters = qt_makeFilterList( nameFilter ); 190 QValueList<QRegExp> filters = qt_makeFilterList( nameFilter );
190 191
191 bool doDirs = (filterSpec & Dirs)!= 0; 192 bool doDirs = (filterSpec & Dirs)!= 0;
192 bool doFiles = (filterSpec & Files)!= 0; 193 bool doFiles = (filterSpec & Files)!= 0;
193 bool noSymLinks = (filterSpec & NoSymLinks) != 0; 194 bool noSymLinks = (filterSpec & NoSymLinks) != 0;
194 bool doReadable = (filterSpec & Readable)!= 0; 195 bool doReadable = (filterSpec & Readable)!= 0;
195 bool doWritable = (filterSpec & Writable)!= 0; 196 bool doWritable = (filterSpec & Writable)!= 0;
196 bool doExecable = (filterSpec & Executable) != 0; 197 bool doExecable = (filterSpec & Executable) != 0;
197 bool doHidden = (filterSpec & Hidden)!= 0; 198 bool doHidden = (filterSpec & Hidden)!= 0;
198 bool doSystem = (filterSpec & System) != 0; 199 bool doSystem = (filterSpec & System) != 0;
199 200
200#if defined(Q_OS_OS2EMX)
201 //QRegExp wc( nameFilter, FALSE, TRUE );// wild card, case insensitive
202#else
203 //QRegExp wc( nameFilter, TRUE, TRUE );// wild card, case sensitive
204#endif
205 QFileInfo fi; 201 QFileInfo fi;
206 DIR *dir; 202 DIR *dir;
207 dirent *file; 203 dirent *file;
208 204
209 dir = opendir( QFile::encodeName(dPath) ); 205 dir = opendir( QFile::encodeName(dPath) );
210 if ( !dir ) 206 if ( !dir )
211 return FALSE; // cannot read the directory 207 return FALSE; // cannot read the directory
212 208
213 while ( (file = readdir(dir)) ) { 209#if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
210 union {
211 struct dirent mt_file;
212 char b[sizeof(struct dirent) + MAXNAMLEN + 1];
213 } u;
214 while ( readdir_r(dir, &u.mt_file, &file ) == 0 && file )
215#else
216 while ( (file = readdir(dir)) )
217#endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS
218 {
214 QString fn = QFile::decodeName(file->d_name); 219 QString fn = QFile::decodeName(file->d_name);
215 fi.setFile( *this, fn ); 220 fi.setFile( *this, fn );
216 if ( !match( filters, fn ) && !(allDirs && fi.isDir()) ) 221 if ( !qt_matchFilterList(filters, fn) && !(allDirs && fi.isDir()) )
217 continue; 222 continue;
218 if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) || 223 if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) ||
219 (doSystem && (!fi.isFile() && !fi.isDir())) ) { 224 (doSystem && (!fi.isFile() && !fi.isDir())) ) {
220 if ( noSymLinks && fi.isSymLink() ) 225 if ( noSymLinks && fi.isSymLink() )
221 continue; 226 continue;
222 if ( (filterSpec & RWEMask) != 0 ) 227 if ( (filterSpec & RWEMask) != 0 )
223 if ( (doReadable && !fi.isReadable()) || 228 if ( (doReadable && !fi.isReadable()) ||
224 (doWritable && !fi.isWritable()) || 229 (doWritable && !fi.isWritable()) ||
225 (doExecable && !fi.isExecutable()) ) 230 (doExecable && !fi.isExecutable()) )
226 continue; 231 continue;
227 if ( !doHidden && fn[0] == '.' && 232 if ( !doHidden && fn[0] == '.' &&
228 fn != QString::fromLatin1(".") 233 fn != QString::fromLatin1(".")
229 && fn != QString::fromLatin1("..") ) 234 && fn != QString::fromLatin1("..") )
230 continue; 235 continue;
231 fiList->append( new QFileInfo( fi ) ); 236 fiList->append( new QFileInfo( fi ) );
232 } 237 }
233 } 238 }
234 if ( closedir(dir) != 0 ) { 239 if ( closedir(dir) != 0 ) {
235#if defined(QT_CHECK_NULL) 240#if defined(QT_CHECK_NULL)
236 qWarning( "QDir::readDirEntries: Cannot close the directory: %s", 241 qWarning( "QDir::readDirEntries: Cannot close the directory: %s",
237 dPath.local8Bit().data() ); 242 dPath.local8Bit().data() );
238#endif 243#endif
239 } 244 }
240 245
@@ -255,37 +260,38 @@ bool QDir::readDirEntries( const QString &nameFilter,
255 fiList->append( si[j].item ); 260 fiList->append( si[j].item );
256 fList->append( si[j].item->fileName() ); 261 fList->append( si[j].item->fileName() );
257 } 262 }
258 delete [] si; 263 delete [] si;
259 fiList->setAutoDelete( TRUE ); 264 fiList->setAutoDelete( TRUE );
260 } 265 }
261 266
262 if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS && 267 if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS &&
263 nameFilter == nameFilt ) 268 nameFilter == nameFilt )
264 dirty = FALSE; 269 dirty = FALSE;
265 else 270 else
266 dirty = TRUE; 271 dirty = TRUE;
267 return TRUE; 272 return TRUE;
268} 273}
269 274
270const QFileInfoList * QDir::drives() 275const QFileInfoList * QDir::drives()
271{ 276{
272 // at most one instance of QFileInfoList is leaked, and this variable 277 // at most one instance of QFileInfoList is leaked, and this variable
273 // points to that list 278 // points to that list
274 static QFileInfoList * knownMemoryLeak = 0; 279 static QFileInfoList * knownMemoryLeak = 0;
275 280
276 if ( !knownMemoryLeak ) { 281 if ( !knownMemoryLeak ) {
277 282
278#ifdef QT_THREAD_SUPPORT 283#ifdef QT_THREAD_SUPPORT
279 QMutexLocker locker( qt_global_mutexpool->get( &knownMemoryLeak ) ); 284 QMutexLocker locker( qt_global_mutexpool ?
285 qt_global_mutexpool->get( &knownMemoryLeak ) : 0 );
280#endif // QT_THREAD_SUPPORT 286#endif // QT_THREAD_SUPPORT
281 287
282 if ( !knownMemoryLeak ) { 288 if ( !knownMemoryLeak ) {
283 knownMemoryLeak = new QFileInfoList; 289 knownMemoryLeak = new QFileInfoList;
284 // non-win32 versions both use just one root directory 290 // non-win32 versions both use just one root directory
285 knownMemoryLeak->append( new QFileInfo( rootDirPath() ) ); 291 knownMemoryLeak->append( new QFileInfo( rootDirPath() ) );
286 } 292 }
287 } 293 }
288 294
289 return knownMemoryLeak; 295 return knownMemoryLeak;
290} 296}
291#endif //QT_NO_DIR 297#endif //QT_NO_DIR
diff --git a/qmake/tools/qfile.cpp b/qmake/tools/qfile.cpp
index a578b49..c088b55 100644
--- a/qmake/tools/qfile.cpp
+++ b/qmake/tools/qfile.cpp
@@ -67,49 +67,49 @@ extern bool qt_file_access( const QString& fn, int t );
67 The file name is usually passed in the constructor but can be 67 The file name is usually passed in the constructor but can be
68 changed with setName(). You can check for a file's existence with 68 changed with setName(). You can check for a file's existence with
69 exists() and remove a file with remove(). 69 exists() and remove a file with remove().
70 70
71 The file is opened with open(), closed with close() and flushed 71 The file is opened with open(), closed with close() and flushed
72 with flush(). Data is usually read and written using QDataStream 72 with flush(). Data is usually read and written using QDataStream
73 or QTextStream, but you can read with readBlock() and readLine() 73 or QTextStream, but you can read with readBlock() and readLine()
74 and write with writeBlock(). QFile also supports getch(), 74 and write with writeBlock(). QFile also supports getch(),
75 ungetch() and putch(). 75 ungetch() and putch().
76 76
77 The size of the file is returned by size(). You can get the 77 The size of the file is returned by size(). You can get the
78 current file position or move to a new file position using the 78 current file position or move to a new file position using the
79 at() functions. If you've reached the end of the file, atEnd() 79 at() functions. If you've reached the end of the file, atEnd()
80 returns TRUE. The file handle is returned by handle(). 80 returns TRUE. The file handle is returned by handle().
81 81
82 Here is a code fragment that uses QTextStream to read a text file 82 Here is a code fragment that uses QTextStream to read a text file
83 line by line. It prints each line with a line number. 83 line by line. It prints each line with a line number.
84 \code 84 \code
85 QStringList lines; 85 QStringList lines;
86 QFile file( "file.txt" ); 86 QFile file( "file.txt" );
87 if ( file.open( IO_ReadOnly ) ) { 87 if ( file.open( IO_ReadOnly ) ) {
88 QTextStream stream( &file ); 88 QTextStream stream( &file );
89 QString line; 89 QString line;
90 int i = 1; 90 int i = 1;
91 while ( !stream.eof() ) { 91 while ( !stream.atEnd() ) {
92 line = stream.readLine(); // line of text excluding '\n' 92 line = stream.readLine(); // line of text excluding '\n'
93 printf( "%3d: %s\n", i++, line.latin1() ); 93 printf( "%3d: %s\n", i++, line.latin1() );
94 lines += line; 94 lines += line;
95 } 95 }
96 file.close(); 96 file.close();
97 } 97 }
98 \endcode 98 \endcode
99 99
100 Writing text is just as easy. The following example shows how to 100 Writing text is just as easy. The following example shows how to
101 write the data we read into the string list from the previous 101 write the data we read into the string list from the previous
102 example: 102 example:
103 \code 103 \code
104 QFile file( "file.txt" ); 104 QFile file( "file.txt" );
105 if ( file.open( IO_WriteOnly ) ) { 105 if ( file.open( IO_WriteOnly ) ) {
106 QTextStream stream( &file ); 106 QTextStream stream( &file );
107 for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) 107 for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
108 stream << *it << "\n"; 108 stream << *it << "\n";
109 file.close(); 109 file.close();
110 } 110 }
111 \endcode 111 \endcode
112 112
113 The QFileInfo class holds detailed information about a file, such 113 The QFileInfo class holds detailed information about a file, such
114 as access permissions, file dates and file types. 114 as access permissions, file dates and file types.
115 115
@@ -269,48 +269,49 @@ bool QFile::remove()
269# define OPEN_ASYNC O_NONBLOCK 269# define OPEN_ASYNC O_NONBLOCK
270#elif defined(O_NDELAY) 270#elif defined(O_NDELAY)
271# define HAS_ASYNC_FILEMODE 271# define HAS_ASYNC_FILEMODE
272# define OPEN_ASYNC O_NDELAY 272# define OPEN_ASYNC O_NDELAY
273#endif 273#endif
274 274
275/*! 275/*!
276 Flushes the file buffer to the disk. 276 Flushes the file buffer to the disk.
277 277
278 close() also flushes the file buffer. 278 close() also flushes the file buffer.
279*/ 279*/
280 280
281void QFile::flush() 281void QFile::flush()
282{ 282{
283 if ( isOpen() && fh ) // can only flush open/buffered 283 if ( isOpen() && fh ) // can only flush open/buffered
284 fflush( fh ); // file 284 fflush( fh ); // file
285} 285}
286 286
287/*! \reimp 287/*! \reimp
288 \fn QIODevice::Offset QFile::at() const 288 \fn QIODevice::Offset QFile::at() const
289*/ 289*/
290 290
291/*! 291/*!
292 Returns TRUE if the end of file has been reached; otherwise returns FALSE. 292 Returns TRUE if the end of file has been reached; otherwise returns FALSE.
293 If QFile has not been open()'d, then the behavior is undefined.
293 294
294 \sa size() 295 \sa size()
295*/ 296*/
296 297
297bool QFile::atEnd() const 298bool QFile::atEnd() const
298{ 299{
299 if ( !isOpen() ) { 300 if ( !isOpen() ) {
300#if defined(QT_CHECK_STATE) 301#if defined(QT_CHECK_STATE)
301 qWarning( "QFile::atEnd: File is not open" ); 302 qWarning( "QFile::atEnd: File is not open" );
302#endif 303#endif
303 return FALSE; 304 return FALSE;
304 } 305 }
305 if ( isDirectAccess() && !isTranslated() ) { 306 if ( isDirectAccess() && !isTranslated() ) {
306 if ( at() < length ) 307 if ( at() < length )
307 return FALSE; 308 return FALSE;
308 } 309 }
309 return QIODevice::atEnd(); 310 return QIODevice::atEnd();
310} 311}
311 312
312/*! 313/*!
313 Reads a line of text. 314 Reads a line of text.
314 315
315 Reads bytes from the file into the char* \a p, until end-of-line 316 Reads bytes from the file into the char* \a p, until end-of-line
316 or \a maxlen bytes have been read, whichever occurs first. Returns 317 or \a maxlen bytes have been read, whichever occurs first. Returns
diff --git a/qmake/tools/qfile_unix.cpp b/qmake/tools/qfile_unix.cpp
index 2d5a856..460bf06 100644
--- a/qmake/tools/qfile_unix.cpp
+++ b/qmake/tools/qfile_unix.cpp
@@ -414,53 +414,56 @@ bool QFile::open( int m, int f )
414 if ( length == 0 && isReadable() ) { 414 if ( length == 0 && isReadable() ) {
415 // try if you can read from it (if you can, it's a sequential 415 // try if you can read from it (if you can, it's a sequential
416 // device; e.g. a file in the /proc filesystem) 416 // device; e.g. a file in the /proc filesystem)
417 int c = getch(); 417 int c = getch();
418 if ( c != -1 ) { 418 if ( c != -1 ) {
419 ungetch(c); 419 ungetch(c);
420 setType( IO_Sequential ); 420 setType( IO_Sequential );
421 length = INT_MAX; 421 length = INT_MAX;
422 ioIndex = 0; 422 ioIndex = 0;
423 } 423 }
424 resetStatus(); 424 resetStatus();
425 } 425 }
426 } 426 }
427 return TRUE; 427 return TRUE;
428} 428}
429 429
430/*! 430/*!
431 Returns the file size. 431 Returns the file size.
432 \sa at() 432 \sa at()
433*/ 433*/
434 434
435QIODevice::Offset QFile::size() const 435QIODevice::Offset QFile::size() const
436{ 436{
437 struct stat st; 437 struct stat st;
438 int ret = 0;
438 if ( isOpen() ) { 439 if ( isOpen() ) {
439 ::fstat( fh ? fileno(fh) : fd, &st ); 440 ret = ::fstat( fh ? fileno(fh) : fd, &st );
440 } else { 441 } else {
441 ::stat( QFile::encodeName(fn), &st ); 442 ret = ::stat( QFile::encodeName(fn), &st );
442 } 443 }
444 if ( ret == -1 )
445 return 0;
443#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_64BITOFFSET) 446#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_64BITOFFSET)
444 return (uint)st.st_size > UINT_MAX ? UINT_MAX : (QIODevice::Offset)st.st_size; 447 return (uint)st.st_size > UINT_MAX ? UINT_MAX : (QIODevice::Offset)st.st_size;
445#else 448#else
446 return st.st_size; 449 return st.st_size;
447#endif 450#endif
448} 451}
449 452
450 453
451/*! 454/*!
452 \overload 455 \overload
453 456
454 Sets the file index to \a pos. Returns TRUE if successful; 457 Sets the file index to \a pos. Returns TRUE if successful;
455 otherwise returns FALSE. 458 otherwise returns FALSE.
456 459
457 Example: 460 Example:
458 \code 461 \code
459 QFile f( "data.bin" ); 462 QFile f( "data.bin" );
460 f.open( IO_ReadOnly ); // index set to 0 463 f.open( IO_ReadOnly ); // index set to 0
461 f.at( 100 ); // set index to 100 464 f.at( 100 ); // set index to 100
462 f.at( f.at()+50 ); // set index to 150 465 f.at( f.at()+50 ); // set index to 150
463 f.at( f.size()-80 ); // set index to 80 before EOF 466 f.at( f.size()-80 ); // set index to 80 before EOF
464 f.close(); 467 f.close();
465 \endcode 468 \endcode
466 469
@@ -517,49 +520,49 @@ bool QFile::at( Offset pos )
517 readBlock() solved this problem. 520 readBlock() solved this problem.
518*/ 521*/
519 522
520Q_LONG QFile::readBlock( char *p, Q_ULONG len ) 523Q_LONG QFile::readBlock( char *p, Q_ULONG len )
521{ 524{
522#if defined(QT_CHECK_NULL) 525#if defined(QT_CHECK_NULL)
523 if ( !p ) 526 if ( !p )
524 qWarning( "QFile::readBlock: Null pointer error" ); 527 qWarning( "QFile::readBlock: Null pointer error" );
525#endif 528#endif
526#if defined(QT_CHECK_STATE) 529#if defined(QT_CHECK_STATE)
527 if ( !isOpen() ) { 530 if ( !isOpen() ) {
528 qWarning( "QFile::readBlock: File not open" ); 531 qWarning( "QFile::readBlock: File not open" );
529 return -1; 532 return -1;
530 } 533 }
531 if ( !isReadable() ) { 534 if ( !isReadable() ) {
532 qWarning( "QFile::readBlock: Read operation not permitted" ); 535 qWarning( "QFile::readBlock: Read operation not permitted" );
533 return -1; 536 return -1;
534 } 537 }
535#endif 538#endif
536 Q_ULONG nread = 0; // number of bytes read 539 Q_ULONG nread = 0; // number of bytes read
537 if ( !ungetchBuffer.isEmpty() ) { 540 if ( !ungetchBuffer.isEmpty() ) {
538 // need to add these to the returned string. 541 // need to add these to the returned string.
539 uint l = ungetchBuffer.length(); 542 uint l = ungetchBuffer.length();
540 while( nread < l ) { 543 while( nread < l ) {
541 *p = ungetchBuffer[ l - nread - 1 ]; 544 *p = ungetchBuffer.at( l - nread - 1 );
542 p++; 545 p++;
543 nread++; 546 nread++;
544 } 547 }
545 ungetchBuffer.truncate( l - nread ); 548 ungetchBuffer.truncate( l - nread );
546 } 549 }
547 550
548 if ( nread < len ) { 551 if ( nread < len ) {
549 if ( isRaw() ) { // raw file 552 if ( isRaw() ) { // raw file
550 nread += ::read( fd, p, len-nread ); 553 nread += ::read( fd, p, len-nread );
551 if ( len && nread <= 0 ) { 554 if ( len && nread <= 0 ) {
552 nread = 0; 555 nread = 0;
553 setStatus(IO_ReadError); 556 setStatus(IO_ReadError);
554 } 557 }
555 } else { // buffered file 558 } else { // buffered file
556 nread += fread( p, 1, len-nread, fh ); 559 nread += fread( p, 1, len-nread, fh );
557 if ( (uint)nread != len ) { 560 if ( (uint)nread != len ) {
558 if ( ferror( fh ) || nread==0 ) 561 if ( ferror( fh ) || nread==0 )
559 setStatus(IO_ReadError); 562 setStatus(IO_ReadError);
560 } 563 }
561 } 564 }
562 } 565 }
563 if ( !isSequentialAccess() ) 566 if ( !isSequentialAccess() )
564 ioIndex += nread; 567 ioIndex += nread;
565 return nread; 568 return nread;
@@ -608,49 +611,51 @@ Q_LONG QFile::writeBlock( const char *p, Q_ULONG len )
608 setStatus( IO_WriteError ); 611 setStatus( IO_WriteError );
609 if ( !isSequentialAccess() ) { 612 if ( !isSequentialAccess() ) {
610 if ( isRaw() ) // recalc file position 613 if ( isRaw() ) // recalc file position
611 ioIndex = (Offset)::lseek( fd, 0, SEEK_CUR ); 614 ioIndex = (Offset)::lseek( fd, 0, SEEK_CUR );
612 else 615 else
613#if defined(QT_LARGEFILE_SUPPORT) 616#if defined(QT_LARGEFILE_SUPPORT)
614 ioIndex = (Offset)::fseeko( fh, 0, SEEK_CUR ); 617 ioIndex = (Offset)::fseeko( fh, 0, SEEK_CUR );
615#else 618#else
616 ioIndex = (Offset)::fseek( fh, 0, SEEK_CUR ); 619 ioIndex = (Offset)::fseek( fh, 0, SEEK_CUR );
617#endif 620#endif
618 } 621 }
619 } else { 622 } else {
620 if ( !isSequentialAccess() ) 623 if ( !isSequentialAccess() )
621 ioIndex += nwritten; 624 ioIndex += nwritten;
622 } 625 }
623 if ( ioIndex > length ) // update file length 626 if ( ioIndex > length ) // update file length
624 length = ioIndex; 627 length = ioIndex;
625 return nwritten; 628 return nwritten;
626} 629}
627 630
628/*! 631/*!
629 Returns the file handle of the file. 632 Returns the file handle of the file.
630 633
631 This is a small positive integer, suitable for use with C library 634 This is a small positive integer, suitable for use with C library
632 functions such as fdopen() and fcntl(), as well as with QSocketNotifier. 635 functions such as fdopen() and fcntl(). On systems that use file
636 descriptors for sockets (ie. Unix systems, but not Windows) the handle
637 can be used with QSocketNotifier as well.
633 638
634 If the file is not open or there is an error, handle() returns -1. 639 If the file is not open or there is an error, handle() returns -1.
635 640
636 \sa QSocketNotifier 641 \sa QSocketNotifier
637*/ 642*/
638 643
639int QFile::handle() const 644int QFile::handle() const
640{ 645{
641 if ( !isOpen() ) 646 if ( !isOpen() )
642 return -1; 647 return -1;
643 else if ( fh ) 648 else if ( fh )
644 return fileno( fh ); 649 return fileno( fh );
645 else 650 else
646 return fd; 651 return fd;
647} 652}
648 653
649/*! 654/*!
650 Closes an open file. 655 Closes an open file.
651 656
652 The file is not closed if it was opened with an existing file handle. 657 The file is not closed if it was opened with an existing file handle.
653 If the existing file handle is a \c FILE*, the file is flushed. 658 If the existing file handle is a \c FILE*, the file is flushed.
654 If the existing file handle is an \c int file descriptor, nothing 659 If the existing file handle is an \c int file descriptor, nothing
655 is done to the file. 660 is done to the file.
656 661
diff --git a/qmake/tools/qfileinfo.cpp b/qmake/tools/qfileinfo.cpp
index 3af7932..a78f4fa 100644
--- a/qmake/tools/qfileinfo.cpp
+++ b/qmake/tools/qfileinfo.cpp
@@ -614,46 +614,48 @@ QDateTime QFileInfo::lastRead() const
614 if ( !fic || !cache ) 614 if ( !fic || !cache )
615 doStat(); 615 doStat();
616 if ( fic && fic->st.st_atime != 0 ) { 616 if ( fic && fic->st.st_atime != 0 ) {
617 dt.setTime_t( fic->st.st_atime ); 617 dt.setTime_t( fic->st.st_atime );
618 return dt; 618 return dt;
619 } else { 619 } else {
620 return lastModified(); 620 return lastModified();
621 } 621 }
622} 622}
623 623
624#ifndef QT_NO_DIR 624#ifndef QT_NO_DIR
625 625
626/*! 626/*!
627 Returns the absolute path including the file name. 627 Returns the absolute path including the file name.
628 628
629 The absolute path name consists of the full path and the file 629 The absolute path name consists of the full path and the file
630 name. On Unix this will always begin with the root, '/', 630 name. On Unix this will always begin with the root, '/',
631 directory. On Windows this will always begin 'D:/' where D is a 631 directory. On Windows this will always begin 'D:/' where D is a
632 drive letter, except for network shares that are not mapped to a 632 drive letter, except for network shares that are not mapped to a
633 drive letter, in which case the path will begin '//sharename/'. 633 drive letter, in which case the path will begin '//sharename/'.
634 634
635 This function returns the same as filePath(), unless isRelative() 635 This function returns the same as filePath(), unless isRelative()
636 is TRUE. 636 is TRUE.
637 637
638 If the QFileInfo is empty it returns QDir::currentDirPath().
639
638 This function can be time consuming under Unix (in the order of 640 This function can be time consuming under Unix (in the order of
639 milliseconds). 641 milliseconds).
640 642
641 \sa isRelative(), filePath() 643 \sa isRelative(), filePath()
642*/ 644*/
643QString QFileInfo::absFilePath() const 645QString QFileInfo::absFilePath() const
644{ 646{
645 QString tmp; 647 QString tmp;
646 if ( QDir::isRelativePath(fn) 648 if ( QDir::isRelativePath(fn)
647#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) 649#if defined(Q_OS_WIN32)
648 && fn[1] != ':' 650 && fn[1] != ':'
649#endif 651#endif
650 ) { 652 ) {
651 tmp = QDir::currentDirPath(); 653 tmp = QDir::currentDirPath();
652 tmp += '/'; 654 tmp += '/';
653 } 655 }
654 tmp += fn; 656 tmp += fn;
655 makeAbs( tmp ); 657 makeAbs( tmp );
656 return QDir::cleanDirPath( tmp ); 658 return QDir::cleanDirPath( tmp );
657} 659}
658 660
659#endif 661#endif
diff --git a/qmake/tools/qfileinfo_unix.cpp b/qmake/tools/qfileinfo_unix.cpp
index f7c3a97..364f219 100644
--- a/qmake/tools/qfileinfo_unix.cpp
+++ b/qmake/tools/qfileinfo_unix.cpp
@@ -193,51 +193,51 @@ QString QFileInfo::group() const
193*/ 193*/
194 194
195uint QFileInfo::groupId() const 195uint QFileInfo::groupId() const
196{ 196{
197 if ( !fic || !cache ) 197 if ( !fic || !cache )
198 doStat(); 198 doStat();
199 if ( fic ) 199 if ( fic )
200 return fic->st.st_gid; 200 return fic->st.st_gid;
201 return nobodyID; 201 return nobodyID;
202} 202}
203 203
204 204
205/*! 205/*!
206 Tests for file permissions. The \a permissionSpec argument can be 206 Tests for file permissions. The \a permissionSpec argument can be
207 several flags of type \c PermissionSpec OR-ed together to check 207 several flags of type \c PermissionSpec OR-ed together to check
208 for permission combinations. 208 for permission combinations.
209 209
210 On systems where files do not have permissions this function 210 On systems where files do not have permissions this function
211 always returns TRUE. 211 always returns TRUE.
212 212
213 Example: 213 Example:
214 \code 214 \code
215 QFileInfo fi( "/tmp/archive.tar.gz" ); 215 QFileInfo fi( "/tmp/archive.tar.gz" );
216 if ( fi.permission( QFileInfo::WriteUser | QFileInfo::ReadGroup ) ) 216 if ( fi.permission( QFileInfo::WriteUser | QFileInfo::ReadGroup ) )
217 qWarning( "I can change the file; my group can read the file."); 217 qWarning( "I can change the file; my group can read the file" );
218 if ( fi.permission( QFileInfo::WriteGroup | QFileInfo::WriteOther ) ) 218 if ( fi.permission( QFileInfo::WriteGroup | QFileInfo::WriteOther ) )
219 qWarning( "The group or others can change the file!" ); 219 qWarning( "The group or others can change the file" );
220 \endcode 220 \endcode
221 221
222 \sa isReadable(), isWritable(), isExecutable() 222 \sa isReadable(), isWritable(), isExecutable()
223*/ 223*/
224 224
225bool QFileInfo::permission( int permissionSpec ) const 225bool QFileInfo::permission( int permissionSpec ) const
226{ 226{
227 if ( !fic || !cache ) 227 if ( !fic || !cache )
228 doStat(); 228 doStat();
229 if ( fic ) { 229 if ( fic ) {
230 uint mask = 0; 230 uint mask = 0;
231 if ( permissionSpec & ReadUser ) 231 if ( permissionSpec & ReadUser )
232 mask |= S_IRUSR; 232 mask |= S_IRUSR;
233 if ( permissionSpec & WriteUser ) 233 if ( permissionSpec & WriteUser )
234 mask |= S_IWUSR; 234 mask |= S_IWUSR;
235 if ( permissionSpec & ExeUser ) 235 if ( permissionSpec & ExeUser )
236 mask |= S_IXUSR; 236 mask |= S_IXUSR;
237 if ( permissionSpec & ReadGroup ) 237 if ( permissionSpec & ReadGroup )
238 mask |= S_IRGRP; 238 mask |= S_IRGRP;
239 if ( permissionSpec & WriteGroup ) 239 if ( permissionSpec & WriteGroup )
240 mask |= S_IWGRP; 240 mask |= S_IWGRP;
241 if ( permissionSpec & ExeGroup ) 241 if ( permissionSpec & ExeGroup )
242 mask |= S_IXGRP; 242 mask |= S_IXGRP;
243 if ( permissionSpec & ReadOther ) 243 if ( permissionSpec & ReadOther )
diff --git a/qmake/tools/qgarray.cpp b/qmake/tools/qgarray.cpp
index 45c45ce..0a522e4 100644
--- a/qmake/tools/qgarray.cpp
+++ b/qmake/tools/qgarray.cpp
@@ -14,63 +14,73 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38 #include "qglobal.h" // needed to define Q_WS_WIN 38#include "qglobal.h"
39#ifdef Q_WS_WIN 39#if defined(Q_CC_BOR)
40 #include "qt_windows.h" // needed for bsearch on some platforms 40 // needed for qsort() because of a std namespace problem on Borland
41# include "qplatformdefs.h"
42#elif defined(Q_WS_WIN)
43 // needed for bsearch on some platforms
44# include "qt_windows.h"
41#endif 45#endif
42 46
43 #define QGARRAY_CPP 47 #define QGARRAY_CPP
44#include "qgarray.h" 48#include "qgarray.h"
45#include <stdlib.h> 49#include <stdlib.h>
46#include <string.h> 50#include <string.h>
47 51
48#ifdef QT_THREAD_SUPPORT 52#ifdef QT_THREAD_SUPPORT
49# include <private/qmutexpool_p.h> 53# include <private/qmutexpool_p.h>
50#endif // QT_THREAD_SUPPORT 54#endif // QT_THREAD_SUPPORT
51 55
52 #define USE_MALLOC // comment to use new/delete 56/*
57 If USE_MALLOC isn't defined, we use new[] and delete[] to allocate
58 memory. The documentation for QMemArray<T>::assign() explicitly
59 mentions that the array is freed using free(), so don't mess around
60 with USE_MALLOC unless you know what you're doing.
61*/
62#define USE_MALLOC
53 63
54#undef NEW 64#undef NEW
55#undef DELETE 65#undef DELETE
56 66
57#if defined(USE_MALLOC) 67#if defined(USE_MALLOC)
58 #define NEW(type,size)((type*)malloc(size*sizeof(type))) 68 #define NEW(type,size)((type*)malloc(size*sizeof(type)))
59 #define DELETE(array)(free((char*)array)) 69 #define DELETE(array)(free((char*)array))
60#else 70#else
61 #define NEW(type,size)(new type[size]) 71 #define NEW(type,size)(new type[size])
62 #define DELETE(array)(delete[] array) 72 #define DELETE(array)(delete[] array)
63 #define DONT_USE_REALLOC // comment to use realloc() 73 #define DONT_USE_REALLOC // comment to use realloc()
64#endif 74#endif
65 75
66/*! 76/*!
67 \class QShared qshared.h 77 \class QShared qshared.h
68 \reentrant 78 \reentrant
69 \ingroup shared 79 \ingroup shared
70 \brief The QShared class is used internally for implementing shared classes. 80 \brief The QShared class is used internally for implementing shared classes.
71 81
72 \internal 82 \internal
73 83
74 It only contains a reference count and member functions to increment and 84 It only contains a reference count and member functions to increment and
75 decrement it. 85 decrement it.
76 86
@@ -114,49 +124,53 @@ QGArray::QGArray()
114*/ 124*/
115 125
116QGArray::QGArray( int, int ) 126QGArray::QGArray( int, int )
117{ 127{
118} 128}
119 129
120/*! 130/*!
121 Constructs an array with room for \a size bytes. 131 Constructs an array with room for \a size bytes.
122*/ 132*/
123 133
124QGArray::QGArray( int size ) 134QGArray::QGArray( int size )
125{ 135{
126 if ( size < 0 ) { 136 if ( size < 0 ) {
127#if defined(QT_CHECK_RANGE) 137#if defined(QT_CHECK_RANGE)
128 qWarning( "QGArray: Cannot allocate array with negative length" ); 138 qWarning( "QGArray: Cannot allocate array with negative length" );
129#endif 139#endif
130 size = 0; 140 size = 0;
131 } 141 }
132 shd = newData(); 142 shd = newData();
133 Q_CHECK_PTR( shd ); 143 Q_CHECK_PTR( shd );
134 if ( size == 0 ) // zero length 144 if ( size == 0 ) // zero length
135 return; 145 return;
136 shd->data = NEW(char,size); 146 shd->data = NEW(char,size);
137 Q_CHECK_PTR( shd->data ); 147 Q_CHECK_PTR( shd->data );
138 shd->len = size; 148 shd->len =
149#ifdef QT_QGARRAY_SPEED_OPTIM
150 shd->maxl =
151#endif
152 size;
139} 153}
140 154
141/*! 155/*!
142 Constructs a shallow copy of \a a. 156 Constructs a shallow copy of \a a.
143*/ 157*/
144 158
145QGArray::QGArray( const QGArray &a ) 159QGArray::QGArray( const QGArray &a )
146{ 160{
147 shd = a.shd; 161 shd = a.shd;
148 shd->ref(); 162 shd->ref();
149} 163}
150 164
151/*! 165/*!
152 Dereferences the array data and deletes it if this was the last 166 Dereferences the array data and deletes it if this was the last
153 reference. 167 reference.
154*/ 168*/
155 169
156QGArray::~QGArray() 170QGArray::~QGArray()
157{ 171{
158 if ( shd && shd->deref() ) { // delete when last reference 172 if ( shd && shd->deref() ) { // delete when last reference
159 if ( shd->data ) // is lost 173 if ( shd->data ) // is lost
160 DELETE(shd->data); 174 DELETE(shd->data);
161 deleteData( shd ); 175 deleteData( shd );
162 shd = 0; 176 shd = 0;
@@ -191,77 +205,112 @@ QGArray::~QGArray()
191 205
192/*! 206/*!
193 \fn uint QGArray::size() const 207 \fn uint QGArray::size() const
194 208
195 Returns the size of the array, in bytes. 209 Returns the size of the array, in bytes.
196*/ 210*/
197 211
198 212
199/*! 213/*!
200 Returns TRUE if this array is equal to \a a, otherwise FALSE. 214 Returns TRUE if this array is equal to \a a, otherwise FALSE.
201 The comparison is bitwise, of course. 215 The comparison is bitwise, of course.
202*/ 216*/
203 217
204bool QGArray::isEqual( const QGArray &a ) const 218bool QGArray::isEqual( const QGArray &a ) const
205{ 219{
206 if ( size() != a.size() ) // different size 220 if ( size() != a.size() ) // different size
207 return FALSE; 221 return FALSE;
208 if ( data() == a.data() ) // has same data 222 if ( data() == a.data() ) // has same data
209 return TRUE; 223 return TRUE;
210 return (size() ? memcmp( data(), a.data(), size() ) : 0) == 0; 224 return (size() ? memcmp( data(), a.data(), size() ) : 0) == 0;
211} 225}
212 226
213 227
214/*! 228/*!
215 Resizes the array to \a newsize bytes. 229 Resizes the array to \a newsize bytes. \a optim is either
230 MemOptim (the default) or SpeedOptim.
216*/ 231*/
217 232bool QGArray::resize( uint newsize, Optimization optim )
218bool QGArray::resize( uint newsize )
219{ 233{
220 if ( newsize == shd->len ) // nothing to do 234#ifndef QT_QGARRAY_SPEED_OPTIM
235 Q_UNUSED(optim);
236#endif
237
238 if ( newsize == shd->len
239#ifdef QT_QGARRAY_SPEED_OPTIM
240 && newsize == shd->maxl
241#endif
242 ) // nothing to do
221 return TRUE; 243 return TRUE;
222 if ( newsize == 0 ) { // remove array 244 if ( newsize == 0 ) { // remove array
223 duplicate( 0, 0 ); 245 duplicate( 0, 0 );
224 return TRUE; 246 return TRUE;
225 } 247 }
248
249 uint newmaxl = newsize;
250#ifdef QT_QGARRAY_SPEED_OPTIM
251 if ( optim == SpeedOptim ) {
252 if ( newsize <= shd->maxl &&
253 ( newsize * 4 > shd->maxl || shd->maxl <= 4 ) ) {
254 shd->len = newsize;
255 return TRUE;
256 }
257 newmaxl = 4;
258 while ( newmaxl < newsize )
259 newmaxl *= 2;
260 // try to spare some memory
261 if ( newmaxl >= 1024 * 1024 && newsize <= newmaxl - (newmaxl >> 2) )
262 newmaxl -= newmaxl >> 2;
263 }
264 shd->maxl = newmaxl;
265#endif
266
226 if ( shd->data ) { // existing data 267 if ( shd->data ) { // existing data
227#if defined(DONT_USE_REALLOC) 268#if defined(DONT_USE_REALLOC)
228 char *newdata = NEW(char,newsize);// manual realloc 269 char *newdata = NEW(char,newsize);// manual realloc
229 memcpy( newdata, shd->data, QMIN(shd->len,newsize) ); 270 memcpy( newdata, shd->data, QMIN(shd->len,newmaxl) );
230 DELETE(shd->data); 271 DELETE(shd->data);
231 shd->data = newdata; 272 shd->data = newdata;
232#else 273#else
233 shd->data = (char *)realloc( shd->data, newsize ); 274 shd->data = (char *)realloc( shd->data, newmaxl );
234#endif 275#endif
235 } else { 276 } else {
236 shd->data = NEW(char,newsize); 277 shd->data = NEW(char,newmaxl);
237 } 278 }
238 if ( !shd->data ) // no memory 279 if ( !shd->data ) // no memory
239 return FALSE; 280 return FALSE;
240 shd->len = newsize; 281 shd->len = newsize;
241 return TRUE; 282 return TRUE;
242} 283}
243 284
285/*!\overload
286*/
287bool QGArray::resize( uint newsize )
288{
289 return resize( newsize, MemOptim );
290}
291
292
244/*! 293/*!
245 Fills the array with the repeated occurrences of \a d, which is 294 Fills the array with the repeated occurrences of \a d, which is
246 \a sz bytes long. 295 \a sz bytes long.
247 If \a len is specified as different from -1, then the array will be 296 If \a len is specified as different from -1, then the array will be
248 resized to \a len*sz before it is filled. 297 resized to \a len*sz before it is filled.
249 298
250 Returns TRUE if successful, or FALSE if the memory cannot be allocated 299 Returns TRUE if successful, or FALSE if the memory cannot be allocated
251 (only when \a len != -1). 300 (only when \a len != -1).
252 301
253 \sa resize() 302 \sa resize()
254*/ 303*/
255 304
256bool QGArray::fill( const char *d, int len, uint sz ) 305bool QGArray::fill( const char *d, int len, uint sz )
257{ 306{
258 if ( len < 0 ) 307 if ( len < 0 )
259 len = shd->len/sz; // default: use array length 308 len = shd->len/sz; // default: use array length
260 else if ( !resize( len*sz ) ) 309 else if ( !resize( len*sz ) )
261 return FALSE; 310 return FALSE;
262 if ( sz == 1 ) // 8 bit elements 311 if ( sz == 1 ) // 8 bit elements
263 memset( data(), *d, len ); 312 memset( data(), *d, len );
264 else if ( sz == 4 ) { // 32 bit elements 313 else if ( sz == 4 ) { // 32 bit elements
265 register Q_INT32 *x = (Q_INT32*)data(); 314 register Q_INT32 *x = (Q_INT32*)data();
266 Q_INT32 v = *((Q_INT32*)d); 315 Q_INT32 v = *((Q_INT32*)d);
267 while ( len-- ) 316 while ( len-- )
@@ -298,132 +347,144 @@ QGArray &QGArray::assign( const QGArray &a )
298 } 347 }
299 shd = a.shd; 348 shd = a.shd;
300 return *this; 349 return *this;
301} 350}
302 351
303/*! 352/*!
304 Shallow copy. Dereference the current array and references the 353 Shallow copy. Dereference the current array and references the
305 array data \a d, which contains \a len bytes. 354 array data \a d, which contains \a len bytes.
306 Returns a reference to this array. 355 Returns a reference to this array.
307 356
308 Do not delete \a d later, because QGArray takes care of that. 357 Do not delete \a d later, because QGArray takes care of that.
309*/ 358*/
310 359
311QGArray &QGArray::assign( const char *d, uint len ) 360QGArray &QGArray::assign( const char *d, uint len )
312{ 361{
313 if ( shd->count > 1 ) { // disconnect this 362 if ( shd->count > 1 ) { // disconnect this
314 shd->count--; 363 shd->count--;
315 shd = newData(); 364 shd = newData();
316 Q_CHECK_PTR( shd ); 365 Q_CHECK_PTR( shd );
317 } else { 366 } else {
318 if ( shd->data ) 367 if ( shd->data )
319 DELETE(shd->data); 368 DELETE(shd->data);
320 } 369 }
321 shd->data = (char *)d; 370 shd->data = (char *)d;
322 shd->len = len; 371 shd->len =
372#ifdef QT_QGARRAY_SPEED_OPTIM
373 shd->maxl =
374#endif
375 len;
323 return *this; 376 return *this;
324} 377}
325 378
326/*! 379/*!
327 Deep copy. Dereference the current array and obtains a copy of the data 380 Deep copy. Dereference the current array and obtains a copy of the data
328 contained in \a a instead. Returns a reference to this array. 381 contained in \a a instead. Returns a reference to this array.
329 \sa assign(), operator=() 382 \sa assign(), operator=()
330*/ 383*/
331 384
332QGArray &QGArray::duplicate( const QGArray &a ) 385QGArray &QGArray::duplicate( const QGArray &a )
333{ 386{
334 if ( a.shd == shd ) { // a.duplicate(a) ! 387 if ( a.shd == shd ) { // a.duplicate(a) !
335 if ( shd->count > 1 ) { 388 if ( shd->count > 1 ) {
336 shd->count--; 389 shd->count--;
337 register array_data *n = newData(); 390 register array_data *n = newData();
338 Q_CHECK_PTR( n ); 391 Q_CHECK_PTR( n );
339 if ( (n->len=shd->len) ) { 392 if ( (n->len=shd->len) ) {
340 n->data = NEW(char,n->len); 393 n->data = NEW(char,n->len);
341 Q_CHECK_PTR( n->data ); 394 Q_CHECK_PTR( n->data );
342 if ( n->data ) 395 if ( n->data )
343 memcpy( n->data, shd->data, n->len ); 396 memcpy( n->data, shd->data, n->len );
344 } else { 397 } else {
345 n->data = 0; 398 n->data = 0;
346 } 399 }
347 shd = n; 400 shd = n;
348 } 401 }
349 return *this; 402 return *this;
350 } 403 }
351 char *oldptr = 0; 404 char *oldptr = 0;
352 if ( shd->count > 1 ) { // disconnect this 405 if ( shd->count > 1 ) { // disconnect this
353 shd->count--; 406 shd->count--;
354 shd = newData(); 407 shd = newData();
355 Q_CHECK_PTR( shd ); 408 Q_CHECK_PTR( shd );
356 } else { // delete after copy was made 409 } else { // delete after copy was made
357 oldptr = shd->data; 410 oldptr = shd->data;
358 } 411 }
359 if ( a.shd->len ) { // duplicate data 412 if ( a.shd->len ) { // duplicate data
360 shd->data = NEW(char,a.shd->len); 413 shd->data = NEW(char,a.shd->len);
361 Q_CHECK_PTR( shd->data ); 414 Q_CHECK_PTR( shd->data );
362 if ( shd->data ) 415 if ( shd->data )
363 memcpy( shd->data, a.shd->data, a.shd->len ); 416 memcpy( shd->data, a.shd->data, a.shd->len );
364 } else { 417 } else {
365 shd->data = 0; 418 shd->data = 0;
366 } 419 }
367 shd->len = a.shd->len; 420 shd->len =
421#ifdef QT_QGARRAY_SPEED_OPTIM
422 shd->maxl =
423#endif
424 a.shd->len;
368 if ( oldptr ) 425 if ( oldptr )
369 DELETE(oldptr); 426 DELETE(oldptr);
370 return *this; 427 return *this;
371} 428}
372 429
373/*! 430/*!
374 \overload 431 \overload
375 Deep copy. Dereferences the current array and obtains a copy of 432 Deep copy. Dereferences the current array and obtains a copy of
376 \a len characters from array data \a d instead. Returns a reference 433 \a len characters from array data \a d instead. Returns a reference
377 to this array. 434 to this array.
378 \sa assign(), operator=() 435 \sa assign(), operator=()
379*/ 436*/
380 437
381QGArray &QGArray::duplicate( const char *d, uint len ) 438QGArray &QGArray::duplicate( const char *d, uint len )
382{ 439{
383 char *data; 440 char *data;
384 if ( d == 0 || len == 0 ) { 441 if ( d == 0 || len == 0 ) {
385 data = 0; 442 data = 0;
386 len = 0; 443 len = 0;
387 } else { 444 } else {
388 if ( shd->count == 1 && shd->len == len ) { 445 if ( shd->count == 1 && shd->len == len ) {
389 memcpy( shd->data, d, len );// use same buffer 446 memcpy( shd->data, d, len );// use same buffer
390 return *this; 447 return *this;
391 } 448 }
392 data = NEW(char,len); 449 data = NEW(char,len);
393 Q_CHECK_PTR( data ); 450 Q_CHECK_PTR( data );
394 memcpy( data, d, len ); 451 memcpy( data, d, len );
395 } 452 }
396 if ( shd->count > 1 ) { // detach 453 if ( shd->count > 1 ) { // detach
397 shd->count--; 454 shd->count--;
398 shd = newData(); 455 shd = newData();
399 Q_CHECK_PTR( shd ); 456 Q_CHECK_PTR( shd );
400 } else { // just a single reference 457 } else { // just a single reference
401 if ( shd->data ) 458 if ( shd->data )
402 DELETE(shd->data); 459 DELETE(shd->data);
403 } 460 }
404 shd->data = data; 461 shd->data = data;
405 shd->len = len; 462 shd->len =
463#ifdef QT_QGARRAY_SPEED_OPTIM
464 shd->maxl =
465#endif
466 len;
406 return *this; 467 return *this;
407} 468}
408 469
409/*! 470/*!
410 Resizes this array to \a len bytes and copies the \a len bytes at 471 Resizes this array to \a len bytes and copies the \a len bytes at
411 address \a d into it. 472 address \a d into it.
412 473
413 \warning This function disregards the reference count mechanism. If 474 \warning This function disregards the reference count mechanism. If
414 other QGArrays reference the same data as this, all will be updated. 475 other QGArrays reference the same data as this, all will be updated.
415*/ 476*/
416 477
417void QGArray::store( const char *d, uint len ) 478void QGArray::store( const char *d, uint len )
418 { // store, but not deref 479 { // store, but not deref
419 resize( len ); 480 resize( len );
420 memcpy( shd->data, d, len ); 481 memcpy( shd->data, d, len );
421} 482}
422 483
423 484
424/*! 485/*!
425 \fn array_data *QGArray::sharedBlock() const 486 \fn array_data *QGArray::sharedBlock() const
426 487
427 Returns a pointer to the shared array block. 488 Returns a pointer to the shared array block.
428 489
429 \warning 490 \warning
@@ -638,67 +699,69 @@ static int __cdecl cmp_arr( const void *n1, const void *n2 )
638#else 699#else
639static int cmp_arr( const void *n1, const void *n2 ) 700static int cmp_arr( const void *n1, const void *n2 )
640#endif 701#endif
641{ 702{
642 return ( n1 && n2 ) ? memcmp( n1, n2, cmp_item_size ) 703 return ( n1 && n2 ) ? memcmp( n1, n2, cmp_item_size )
643 : ( n1 ? 1 : ( n2 ? -1 : 0 ) ); 704 : ( n1 ? 1 : ( n2 ? -1 : 0 ) );
644 // ### Qt 3.0: Add a virtual compareItems() method and call that instead 705 // ### Qt 3.0: Add a virtual compareItems() method and call that instead
645} 706}
646 707
647#if defined(Q_C_CALLBACKS) 708#if defined(Q_C_CALLBACKS)
648} 709}
649#endif 710#endif
650 711
651/*! 712/*!
652 Sorts the first \a sz items of the array. 713 Sorts the first \a sz items of the array.
653*/ 714*/
654 715
655void QGArray::sort( uint sz ) 716void QGArray::sort( uint sz )
656{ 717{
657 int numItems = size() / sz; 718 int numItems = size() / sz;
658 if ( numItems < 2 ) 719 if ( numItems < 2 )
659 return; 720 return;
660 721
661#ifdef QT_THREAD_SUPPORT 722#ifdef QT_THREAD_SUPPORT
662 QMutexLocker locker( qt_global_mutexpool->get( &cmp_item_size ) ); 723 QMutexLocker locker( qt_global_mutexpool ?
724 qt_global_mutexpool->get( &cmp_item_size ) : 0 );
663#endif // QT_THREAD_SUPPORT 725#endif // QT_THREAD_SUPPORT
664 726
665 cmp_item_size = sz; 727 cmp_item_size = sz;
666 qsort( shd->data, numItems, sz, cmp_arr ); 728 qsort( shd->data, numItems, sz, cmp_arr );
667} 729}
668 730
669/*! 731/*!
670 Binary search; assumes that \a d is a sorted array of size \a sz. 732 Binary search; assumes that \a d is a sorted array of size \a sz.
671*/ 733*/
672 734
673int QGArray::bsearch( const char *d, uint sz ) const 735int QGArray::bsearch( const char *d, uint sz ) const
674{ 736{
675 int numItems = size() / sz; 737 int numItems = size() / sz;
676 if ( !numItems ) 738 if ( !numItems )
677 return -1; 739 return -1;
678 740
679#ifdef QT_THREAD_SUPPORT 741#ifdef QT_THREAD_SUPPORT
680 QMutexLocker locker( qt_global_mutexpool->get( &cmp_item_size ) ); 742 QMutexLocker locker( qt_global_mutexpool ?
743 qt_global_mutexpool->get( &cmp_item_size ) : 0 );
681#endif // QT_THREAD_SUPPORT 744#endif // QT_THREAD_SUPPORT
682 745
683 cmp_item_size = sz; 746 cmp_item_size = sz;
684 char* r = (char*)::bsearch( d, shd->data, numItems, sz, cmp_arr ); 747 char* r = (char*)::bsearch( d, shd->data, numItems, sz, cmp_arr );
685 if ( !r ) 748 if ( !r )
686 return -1; 749 return -1;
687 while( (r >= shd->data + sz) && (cmp_arr( r - sz, d ) == 0) ) 750 while( (r >= shd->data + sz) && (cmp_arr( r - sz, d ) == 0) )
688 r -= sz;// search to first of equal elements; bsearch is undef 751 r -= sz;// search to first of equal elements; bsearch is undef
689 return (int)(( r - shd->data ) / sz); 752 return (int)(( r - shd->data ) / sz);
690} 753}
691 754
692 755
693/*! 756/*!
694 \fn char *QGArray::at( uint index ) const 757 \fn char *QGArray::at( uint index ) const
695 758
696 Returns a pointer to the byte at offset \a index in the array. 759 Returns a pointer to the byte at offset \a index in the array.
697*/ 760*/
698 761
699/*! 762/*!
700 Expand the array if necessary, and copies (the first part of) its 763 Expand the array if necessary, and copies (the first part of) its
701 contents from the \a index * \a sz bytes at \a d. 764 contents from the \a index * \a sz bytes at \a d.
702 765
703 Returns TRUE if the operation succeeds, FALSE if it runs out of 766 Returns TRUE if the operation succeeds, FALSE if it runs out of
704 memory. 767 memory.
diff --git a/qmake/tools/qgdict.cpp b/qmake/tools/qgdict.cpp
index c431ff8..3d49fc7 100644
--- a/qmake/tools/qgdict.cpp
+++ b/qmake/tools/qgdict.cpp
@@ -183,49 +183,52 @@ QDataStream& QGDict::write( QDataStream &s, QPtrCollection::Item ) const
183} 183}
184#endif //QT_NO_DATASTREAM 184#endif //QT_NO_DATASTREAM
185 185
186/***************************************************************************** 186/*****************************************************************************
187 QGDict member functions 187 QGDict member functions
188 *****************************************************************************/ 188 *****************************************************************************/
189 189
190/*! 190/*!
191 Constructs a dictionary. 191 Constructs a dictionary.
192 192
193 \a len is the initial size of the dictionary. 193 \a len is the initial size of the dictionary.
194 The key type is \a kt which may be \c StringKey, \c AsciiKey, 194 The key type is \a kt which may be \c StringKey, \c AsciiKey,
195 \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with 195 \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with
196 \a caseSensitive. Keys are copied if \a copyKeys is TRUE. 196 \a caseSensitive. Keys are copied if \a copyKeys is TRUE.
197*/ 197*/
198 198
199QGDict::QGDict( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) 199QGDict::QGDict( uint len, KeyType kt, bool caseSensitive, bool copyKeys )
200{ 200{
201 init( len, kt, caseSensitive, copyKeys ); 201 init( len, kt, caseSensitive, copyKeys );
202} 202}
203 203
204 204
205void QGDict::init( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) 205void QGDict::init( uint len, KeyType kt, bool caseSensitive, bool copyKeys )
206{ 206{
207 vec = new QBaseBucket *[vlen = len]; // allocate hash table 207 vlen = len;
208 if ( vlen == 0 )
209 vlen = 17;
210 vec = new QBaseBucket *[vlen];
208 Q_CHECK_PTR( vec ); 211 Q_CHECK_PTR( vec );
209 memset( (char*)vec, 0, vlen*sizeof(QBaseBucket*) ); 212 memset( (char*)vec, 0, vlen*sizeof(QBaseBucket*) );
210 numItems = 0; 213 numItems = 0;
211 iterators = 0; 214 iterators = 0;
212 // The caseSensitive and copyKey options don't make sense for 215 // The caseSensitive and copyKey options don't make sense for
213 // all dict types. 216 // all dict types.
214 switch ( (keytype = (uint)kt) ) { 217 switch ( (keytype = (uint)kt) ) {
215 case StringKey: 218 case StringKey:
216 cases = caseSensitive; 219 cases = caseSensitive;
217 copyk = FALSE; 220 copyk = FALSE;
218 break; 221 break;
219 case AsciiKey: 222 case AsciiKey:
220 cases = caseSensitive; 223 cases = caseSensitive;
221 copyk = copyKeys; 224 copyk = copyKeys;
222 break; 225 break;
223 default: 226 default:
224 cases = FALSE; 227 cases = FALSE;
225 copyk = FALSE; 228 copyk = FALSE;
226 break; 229 break;
227 } 230 }
228} 231}
229 232
230 233
231/*! 234/*!
diff --git a/qmake/tools/qglist.cpp b/qmake/tools/qglist.cpp
index 155d585..bd27f8a 100644
--- a/qmake/tools/qglist.cpp
+++ b/qmake/tools/qglist.cpp
@@ -308,54 +308,50 @@ bool QGList::operator==( const QGList &list ) const
308 308
309/*! 309/*!
310 \fn uint QGList::count() const 310 \fn uint QGList::count() const
311 311
312 Returns the number of items in the list. 312 Returns the number of items in the list.
313*/ 313*/
314 314
315 315
316/*! 316/*!
317 Returns the node at position \a index. Sets this node to current. 317 Returns the node at position \a index. Sets this node to current.
318*/ 318*/
319 319
320QLNode *QGList::locate( uint index ) 320QLNode *QGList::locate( uint index )
321{ 321{
322 if ( index == (uint)curIndex ) // current node ? 322 if ( index == (uint)curIndex ) // current node ?
323 return curNode; 323 return curNode;
324 if ( !curNode && firstNode ) { // set current node 324 if ( !curNode && firstNode ) { // set current node
325 curNode = firstNode; 325 curNode = firstNode;
326 curIndex = 0; 326 curIndex = 0;
327 } 327 }
328 register QLNode *node; 328 register QLNode *node;
329 int distance = index - curIndex; // node distance to cur node 329 int distance = index - curIndex; // node distance to cur node
330 bool forward; // direction to traverse 330 bool forward; // direction to traverse
331 331
332 if ( index >= numNodes ) { 332 if ( index >= numNodes )
333#if defined(QT_CHECK_RANGE)
334 qWarning( "QGList::locate: Index %d out of range", index );
335#endif
336 return 0; 333 return 0;
337 }
338 334
339 if ( distance < 0 ) 335 if ( distance < 0 )
340 distance = -distance; 336 distance = -distance;
341 if ( (uint)distance < index && (uint)distance < numNodes - index ) { 337 if ( (uint)distance < index && (uint)distance < numNodes - index ) {
342 node = curNode; // start from current node 338 node = curNode; // start from current node
343 forward = index > (uint)curIndex; 339 forward = index > (uint)curIndex;
344 } else if ( index < numNodes - index ) {// start from first node 340 } else if ( index < numNodes - index ) {// start from first node
345 node = firstNode; 341 node = firstNode;
346 distance = index; 342 distance = index;
347 forward = TRUE; 343 forward = TRUE;
348 } else { // start from last node 344 } else { // start from last node
349 node = lastNode; 345 node = lastNode;
350 distance = numNodes - index - 1; 346 distance = numNodes - index - 1;
351 if ( distance < 0 ) 347 if ( distance < 0 )
352 distance = 0; 348 distance = 0;
353 forward = FALSE; 349 forward = FALSE;
354 } 350 }
355 if ( forward ) { // now run through nodes 351 if ( forward ) { // now run through nodes
356 while ( distance-- ) 352 while ( distance-- )
357 node = node->next; 353 node = node->next;
358 } else { 354 } else {
359 while ( distance-- ) 355 while ( distance-- )
360 node = node->prev; 356 node = node->prev;
361 } 357 }
diff --git a/qmake/tools/qglobal.cpp b/qmake/tools/qglobal.cpp
index 47cd6bd..342005d 100644
--- a/qmake/tools/qglobal.cpp
+++ b/qmake/tools/qglobal.cpp
@@ -128,49 +128,70 @@ bool qSysInfo( int *wordSize, bool *bigEndian )
128 unsigned char *p = (unsigned char *)(&ns);// 16-bit integer 128 unsigned char *p = (unsigned char *)(&ns);// 16-bit integer
129 be16 = *p == 0x12; 129 be16 = *p == 0x12;
130 130
131 p = (unsigned char *)(&nl); // 32-bit integer 131 p = (unsigned char *)(&nl); // 32-bit integer
132 if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 ) 132 if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 )
133 be32 = TRUE; 133 be32 = TRUE;
134 else 134 else
135 if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 ) 135 if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 )
136 be32 = FALSE; 136 be32 = FALSE;
137 else 137 else
138 be32 = !be16; 138 be32 = !be16;
139 139
140 if ( be16 != be32 ) { // strange machine! 140 if ( be16 != be32 ) { // strange machine!
141#if defined(QT_CHECK_RANGE) 141#if defined(QT_CHECK_RANGE)
142 qFatal( "qSysInfo: Inconsistent system byte order" ); 142 qFatal( "qSysInfo: Inconsistent system byte order" );
143#endif 143#endif
144 return FALSE; 144 return FALSE;
145 } 145 }
146 146
147 *bigEndian = si_bigEndian = be32; 147 *bigEndian = si_bigEndian = be32;
148 si_alreadyDone = TRUE; 148 si_alreadyDone = TRUE;
149 return TRUE; 149 return TRUE;
150} 150}
151 151
152#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) 152#if !defined(QWS) && defined(Q_OS_MAC)
153
154#include "qt_mac.h"
155
156int qMacVersion()
157{
158 static int macver = Qt::MV_Unknown;
159 static bool first = TRUE;
160 if(first) {
161 first = FALSE;
162 long gestalt_version;
163 if(Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
164 if(gestalt_version >= 0x1020 && gestalt_version < 0x1030)
165 macver = Qt::MV_10_DOT_2;
166 else if(gestalt_version >= 0x1010 && gestalt_version < 0x1020)
167 macver = Qt::MV_10_DOT_1;
168 }
169 }
170 return macver;
171}
172Qt::MacintoshVersion qt_macver = (Qt::MacintoshVersion)qMacVersion();
173#elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
153bool qt_winunicode; 174bool qt_winunicode;
154 175
155#include "qt_windows.h" 176#include "qt_windows.h"
156 177
157int qWinVersion() 178int qWinVersion()
158{ 179{
159#ifndef VER_PLATFORM_WIN32s 180#ifndef VER_PLATFORM_WIN32s
160 #define VER_PLATFORM_WIN32s 0 181 #define VER_PLATFORM_WIN32s 0
161#endif 182#endif
162#ifndef VER_PLATFORM_WIN32_WINDOWS 183#ifndef VER_PLATFORM_WIN32_WINDOWS
163#define VER_PLATFORM_WIN32_WINDOWS 1 184#define VER_PLATFORM_WIN32_WINDOWS 1
164#endif 185#endif
165#ifndef VER_PLATFORM_WIN32_NT 186#ifndef VER_PLATFORM_WIN32_NT
166 #define VER_PLATFORM_WIN32_NT 2 187 #define VER_PLATFORM_WIN32_NT 2
167#endif 188#endif
168 189
169 static int winver = Qt::WV_NT; 190 static int winver = Qt::WV_NT;
170 static int t=0; 191 static int t=0;
171 if ( !t ) { 192 if ( !t ) {
172 t=1; 193 t=1;
173#ifdef Q_OS_TEMP 194#ifdef Q_OS_TEMP
174 OSVERSIONINFOW osver; 195 OSVERSIONINFOW osver;
175 osver.dwOSVersionInfoSize = sizeof(osver); 196 osver.dwOSVersionInfoSize = sizeof(osver);
176 GetVersionEx( &osver ); 197 GetVersionEx( &osver );
@@ -300,65 +321,77 @@ Qt::WindowsVersion qt_winver = (Qt::WindowsVersion)qWinVersion();
300 qFatal( "divide: cannot divide by zero" ); 321 qFatal( "divide: cannot divide by zero" );
301 return a/b; 322 return a/b;
302 } 323 }
303 \endcode 324 \endcode
304 325
305 Under X11, the text is printed to stderr. Under Windows, the text 326 Under X11, the text is printed to stderr. Under Windows, the text
306 is sent to the debugger. 327 is sent to the debugger.
307 328
308 \warning The internal buffer is limited to 8196 bytes (including 329 \warning The internal buffer is limited to 8196 bytes (including
309 the '\0'-terminator). 330 the '\0'-terminator).
310 331
311 \warning Passing (const char *)0 as argument to qFatal might lead 332 \warning Passing (const char *)0 as argument to qFatal might lead
312 to crashes on certain platforms due to the platforms printf implementation. 333 to crashes on certain platforms due to the platforms printf implementation.
313 334
314 \sa qDebug(), qWarning(), qInstallMsgHandler(), 335 \sa qDebug(), qWarning(), qInstallMsgHandler(),
315 \link debug.html Debugging\endlink 336 \link debug.html Debugging\endlink
316*/ 337*/
317 338
318 339
319 static QtMsgHandler handler = 0; // pointer to debug handler 340 static QtMsgHandler handler = 0; // pointer to debug handler
320 static const int QT_BUFFER_LENGTH = 8196;// internal buffer length 341 static const int QT_BUFFER_LENGTH = 8196;// internal buffer length
321 342
322 343
323#ifdef Q_OS_MAC 344#ifdef Q_OS_MAC
324const unsigned char * p_str(const char * c, int len=-1) 345QString cfstring2qstring(CFStringRef str)
346{
347 CFIndex length = CFStringGetLength(str);
348 if(const UniChar *chars = CFStringGetCharactersPtr(str))
349 return QString((QChar *)chars, length);
350 UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar));
351 CFStringGetCharacters(str, CFRangeMake(0, length), buffer);
352 QString ret((QChar *)buffer, length);
353 free(buffer);
354 return ret;
355}
356
357unsigned char * p_str(const char * c, int len=-1)
325{ 358{
326 const int maxlen = 255; 359 const int maxlen = 255;
327 if(len == -1) 360 if(len == -1)
328 len = qstrlen(c); 361 len = qstrlen(c);
329 if(len > maxlen) { 362 if(len > maxlen) {
330 qWarning( "p_str len must never exceed %d", maxlen ); 363 qWarning( "p_str len must never exceed %d", maxlen );
331 len = maxlen; 364 len = maxlen;
332 } 365 }
333 unsigned char *ret = (unsigned char*)malloc(len+2); 366 unsigned char *ret = (unsigned char*)malloc(len+2);
334 *ret=len; 367 *ret=len;
335 memcpy(((char *)ret)+1,c,len); 368 memcpy(((char *)ret)+1,c,len);
336 *(ret+len+1) = '\0'; 369 *(ret+len+1) = '\0';
337 return ret; 370 return ret;
338} 371}
339 372
340const unsigned char * p_str(const QString &s) 373unsigned char * p_str(const QString &s)
341{ 374{
342 return p_str(s, s.length()); 375 return p_str(s, s.length());
343} 376}
344 377
345QCString p2qstring(const unsigned char *c) { 378QCString p2qstring(const unsigned char *c) {
346 char *arr = (char *)malloc(c[0] + 1); 379 char *arr = (char *)malloc(c[0] + 1);
347 memcpy(arr, c+1, c[0]); 380 memcpy(arr, c+1, c[0]);
348 arr[c[0]] = '\0'; 381 arr[c[0]] = '\0';
349 QCString ret = arr; 382 QCString ret = arr;
350 delete arr; 383 delete arr;
351 return ret; 384 return ret;
352} 385}
353#endif 386#endif
354 387
355 388
356#ifdef Q_CC_MWERKS 389#ifdef Q_CC_MWERKS
357 390
358#include "qt_mac.h" 391#include "qt_mac.h"
359 392
360extern bool qt_is_gui_used; 393extern bool qt_is_gui_used;
361static void mac_default_handler( const char *msg ) 394static void mac_default_handler( const char *msg )
362{ 395{
363 if ( qt_is_gui_used ) { 396 if ( qt_is_gui_used ) {
364 const char *p = p_str(msg); 397 const char *p = p_str(msg);
@@ -620,60 +653,60 @@ void qSystemWarning( const char* msg, int code )
620 #include <qglobal.h> 653 #include <qglobal.h>
621 654
622 int divide( int a, int b ) 655 int divide( int a, int b )
623 { 656 {
624 Q_ASSERT( b != 0 ); // this is line 9 657 Q_ASSERT( b != 0 ); // this is line 9
625 return a/b; 658 return a/b;
626 } 659 }
627 \endcode 660 \endcode
628 661
629 If \c b is zero, the Q_ASSERT statement will output the following 662 If \c b is zero, the Q_ASSERT statement will output the following
630 message using the qWarning() function: 663 message using the qWarning() function:
631 \code 664 \code
632 ASSERT: "b == 0" in div.cpp (9) 665 ASSERT: "b == 0" in div.cpp (9)
633 \endcode 666 \endcode
634 667
635 \sa qWarning(), \link debug.html Debugging\endlink 668 \sa qWarning(), \link debug.html Debugging\endlink
636*/ 669*/
637 670
638 671
639/*! 672/*!
640 \fn void Q_CHECK_PTR( void *p ) 673 \fn void Q_CHECK_PTR( void *p )
641 674
642 \relates QApplication 675 \relates QApplication
643 676
644 If \a p is null, a fatal messages says that the program ran out of 677 If \a p is 0, a fatal messages says that the program ran out of
645 memory and exits. If \e p is not null, nothing happens. 678 memory and exits. If \e p is not 0, nothing happens.
646 679
647 This is really a macro defined in \c qglobal.h. 680 This is really a macro defined in \c qglobal.h.
648 681
649 Example: 682 Example:
650 \code 683 \code
651 int *a; 684 int *a;
652 685
653 Q_CHECK_PTR( a = new int[80] ); // WRONG! 686 Q_CHECK_PTR( a = new int[80] ); // WRONG!
654 687
655 a = new int[80]; // Right 688 a = new (nothrow) int[80]; // Right
656 Q_CHECK_PTR( a ); 689 Q_CHECK_PTR( a );
657 \endcode 690 \endcode
658 691
659 \sa qFatal(), \link debug.html Debugging\endlink 692 \sa qFatal(), \link debug.html Debugging\endlink
660*/ 693*/
661 694
662 695
663// 696//
664// The Q_CHECK_PTR macro calls this function to check if an allocation went ok. 697// The Q_CHECK_PTR macro calls this function to check if an allocation went ok.
665// 698//
666#if (QT_VERSION-0 >= 0x040000) 699#if (QT_VERSION-0 >= 0x040000)
667#if defined(Q_CC_GNU) 700#if defined(Q_CC_GNU)
668#warning "Change Q_CHECK_PTR to '{if ((p)==0) qt_check_pointer(__FILE__,__LINE__);}'" 701#warning "Change Q_CHECK_PTR to '{if ((p)==0) qt_check_pointer(__FILE__,__LINE__);}'"
669#warning "No need for qt_check_pointer() to return a value - make it void!" 702#warning "No need for qt_check_pointer() to return a value - make it void!"
670#endif 703#endif
671#endif 704#endif
672bool qt_check_pointer( bool c, const char *n, int l ) 705bool qt_check_pointer( bool c, const char *n, int l )
673{ 706{
674 if ( c ) 707 if ( c )
675 qWarning( "In file %s, line %d: Out of memory", n, l ); 708 qWarning( "In file %s, line %d: Out of memory", n, l );
676 return TRUE; 709 return TRUE;
677} 710}
678 711
679 712
diff --git a/qmake/tools/qgpluginmanager.cpp b/qmake/tools/qgpluginmanager.cpp
index 46c85f5..72246ac 100644
--- a/qmake/tools/qgpluginmanager.cpp
+++ b/qmake/tools/qgpluginmanager.cpp
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QGPluginManager class 4** Implementation of QGPluginManager class
5** 5**
6** Copyright (C) 2000-2001 Trolltech AS. All rights reserved. 6** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
7** 7**
8** This file is part of the tools module of the Qt GUI Toolkit. 8** This file is part of the tools module of the Qt GUI Toolkit.
9** 9**
10** This file may be distributed under the terms of the Q Public License 10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file 11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file. 12** LICENSE.QPL included in the packaging of this file.
13** 13**
14** This file may be distributed and/or modified under the terms of the 14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software 15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the 16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file. 17** packaging of this file.
18** 18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License 20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software. 21** Agreement provided with the Software.
22** 22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25** 25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements. 27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information. 28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information. 29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30** 30**
@@ -454,49 +454,49 @@ bool QGPluginManager::addLibrary( QLibrary* lib )
454 454
455 QComLibrary* plugin = (QComLibrary*)lib; 455 QComLibrary* plugin = (QComLibrary*)lib;
456 bool useful = FALSE; 456 bool useful = FALSE;
457 457
458 QUnknownInterface* iFace = 0; 458 QUnknownInterface* iFace = 0;
459 plugin->queryInterface( interfaceId, &iFace ); 459 plugin->queryInterface( interfaceId, &iFace );
460 if ( iFace ) { 460 if ( iFace ) {
461 QFeatureListInterface *fliFace = 0; 461 QFeatureListInterface *fliFace = 0;
462 QComponentInformationInterface *cpiFace = 0; 462 QComponentInformationInterface *cpiFace = 0;
463 iFace->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); 463 iFace->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace );
464 if ( !fliFace ) 464 if ( !fliFace )
465 plugin->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace ); 465 plugin->queryInterface( IID_QFeatureList, (QUnknownInterface**)&fliFace );
466 if ( !fliFace ) { 466 if ( !fliFace ) {
467 iFace->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); 467 iFace->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace );
468 if ( !cpiFace ) 468 if ( !cpiFace )
469 plugin->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace ); 469 plugin->queryInterface( IID_QComponentInformation, (QUnknownInterface**)&cpiFace );
470 } 470 }
471 QStringList fl; 471 QStringList fl;
472 if ( fliFace ) 472 if ( fliFace )
473 // Map all found features to the library 473 // Map all found features to the library
474 fl = fliFace->featureList(); 474 fl = fliFace->featureList();
475 else if ( cpiFace ) 475 else if ( cpiFace )
476 fl << cpiFace->name(); 476 fl << cpiFace->name();
477 477
478 for ( QStringList::Iterator f = fl.begin(); f != fl.end(); f++ ) { 478 for ( QStringList::Iterator f = fl.begin(); f != fl.end(); ++f ) {
479 QLibrary *old = plugDict[*f]; 479 QLibrary *old = plugDict[*f];
480 if ( !old ) { 480 if ( !old ) {
481 useful = TRUE; 481 useful = TRUE;
482 plugDict.replace( *f, plugin ); 482 plugDict.replace( *f, plugin );
483 } else { 483 } else {
484 // we have old *and* plugin, which one to pick? 484 // we have old *and* plugin, which one to pick?
485 QComLibrary* first = (QComLibrary*)old; 485 QComLibrary* first = (QComLibrary*)old;
486 QComLibrary* second = (QComLibrary*)plugin; 486 QComLibrary* second = (QComLibrary*)plugin;
487 bool takeFirst = TRUE; 487 bool takeFirst = TRUE;
488 if ( first->qtVersion() != QT_VERSION ) { 488 if ( first->qtVersion() != QT_VERSION ) {
489 if ( second->qtVersion() == QT_VERSION ) 489 if ( second->qtVersion() == QT_VERSION )
490 takeFirst = FALSE; 490 takeFirst = FALSE;
491 else if ( second->qtVersion() < QT_VERSION && 491 else if ( second->qtVersion() < QT_VERSION &&
492 first->qtVersion() > QT_VERSION ) 492 first->qtVersion() > QT_VERSION )
493 takeFirst = FALSE; 493 takeFirst = FALSE;
494 } 494 }
495 if ( !takeFirst ) { 495 if ( !takeFirst ) {
496 useful = TRUE; 496 useful = TRUE;
497 plugDict.replace( *f, plugin ); 497 plugDict.replace( *f, plugin );
498 qWarning("%s: Discarding feature %s in %s!", 498 qWarning("%s: Discarding feature %s in %s!",
499 (const char*) QFile::encodeName( plugin->library()), 499 (const char*) QFile::encodeName( plugin->library()),
500 (*f).latin1(), 500 (*f).latin1(),
501 (const char*) QFile::encodeName( old->library() ) ); 501 (const char*) QFile::encodeName( old->library() ) );
502 } else { 502 } else {
diff --git a/qmake/tools/qgvector.cpp b/qmake/tools/qgvector.cpp
index 1985f03..3c903ed 100644
--- a/qmake/tools/qgvector.cpp
+++ b/qmake/tools/qgvector.cpp
@@ -14,48 +14,54 @@
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qglobal.h"
39#if defined(Q_CC_BOR)
40// needed for qsort() because of a std namespace problem on Borland
41#include "qplatformdefs.h"
42#endif
43
38 #define QGVECTOR_CPP 44 #define QGVECTOR_CPP
39#include "qgvector.h" 45#include "qgvector.h"
40#include "qglist.h" 46#include "qglist.h"
41#include "qstring.h" 47#include "qstring.h"
42#include "qdatastream.h" 48#include "qdatastream.h"
43#include <stdlib.h> 49#include <stdlib.h>
44 50
45#ifdef QT_THREAD_SUPPORT 51#ifdef QT_THREAD_SUPPORT
46# include <private/qmutexpool_p.h> 52# include <private/qmutexpool_p.h>
47#endif // QT_THREAD_SUPPORT 53#endif // QT_THREAD_SUPPORT
48 54
49 #define USE_MALLOC // comment to use new/delete 55 #define USE_MALLOC // comment to use new/delete
50 56
51#undef NEW 57#undef NEW
52#undef DELETE 58#undef DELETE
53 59
54#if defined(USE_MALLOC) 60#if defined(USE_MALLOC)
55 #define NEW(type,size)((type*)malloc(size*sizeof(type))) 61 #define NEW(type,size)((type*)malloc(size*sizeof(type)))
56 #define DELETE(array)(free((char*)array)) 62 #define DELETE(array)(free((char*)array))
57#else 63#else
58 #define NEW(type,size)(new type[size]) 64 #define NEW(type,size)(new type[size])
59 #define DELETE(array)(delete[] array) 65 #define DELETE(array)(delete[] array)
60 #define DONT_USE_REALLOC // comment to use realloc() 66 #define DONT_USE_REALLOC // comment to use realloc()
61#endif 67#endif
@@ -372,49 +378,50 @@ static int cmp_vec( const void *n1, const void *n2 )
372 378
373 379
374 void QGVector::sort() // sort vector 380 void QGVector::sort() // sort vector
375{ 381{
376 if ( count() == 0 ) // no elements 382 if ( count() == 0 ) // no elements
377 return; 383 return;
378 register Item *start = &vec[0]; 384 register Item *start = &vec[0];
379 register Item *end= &vec[len-1]; 385 register Item *end= &vec[len-1];
380 Item tmp; 386 Item tmp;
381 for (;;) { // put all zero elements behind 387 for (;;) { // put all zero elements behind
382 while ( start < end && *start != 0 ) 388 while ( start < end && *start != 0 )
383 start++; 389 start++;
384 while ( end > start && *end == 0 ) 390 while ( end > start && *end == 0 )
385 end--; 391 end--;
386 if ( start < end ) { 392 if ( start < end ) {
387 tmp = *start; 393 tmp = *start;
388 *start = *end; 394 *start = *end;
389 *end = tmp; 395 *end = tmp;
390 } else { 396 } else {
391 break; 397 break;
392 } 398 }
393 } 399 }
394 400
395#ifdef QT_THREAD_SUPPORT 401#ifdef QT_THREAD_SUPPORT
396 QMutexLocker locker( qt_global_mutexpool->get( &sort_vec ) ); 402 QMutexLocker locker( qt_global_mutexpool ?
403 qt_global_mutexpool->get( &sort_vec ) : 0 );
397#endif // QT_THREAD_SUPPORT 404#endif // QT_THREAD_SUPPORT
398 405
399 sort_vec = (QGVector*)this; 406 sort_vec = (QGVector*)this;
400 qsort( vec, count(), sizeof(Item), cmp_vec ); 407 qsort( vec, count(), sizeof(Item), cmp_vec );
401 sort_vec = 0; 408 sort_vec = 0;
402} 409}
403 410
404 int QGVector::bsearch( Item d ) const // binary search; when sorted 411 int QGVector::bsearch( Item d ) const // binary search; when sorted
405{ 412{
406 if ( !len ) 413 if ( !len )
407 return -1; 414 return -1;
408 if ( !d ) { 415 if ( !d ) {
409#if defined(QT_CHECK_NULL) 416#if defined(QT_CHECK_NULL)
410 qWarning( "QGVector::bsearch: Cannot search for null object" ); 417 qWarning( "QGVector::bsearch: Cannot search for null object" );
411#endif 418#endif
412 return -1; 419 return -1;
413 } 420 }
414 int n1 = 0; 421 int n1 = 0;
415 int n2 = len - 1; 422 int n2 = len - 1;
416 int mid = 0; 423 int mid = 0;
417 bool found = FALSE; 424 bool found = FALSE;
418 while ( n1 <= n2 ) { 425 while ( n1 <= n2 ) {
419 int res; 426 int res;
420 mid = (n1 + n2)/2; 427 mid = (n1 + n2)/2;
diff --git a/qmake/tools/qlibrary.cpp b/qmake/tools/qlibrary.cpp
index 564db30..be1d54b 100644
--- a/qmake/tools/qlibrary.cpp
+++ b/qmake/tools/qlibrary.cpp
@@ -1,32 +1,32 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QLibrary class 4** Implementation of QLibrary class
5** 5**
6** Created : 2000-01-01 6** Created : 000101
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
@@ -50,49 +50,49 @@
50# define QT_DEBUG_COMPONENT 1 50# define QT_DEBUG_COMPONENT 1
51# endif 51# endif
52#endif 52#endif
53 53
54#if defined(QT_DEBUG_COMPONENT) 54#if defined(QT_DEBUG_COMPONENT)
55#include <qfile.h> 55#include <qfile.h>
56#endif 56#endif
57 57
58#if defined(Q_WS_WIN) && !defined(QT_MAKEDLL) 58#if defined(Q_WS_WIN) && !defined(QT_MAKEDLL)
59#define QT_NO_LIBRARY_UNLOAD 59#define QT_NO_LIBRARY_UNLOAD
60#endif 60#endif
61 61
62QLibraryPrivate::QLibraryPrivate( QLibrary *lib ) 62QLibraryPrivate::QLibraryPrivate( QLibrary *lib )
63 : pHnd( 0 ), library( lib ) 63 : pHnd( 0 ), library( lib )
64{ 64{
65} 65}
66 66
67 67
68/*! 68/*!
69 \class QLibrary qlibrary.h 69 \class QLibrary qlibrary.h
70 \reentrant 70 \reentrant
71 \brief The QLibrary class provides a wrapper for handling shared libraries. 71 \brief The QLibrary class provides a wrapper for handling shared libraries.
72 72
73 \mainclass 73 \mainclass
74 \group plugins 74 \ingroup plugins
75 75
76 An instance of a QLibrary object can handle a single shared 76 An instance of a QLibrary object can handle a single shared
77 library and provide access to the functionality in the library in 77 library and provide access to the functionality in the library in
78 a platform independent way. If the library is a component server, 78 a platform independent way. If the library is a component server,
79 QLibrary provides access to the exported component and can 79 QLibrary provides access to the exported component and can
80 directly query this component for interfaces. 80 directly query this component for interfaces.
81 81
82 QLibrary ensures that the shared library is loaded and stays in 82 QLibrary ensures that the shared library is loaded and stays in
83 memory whilst it is in use. QLibrary can also unload the library 83 memory whilst it is in use. QLibrary can also unload the library
84 on destruction and release unused resources. 84 on destruction and release unused resources.
85 85
86 A typical use of QLibrary is to resolve an exported symbol in a 86 A typical use of QLibrary is to resolve an exported symbol in a
87 shared object, and to call the function that this symbol 87 shared object, and to call the function that this symbol
88 represents. This is called "explicit linking" in contrast to 88 represents. This is called "explicit linking" in contrast to
89 "implicit linking", which is done by the link step in the build 89 "implicit linking", which is done by the link step in the build
90 process when linking an executable against a library. 90 process when linking an executable against a library.
91 91
92 The following code snippet loads a library, resolves the symbol 92 The following code snippet loads a library, resolves the symbol
93 "mysymbol", and calls the function if everything succeeded. If 93 "mysymbol", and calls the function if everything succeeded. If
94 something went wrong, e.g. the library file does not exist or the 94 something went wrong, e.g. the library file does not exist or the
95 symbol is not defined, the function pointer will be 0 and won't be 95 symbol is not defined, the function pointer will be 0 and won't be
96 called. When the QLibrary object is destroyed the library will be 96 called. When the QLibrary object is destroyed the library will be
97 unloaded, making all references to memory allocated in the library 97 unloaded, making all references to memory allocated in the library
98 invalid. 98 invalid.
@@ -305,39 +305,40 @@ void QLibrary::setAutoUnload( bool enabled )
305 Returns the filename of the shared library this QLibrary object 305 Returns the filename of the shared library this QLibrary object
306 handles, including the platform specific file extension. 306 handles, including the platform specific file extension.
307 307
308 For example: 308 For example:
309 \code 309 \code
310 QLibrary lib( "mylib" ); 310 QLibrary lib( "mylib" );
311 QString str = lib.library(); 311 QString str = lib.library();
312 \endcode 312 \endcode
313 will set \e str to "mylib.dll" on Windows, and "libmylib.so" on Linux. 313 will set \e str to "mylib.dll" on Windows, and "libmylib.so" on Linux.
314*/ 314*/
315QString QLibrary::library() const 315QString QLibrary::library() const
316{ 316{
317 if ( libfile.isEmpty() ) 317 if ( libfile.isEmpty() )
318 return libfile; 318 return libfile;
319 319
320 QString filename = libfile; 320 QString filename = libfile;
321 321
322#if defined(Q_WS_WIN) 322#if defined(Q_WS_WIN)
323 if ( filename.findRev( '.' ) <= filename.findRev( '/' ) ) 323 if ( filename.findRev( '.' ) <= filename.findRev( '/' ) )
324 filename += ".dll"; 324 filename += ".dll";
325#elif defined(Q_OS_MACX) 325#elif defined(Q_OS_MACX)
326 if ( filename.find( ".dylib" ) == -1 ) 326 if ( filename.find( ".dylib" ) == -1 )
327 filename += ".dylib"; 327 filename += ".dylib";
328#else 328#else
329 if ( filename.find( ".so" ) == -1 ) { 329 QString filter = ".so";
330 if ( filename.find(filter) == -1 ) {
330 const int x = filename.findRev( "/" ); 331 const int x = filename.findRev( "/" );
331 if ( x != -1 ) { 332 if ( x != -1 ) {
332 QString path = filename.left( x + 1 ); 333 QString path = filename.left( x + 1 );
333 QString file = filename.right( filename.length() - x - 1 ); 334 QString file = filename.right( filename.length() - x - 1 );
334 filename = QString( "%1lib%2.so" ).arg( path ).arg( file ); 335 filename = QString( "%1lib%2.%3" ).arg( path ).arg( file ).arg( filter );
335 } else { 336 } else {
336 filename = QString( "lib%1.so" ).arg( filename ); 337 filename = QString( "lib%1.%2" ).arg( filename ).arg( filter );
337 } 338 }
338 } 339 }
339#endif 340#endif
340 341
341 return filename; 342 return filename;
342} 343}
343#endif //QT_NO_LIBRARY 344#endif //QT_NO_LIBRARY
diff --git a/qmake/tools/qlibrary_unix.cpp b/qmake/tools/qlibrary_unix.cpp
index f0fbdf6..12b9310 100644
--- a/qmake/tools/qlibrary_unix.cpp
+++ b/qmake/tools/qlibrary_unix.cpp
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QLibraryPrivate class 4** Implementation of QLibraryPrivate class
5** 5**
6** Created : 2000-01-01 6** Created : 000101
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
@@ -32,49 +32,66 @@
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qplatformdefs.h" 38#include "qplatformdefs.h"
39#include "private/qlibrary_p.h" 39#include "private/qlibrary_p.h"
40 40
41#ifndef QT_NO_LIBRARY 41#ifndef QT_NO_LIBRARY
42 42
43#if defined(QT_AOUT_UNDERSCORE) 43#if defined(QT_AOUT_UNDERSCORE)
44#include <string.h> 44#include <string.h>
45#endif 45#endif
46 46
47/* 47/*
48 The platform dependent implementations of 48 The platform dependent implementations of
49 - loadLibrary 49 - loadLibrary
50 - freeLibrary 50 - freeLibrary
51 - resolveSymbol 51 - resolveSymbol
52 52
53 It's not too hard to guess what the functions do. 53 It's not too hard to guess what the functions do.
54*/ 54*/
55 55
56#if defined(QT_HPUX_LD) // for HP-UX < 11.x and 32 bit 56#if defined(Q_OS_MAC)
57
58bool QLibraryPrivate::loadLibrary()
59{
60 return FALSE;
61}
62
63bool QLibraryPrivate::freeLibrary()
64{
65 return FALSE;
66}
67
68void* QLibraryPrivate::resolveSymbol( const char* )
69{
70 return 0;
71}
72
73#elif defined(QT_HPUX_LD) // for HP-UX < 11.x and 32 bit
57 74
58bool QLibraryPrivate::loadLibrary() 75bool QLibraryPrivate::loadLibrary()
59{ 76{
60 if ( pHnd ) 77 if ( pHnd )
61 return TRUE; 78 return TRUE;
62 79
63 QString filename = library->library(); 80 QString filename = library->library();
64 81
65 pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); 82 pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 );
66#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 83#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
67 if ( !pHnd ) 84 if ( !pHnd )
68 qWarning( "%s: failed to load library!", filename.latin1() ); 85 qWarning( "%s: failed to load library!", filename.latin1() );
69#endif 86#endif
70 return pHnd != 0; 87 return pHnd != 0;
71} 88}
72 89
73bool QLibraryPrivate::freeLibrary() 90bool QLibraryPrivate::freeLibrary()
74{ 91{
75 if ( !pHnd ) 92 if ( !pHnd )
76 return TRUE; 93 return TRUE;
77 94
78 if ( shl_unload( (shl_t)pHnd ) ) { 95 if ( shl_unload( (shl_t)pHnd ) ) {
79#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 96#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
80 QString filename = library->library(); 97 QString filename = library->library();
diff --git a/qmake/tools/qmutex_unix.cpp b/qmake/tools/qmutex_unix.cpp
index c861b2d..3eb59cf 100644
--- a/qmake/tools/qmutex_unix.cpp
+++ b/qmake/tools/qmutex_unix.cpp
@@ -22,50 +22,51 @@
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#if defined(QT_THREAD_SUPPORT) 38#if defined(QT_THREAD_SUPPORT)
39 39
40#include "qplatformdefs.h" 40#include "qplatformdefs.h"
41 41
42typedef pthread_mutex_t Q_MUTEX_T; 42typedef pthread_mutex_t Q_MUTEX_T;
43 43
44// POSIX threads mutex types 44// POSIX threads mutex types
45#if ((defined(PTHREAD_MUTEX_RECURSIVE) && defined(PTHREAD_MUTEX_DEFAULT)) || \ 45#if ((defined(PTHREAD_MUTEX_RECURSIVE) && defined(PTHREAD_MUTEX_DEFAULT)) || \
46 defined(Q_OS_FREEBSD)) && !defined(Q_OS_UNIXWARE) && !defined(Q_OS_SOLARIS) 46 defined(Q_OS_FREEBSD)) && !defined(Q_OS_UNIXWARE) && !defined(Q_OS_SOLARIS) && \
47 // POSIX 1003.1c-1995 - We love this OS 47 !defined(Q_OS_MAC)
48// POSIX 1003.1c-1995 - We love this OS
48# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_settype((a), (b)) 49# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_settype((a), (b))
49# if defined(QT_CHECK_RANGE) 50# if defined(QT_CHECK_RANGE)
50# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK 51# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK
51# else 52# else
52# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT 53# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT
53# endif 54# endif
54# define Q_RECURSIVE_MUTEX_TYPE PTHREAD_MUTEX_RECURSIVE 55# define Q_RECURSIVE_MUTEX_TYPE PTHREAD_MUTEX_RECURSIVE
55#elif defined(MUTEX_NONRECURSIVE_NP) && defined(MUTEX_RECURSIVE_NP) 56#elif defined(MUTEX_NONRECURSIVE_NP) && defined(MUTEX_RECURSIVE_NP)
56// POSIX 1003.4a pthreads draft extensions 57// POSIX 1003.4a pthreads draft extensions
57# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_setkind_np((a), (b)); 58# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_setkind_np((a), (b));
58# define Q_NORMAL_MUTEX_TYPE MUTEX_NONRECURSIVE_NP 59# define Q_NORMAL_MUTEX_TYPE MUTEX_NONRECURSIVE_NP
59# define Q_RECURSIVE_MUTEX_TYPE MUTEX_RECURSIVE_NP 60# define Q_RECURSIVE_MUTEX_TYPE MUTEX_RECURSIVE_NP
60#else 61#else
61// Unknown mutex types - skip them 62// Unknown mutex types - skip them
62# define Q_MUTEX_SET_TYPE(a, b) 63# define Q_MUTEX_SET_TYPE(a, b)
63# undef Q_NORMAL_MUTEX_TYPE 64# undef Q_NORMAL_MUTEX_TYPE
64# undef Q_RECURSIVE_MUTEX_TYPE 65# undef Q_RECURSIVE_MUTEX_TYPE
65#endif 66#endif
66 67
67#include "qmutex.h" 68#include "qmutex.h"
68#include "qmutex_p.h" 69#include "qmutex_p.h"
69 70
70#include <errno.h> 71#include <errno.h>
71#include <string.h> 72#include <string.h>
@@ -640,48 +641,49 @@ bool QMutex::tryLock()
640 641
641 void waitForSignal() 642 void waitForSignal()
642 { 643 {
643 ... 644 ...
644 ... 645 ...
645 ... 646 ...
646 647
647 while ( ! signalled ) 648 while ( ! signalled )
648 waitcondition.wait( locker.mutex() ); 649 waitcondition.wait( locker.mutex() );
649 650
650 ... 651 ...
651 ... 652 ...
652 ... 653 ...
653 } 654 }
654 }; 655 };
655 \endcode 656 \endcode
656 657
657 \sa QMutex, QWaitCondition 658 \sa QMutex, QWaitCondition
658*/ 659*/
659 660
660/*! 661/*!
661 \fn QMutexLocker::QMutexLocker( QMutex *mutex ) 662 \fn QMutexLocker::QMutexLocker( QMutex *mutex )
662 663
663 Constructs a QMutexLocker and locks \a mutex. The mutex will be 664 Constructs a QMutexLocker and locks \a mutex. The mutex will be
664 unlocked when the QMutexLocker is destroyed. 665 unlocked when the QMutexLocker is destroyed. If \a mutex is zero,
666 QMutexLocker does nothing.
665 667
666 \sa QMutex::lock() 668 \sa QMutex::lock()
667*/ 669*/
668 670
669/*! 671/*!
670 \fn QMutexLocker::~QMutexLocker() 672 \fn QMutexLocker::~QMutexLocker()
671 673
672 Destroys the QMutexLocker and unlocks the mutex which was locked 674 Destroys the QMutexLocker and unlocks the mutex which was locked
673 in the constructor. 675 in the constructor.
674 676
675 \sa QMutexLocker::QMutexLocker(), QMutex::unlock() 677 \sa QMutexLocker::QMutexLocker(), QMutex::unlock()
676*/ 678*/
677 679
678/*! 680/*!
679 \fn QMutex *QMutexLocker::mutex() const 681 \fn QMutex *QMutexLocker::mutex() const
680 682
681 Returns a pointer to the mutex which was locked in the 683 Returns a pointer to the mutex which was locked in the
682 constructor. 684 constructor.
683 685
684 \sa QMutexLocker::QMutexLocker() 686 \sa QMutexLocker::QMutexLocker()
685*/ 687*/
686 688
687#endif // QT_THREAD_SUPPORT 689#endif // QT_THREAD_SUPPORT
diff --git a/qmake/tools/qmutexpool.cpp b/qmake/tools/qmutexpool.cpp
index 9ed2829..a8e7402 100644
--- a/qmake/tools/qmutexpool.cpp
+++ b/qmake/tools/qmutexpool.cpp
@@ -1,48 +1,67 @@
1/****************************************************************************
2** $Id$
3**
4** ...
5**
6** Copyright (C) 2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the tools module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
1#include "qmutexpool_p.h" 36#include "qmutexpool_p.h"
2 37
3#ifdef QT_THREAD_SUPPORT 38#ifdef QT_THREAD_SUPPORT
4 39
5#include <qthread.h> 40#include <qthread.h>
6#include <stdio.h>
7 41
8QMutexPool *qt_global_mutexpool = 0; 42QMutexPool *qt_global_mutexpool = 0;
9 43
10// this is an internal class used only for inititalizing the global mutexpool
11class QGlobalMutexPoolInitializer
12{
13public:
14 inline QGlobalMutexPoolInitializer()
15 {
16 /*
17 Purify will report a leak here. However, this mutex pool must be alive
18 until *everything* in Qt has been destructed. Unfortunately there is
19 no way to guarantee this, so we never destroy this mutex pool.
20 */
21 qt_global_mutexpool = new QMutexPool( TRUE );
22 }
23};
24QGlobalMutexPoolInitializer qt_global_mutexpool_initializer;
25 44
26/*! 45/*!
27 \class QMutexPool qmutexpool_p.h 46 \class QMutexPool qmutexpool_p.h
28 \brief The QMutexPool class provides a pool of QMutex objects. 47 \brief The QMutexPool class provides a pool of QMutex objects.
29 48
30 \internal 49 \internal
31 50
32 \ingroup thread 51 \ingroup thread
33 52
34 QMutexPool is a convenience class that provides access to a fixed 53 QMutexPool is a convenience class that provides access to a fixed
35 number of QMutex objects. 54 number of QMutex objects.
36 55
37 Typical use of a QMutexPool is in situations where it is not 56 Typical use of a QMutexPool is in situations where it is not
38 possible or feasible to use one QMutex for every protected object. 57 possible or feasible to use one QMutex for every protected object.
39 The mutex pool will return a mutex based on the address of the 58 The mutex pool will return a mutex based on the address of the
40 object that needs protection. 59 object that needs protection.
41 60
42 For example, consider this simple class: 61 For example, consider this simple class:
43 62
44 \code 63 \code
45 class Number { 64 class Number {
46 public: 65 public:
47 Number( double n ) : num ( n ) { } 66 Number( double n ) : num ( n ) { }
48 67
@@ -64,67 +83,70 @@ QGlobalMutexPoolInitializer qt_global_mutexpool_initializer;
64 83
65 \code 84 \code
66 void calcSquare( Number *num ) 85 void calcSquare( Number *num )
67 { 86 {
68 QMutexLocker locker( mutexpool.get( num ) ); 87 QMutexLocker locker( mutexpool.get( num ) );
69 num.setNumber( num.number() * num.number() ); 88 num.setNumber( num.number() * num.number() );
70 } 89 }
71 \endcode 90 \endcode
72 91
73 This function will safely calculate the square of a number, since 92 This function will safely calculate the square of a number, since
74 it uses a mutex from a QMutexPool. The mutex is locked and 93 it uses a mutex from a QMutexPool. The mutex is locked and
75 unlocked automatically by the QMutexLocker class. See the 94 unlocked automatically by the QMutexLocker class. See the
76 QMutexLocker documentation for more details. 95 QMutexLocker documentation for more details.
77*/ 96*/
78 97
79/*! 98/*!
80 Constructs a QMutexPool, reserving space for \a size QMutexes. If 99 Constructs a QMutexPool, reserving space for \a size QMutexes. If
81 \a recursive is TRUE, all QMutexes in the pool will be recursive 100 \a recursive is TRUE, all QMutexes in the pool will be recursive
82 mutexes; otherwise they will all be non-recursive (the default). 101 mutexes; otherwise they will all be non-recursive (the default).
83 102
84 The QMutexes are created when needed, and deleted when the 103 The QMutexes are created when needed, and deleted when the
85 QMutexPool is destructed. 104 QMutexPool is destructed.
86*/ 105*/
87QMutexPool::QMutexPool( bool recursive, int size ) 106QMutexPool::QMutexPool( bool recursive, int size )
88 : mutex( FALSE ), mutexes( size ), recurs( recursive ) 107 : mutex( FALSE ), count( size ), recurs( recursive )
89{ 108{
90 mutexes.fill( 0 ); 109 mutexes = new QMutex*[count];
110 for ( int index = 0; index < count; ++index ) {
111 mutexes[index] = 0;
112 }
91} 113}
92 114
93/*! 115/*!
94 Destructs a QMutexPool. All QMutexes that were created by the pool 116 Destructs a QMutexPool. All QMutexes that were created by the pool
95 are deleted. 117 are deleted.
96*/ 118*/
97QMutexPool::~QMutexPool() 119QMutexPool::~QMutexPool()
98{ 120{
99 QMutexLocker locker( &mutex ); 121 QMutexLocker locker( &mutex );
100 QMutex **d = mutexes.data(); 122 for ( int index = 0; index < count; ++index ) {
101 for ( int index = 0; (uint) index < mutexes.size(); index++ ) { 123 delete mutexes[index];
102 delete d[index]; 124 mutexes[index] = 0;
103 d[index] = 0;
104 } 125 }
126 delete [] mutexes;
127 mutexes = 0;
105} 128}
106 129
107/*! 130/*!
108 Returns a QMutex from the pool. QMutexPool uses the value \a 131 Returns a QMutex from the pool. QMutexPool uses the value \a
109 address to determine which mutex is retured from the pool. 132 address to determine which mutex is retured from the pool.
110*/ 133*/
111QMutex *QMutexPool::get( void *address ) 134QMutex *QMutexPool::get( void *address )
112{ 135{
113 QMutex **d = mutexes.data(); 136 int index = (int) ( (unsigned long) address % count );
114 int index = (int)( (ulong) address % mutexes.size() );
115 137
116 if ( ! d[index] ) { 138 if ( ! mutexes[index] ) {
117 // mutex not created, create one 139 // mutex not created, create one
118 140
119 QMutexLocker locker( &mutex ); 141 QMutexLocker locker( &mutex );
120 // we need to check once again that the mutex hasn't been created, since 142 // we need to check once again that the mutex hasn't been created, since
121 // 2 threads could be trying to create a mutex as the same index... 143 // 2 threads could be trying to create a mutex as the same index...
122 if ( ! d[index] ) { 144 if ( ! mutexes[index] ) {
123 d[index] = new QMutex( recurs ); 145 mutexes[index] = new QMutex( recurs );
124 } 146 }
125 } 147 }
126 148
127 return d[index]; 149 return mutexes[index];
128} 150}
129 151
130#endif 152#endif
diff --git a/qmake/tools/qregexp.cpp b/qmake/tools/qregexp.cpp
index 500efed..0c1f060 100644
--- a/qmake/tools/qregexp.cpp
+++ b/qmake/tools/qregexp.cpp
@@ -242,57 +242,57 @@
242 \i A character that follows a backslash matches the character 242 \i A character that follows a backslash matches the character
243 itself except where mentioned below. For example if you 243 itself except where mentioned below. For example if you
244 wished to match a literal caret at the beginning of a string 244 wished to match a literal caret at the beginning of a string
245 you would write <b>\^</b>. 245 you would write <b>\^</b>.
246 \row \i <b>\\a</b> 246 \row \i <b>\\a</b>
247 \i This matches the ASCII bell character (BEL, 0x07). 247 \i This matches the ASCII bell character (BEL, 0x07).
248 \row \i <b>\\f</b> 248 \row \i <b>\\f</b>
249 \i This matches the ASCII form feed character (FF, 0x0C). 249 \i This matches the ASCII form feed character (FF, 0x0C).
250 \row \i <b>\\n</b> 250 \row \i <b>\\n</b>
251 \i This matches the ASCII line feed character (LF, 0x0A, Unix newline). 251 \i This matches the ASCII line feed character (LF, 0x0A, Unix newline).
252 \row \i <b>\\r</b> 252 \row \i <b>\\r</b>
253 \i This matches the ASCII carriage return character (CR, 0x0D). 253 \i This matches the ASCII carriage return character (CR, 0x0D).
254 \row \i <b>\\t</b> 254 \row \i <b>\\t</b>
255 \i This matches the ASCII horizontal tab character (HT, 0x09). 255 \i This matches the ASCII horizontal tab character (HT, 0x09).
256 \row \i <b>\\v</b> 256 \row \i <b>\\v</b>
257 \i This matches the ASCII vertical tab character (VT, 0x0B). 257 \i This matches the ASCII vertical tab character (VT, 0x0B).
258 \row \i <b>\\xhhhh</b> 258 \row \i <b>\\xhhhh</b>
259 \i This matches the Unicode character corresponding to the 259 \i This matches the Unicode character corresponding to the
260 hexadecimal number hhhh (between 0x0000 and 0xFFFF). \0ooo 260 hexadecimal number hhhh (between 0x0000 and 0xFFFF). \0ooo
261 (i.e., \zero ooo) matches the ASCII/Latin-1 character 261 (i.e., \zero ooo) matches the ASCII/Latin-1 character
262 corresponding to the octal number ooo (between 0 and 0377). 262 corresponding to the octal number ooo (between 0 and 0377).
263 \row \i <b>. (dot)</b> 263 \row \i <b>. (dot)</b>
264 \i This matches any character (including newline). 264 \i This matches any character (including newline).
265 \row \i <b>\\d</b> 265 \row \i <b>\\d</b>
266 \i This matches a digit (see QChar::isDigit()). 266 \i This matches a digit (QChar::isDigit()).
267 \row \i <b>\\D</b> 267 \row \i <b>\\D</b>
268 \i This matches a non-digit. 268 \i This matches a non-digit.
269 \row \i <b>\\s</b> 269 \row \i <b>\\s</b>
270 \i This matches a whitespace (see QChar::isSpace()). 270 \i This matches a whitespace (QChar::isSpace()).
271 \row \i <b>\\S</b> 271 \row \i <b>\\S</b>
272 \i This matches a non-whitespace. 272 \i This matches a non-whitespace.
273 \row \i <b>\\w</b> 273 \row \i <b>\\w</b>
274 \i This matches a word character (see QChar::isLetterOrNumber()). 274 \i This matches a word character (QChar::isLetterOrNumber() or '_').
275 \row \i <b>\\W</b> 275 \row \i <b>\\W</b>
276 \i This matches a non-word character. 276 \i This matches a non-word character.
277 \row \i <b>\\n</b> 277 \row \i <b>\\n</b>
278 \i The n-th \link #capturing-text backreference \endlink, 278 \i The n-th \link #capturing-text backreference \endlink,
279 e.g. \1, \2, etc. 279 e.g. \1, \2, etc.
280 \endtable 280 \endtable
281 281
282 \e {Note that the C++ compiler transforms backslashes in strings 282 \e {Note that the C++ compiler transforms backslashes in strings
283 so to include a <b>\\</b> in a regexp you will need to enter it 283 so to include a <b>\\</b> in a regexp you will need to enter it
284 twice, i.e. <b>\\\\</b>.} 284 twice, i.e. <b>\\\\</b>.}
285 285
286 \target sets-of-characters 286 \target sets-of-characters
287 \section1 Sets of Characters 287 \section1 Sets of Characters
288 288
289 Square brackets are used to match any character in the set of 289 Square brackets are used to match any character in the set of
290 characters contained within the square brackets. All the character 290 characters contained within the square brackets. All the character
291 set abbreviations described above can be used within square 291 set abbreviations described above can be used within square
292 brackets. Apart from the character set abbreviations and the 292 brackets. Apart from the character set abbreviations and the
293 following two exceptions no characters have special meanings in 293 following two exceptions no characters have special meanings in
294 square brackets. 294 square brackets.
295 295
296 \table 296 \table
297 \row \i <b>^</b> 297 \row \i <b>^</b>
298 \i The caret negates the character set if it occurs as the 298 \i The caret negates the character set if it occurs as the
@@ -526,49 +526,56 @@
526 The equivalent of Perl's \c{/i} option is 526 The equivalent of Perl's \c{/i} option is
527 setCaseSensitive(FALSE). 527 setCaseSensitive(FALSE).
528 528
529 Perl's \c{/g} option can be emulated using a \link 529 Perl's \c{/g} option can be emulated using a \link
530 #cap_in_a_loop loop \endlink. 530 #cap_in_a_loop loop \endlink.
531 531
532 In QRegExp <b>.</b> matches any character, therefore all QRegExp 532 In QRegExp <b>.</b> matches any character, therefore all QRegExp
533 regexps have the equivalent of Perl's \c{/s} option. QRegExp 533 regexps have the equivalent of Perl's \c{/s} option. QRegExp
534 does not have an equivalent to Perl's \c{/m} option, but this 534 does not have an equivalent to Perl's \c{/m} option, but this
535 can be emulated in various ways for example by splitting the input 535 can be emulated in various ways for example by splitting the input
536 into lines or by looping with a regexp that searches for newlines. 536 into lines or by looping with a regexp that searches for newlines.
537 537
538 Because QRegExp is string oriented there are no \A, \Z or \z 538 Because QRegExp is string oriented there are no \A, \Z or \z
539 assertions. The \G assertion is not supported but can be emulated 539 assertions. The \G assertion is not supported but can be emulated
540 in a loop. 540 in a loop.
541 541
542 Perl's $& is cap(0) or capturedTexts()[0]. There are no QRegExp 542 Perl's $& is cap(0) or capturedTexts()[0]. There are no QRegExp
543 equivalents for $`, $' or $+. Perl's capturing variables, $1, $2, 543 equivalents for $`, $' or $+. Perl's capturing variables, $1, $2,
544 ... correspond to cap(1) or capturedTexts()[1], cap(2) or 544 ... correspond to cap(1) or capturedTexts()[1], cap(2) or
545 capturedTexts()[2], etc. 545 capturedTexts()[2], etc.
546 546
547 To substitute a pattern use QString::replace(). 547 To substitute a pattern use QString::replace().
548 548
549 Perl's extended \c{/x} syntax is not supported, nor are 549 Perl's extended \c{/x} syntax is not supported, nor are
550 regexp comments (?#comment) or directives, e.g. (?i). 550 directives, e.g. (?i), or regexp comments, e.g. (?#comment). On
551 the other hand, C++'s rules for literal strings can be used to
552 achieve the same:
553 \code
554 QRegExp mark( "\\b" // word boundary
555 "[Mm]ark" // the word we want to match
556 );
557 \endcode
551 558
552 Both zero-width positive and zero-width negative lookahead 559 Both zero-width positive and zero-width negative lookahead
553 assertions (?=pattern) and (?!pattern) are supported with the same 560 assertions (?=pattern) and (?!pattern) are supported with the same
554 syntax as Perl. Perl's lookbehind assertions, "independent" 561 syntax as Perl. Perl's lookbehind assertions, "independent"
555 subexpressions and conditional expressions are not supported. 562 subexpressions and conditional expressions are not supported.
556 563
557 Non-capturing parentheses are also supported, with the same 564 Non-capturing parentheses are also supported, with the same
558 (?:pattern) syntax. 565 (?:pattern) syntax.
559 566
560 See QStringList::split() and QStringList::join() for equivalents 567 See QStringList::split() and QStringList::join() for equivalents
561 to Perl's split and join functions. 568 to Perl's split and join functions.
562 569
563 Note: because C++ transforms \\'s they must be written \e twice in 570 Note: because C++ transforms \\'s they must be written \e twice in
564 code, e.g. <b>\\b</b> must be written <b>\\\\b</b>. 571 code, e.g. <b>\\b</b> must be written <b>\\\\b</b>.
565 572
566 \target code-examples 573 \target code-examples
567 \section1 Code Examples 574 \section1 Code Examples
568 575
569 \code 576 \code
570 QRegExp rx( "^\\d\\d?$" ); // match integers 0 to 99 577 QRegExp rx( "^\\d\\d?$" ); // match integers 0 to 99
571 rx.search( "123" ); // returns -1 (no match) 578 rx.search( "123" ); // returns -1 (no match)
572 rx.search( "-6" ); // returns -1 (no match) 579 rx.search( "-6" ); // returns -1 (no match)
573 rx.search( "6" ); // returns 0 (matched as position 0) 580 rx.search( "6" ); // returns 0 (matched as position 0)
574 \endcode 581 \endcode
@@ -656,86 +663,91 @@
656 if ( rx.search( str ) != -1 ) { 663 if ( rx.search( str ) != -1 ) {
657 company = rx.cap( 1 ); 664 company = rx.cap( 1 );
658 web = rx.cap( 2 ); 665 web = rx.cap( 2 );
659 country = rx.cap( 3 ); 666 country = rx.cap( 3 );
660 } 667 }
661 \endcode 668 \endcode
662 669
663 In this example our input lines have the format company name, web 670 In this example our input lines have the format company name, web
664 address and country. Unfortunately the regexp is rather long and 671 address and country. Unfortunately the regexp is rather long and
665 not very versatile -- the code will break if we add any more 672 not very versatile -- the code will break if we add any more
666 fields. A simpler and better solution is to look for the 673 fields. A simpler and better solution is to look for the
667 separator, '\t' in this case, and take the surrounding text. The 674 separator, '\t' in this case, and take the surrounding text. The
668 QStringList split() function can take a separator string or regexp 675 QStringList split() function can take a separator string or regexp
669 as an argument and split a string accordingly. 676 as an argument and split a string accordingly.
670 677
671 \code 678 \code
672 QStringList field = QStringList::split( "\t", str ); 679 QStringList field = QStringList::split( "\t", str );
673 \endcode 680 \endcode
674 681
675 Here field[0] is the company, field[1] the web address and so on. 682 Here field[0] is the company, field[1] the web address and so on.
676 683
677 To imitate the matching of a shell we can use wildcard mode. 684 To imitate the matching of a shell we can use wildcard mode.
678 685
679 \code 686 \code
680 QRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything 687 QRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything
681 rx.setWildcard( TRUE ); // now it's a valid wildcard regexp 688 rx.setWildcard( TRUE ); // now it's a valid wildcard regexp
682 rx.search( "index.html" ); // returns 0 (matched at position 0) 689 rx.exactMatch( "index.html" ); // returns TRUE
683 rx.search( "default.htm" ); // returns -1 (no match) 690 rx.exactMatch( "default.htm" ); // returns FALSE
684 rx.search( "readme.txt" ); // returns -1 (no match) 691 rx.exactMatch( "readme.txt" ); // returns FALSE
685 \endcode 692 \endcode
686 693
687 Wildcard matching can be convenient because of its simplicity, but 694 Wildcard matching can be convenient because of its simplicity, but
688 any wildcard regexp can be defined using full regexps, e.g. 695 any wildcard regexp can be defined using full regexps, e.g.
689 <b>.*\.html$</b>. Notice that we can't match both \c .html and \c 696 <b>.*\.html$</b>. Notice that we can't match both \c .html and \c
690 .htm files with a wildcard unless we use <b>*.htm*</b> which will 697 .htm files with a wildcard unless we use <b>*.htm*</b> which will
691 also match 'test.html.bak'. A full regexp gives us the precision 698 also match 'test.html.bak'. A full regexp gives us the precision
692 we need, <b>.*\\.html?$</b>. 699 we need, <b>.*\\.html?$</b>.
693 700
694 QRegExp can match case insensitively using setCaseSensitive(), and 701 QRegExp can match case insensitively using setCaseSensitive(), and
695 can use non-greedy matching, see setMinimal(). By default QRegExp 702 can use non-greedy matching, see setMinimal(). By default QRegExp
696 uses full regexps but this can be changed with setWildcard(). 703 uses full regexps but this can be changed with setWildcard().
697 Searching can be forward with search() or backward with 704 Searching can be forward with search() or backward with
698 searchRev(). Captured text can be accessed using capturedTexts() 705 searchRev(). Captured text can be accessed using capturedTexts()
699 which returns a string list of all captured strings, or using 706 which returns a string list of all captured strings, or using
700 cap() which returns the captured string for the given index. The 707 cap() which returns the captured string for the given index. The
701 pos() function takes a match index and returns the position in the 708 pos() function takes a match index and returns the position in the
702 string where the match was made (or -1 if there was no match). 709 string where the match was made (or -1 if there was no match).
703 710
704 \sa QRegExpValidator QString QStringList 711 \sa QRegExpValidator QString QStringList
705 712
706 \target member-function-documentation 713 \target member-function-documentation
707*/ 714*/
708 715
709const int NumBadChars = 64; 716const int NumBadChars = 64;
710#define BadChar( ch ) ( (ch).unicode() % NumBadChars ) 717#define BadChar( ch ) ( (ch).unicode() % NumBadChars )
711 718
712const int NoOccurrence = INT_MAX; 719const int NoOccurrence = INT_MAX;
713const int EmptyCapture = INT_MAX; 720const int EmptyCapture = INT_MAX;
714const int InftyLen = INT_MAX; 721const int InftyLen = INT_MAX;
715const int InftyRep = 1025; 722const int InftyRep = 1025;
716const int EOS = -1; 723const int EOS = -1;
717 724
725static bool isWord( QChar ch )
726{
727 return ch.isLetterOrNumber() || ch == QChar( '_' );
728}
729
718/* 730/*
719 Merges two QMemArrays of ints and puts the result into the first one. 731 Merges two QMemArrays of ints and puts the result into the first one.
720*/ 732*/
721static void mergeInto( QMemArray<int> *a, const QMemArray<int>& b ) 733static void mergeInto( QMemArray<int> *a, const QMemArray<int>& b )
722{ 734{
723 int asize = a->size(); 735 int asize = a->size();
724 int bsize = b.size(); 736 int bsize = b.size();
725 if ( asize == 0 ) { 737 if ( asize == 0 ) {
726 *a = b.copy(); 738 *a = b.copy();
727#ifndef QT_NO_REGEXP_OPTIM 739#ifndef QT_NO_REGEXP_OPTIM
728 } else if ( bsize == 1 && (*a)[asize - 1] < b[0] ) { 740 } else if ( bsize == 1 && (*a)[asize - 1] < b[0] ) {
729 a->resize( asize + 1 ); 741 a->resize( asize + 1 );
730 (*a)[asize] = b[0]; 742 (*a)[asize] = b[0];
731#endif 743#endif
732 } else if ( bsize >= 1 ) { 744 } else if ( bsize >= 1 ) {
733 int csize = asize + bsize; 745 int csize = asize + bsize;
734 QMemArray<int> c( csize ); 746 QMemArray<int> c( csize );
735 int i = 0, j = 0, k = 0; 747 int i = 0, j = 0, k = 0;
736 while ( i < asize ) { 748 while ( i < asize ) {
737 if ( j < bsize ) { 749 if ( j < bsize ) {
738 if ( (*a)[i] == b[j] ) { 750 if ( (*a)[i] == b[j] ) {
739 i++; 751 i++;
740 csize--; 752 csize--;
741 } else if ( (*a)[i] < b[j] ) { 753 } else if ( (*a)[i] < b[j] ) {
@@ -1659,51 +1671,51 @@ bool QRegExpEngine::isBetterCapture( const int *begin1, const int *end1,
1659bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) 1671bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin )
1660{ 1672{
1661 int j; 1673 int j;
1662 1674
1663#ifndef QT_NO_REGEXP_ANCHOR_ALT 1675#ifndef QT_NO_REGEXP_ANCHOR_ALT
1664 if ( (a & Anchor_Alternation) != 0 ) { 1676 if ( (a & Anchor_Alternation) != 0 ) {
1665 return testAnchor( i, aa[a ^ Anchor_Alternation].a, capBegin ) || 1677 return testAnchor( i, aa[a ^ Anchor_Alternation].a, capBegin ) ||
1666 testAnchor( i, aa[a ^ Anchor_Alternation].b, capBegin ); 1678 testAnchor( i, aa[a ^ Anchor_Alternation].b, capBegin );
1667 } 1679 }
1668#endif 1680#endif
1669 1681
1670 if ( (a & Anchor_Caret) != 0 ) { 1682 if ( (a & Anchor_Caret) != 0 ) {
1671 if ( mmPos + i != mmCaretPos ) 1683 if ( mmPos + i != mmCaretPos )
1672 return FALSE; 1684 return FALSE;
1673 } 1685 }
1674 if ( (a & Anchor_Dollar) != 0 ) { 1686 if ( (a & Anchor_Dollar) != 0 ) {
1675 if ( mmPos + i != mmLen ) 1687 if ( mmPos + i != mmLen )
1676 return FALSE; 1688 return FALSE;
1677 } 1689 }
1678#ifndef QT_NO_REGEXP_ESCAPE 1690#ifndef QT_NO_REGEXP_ESCAPE
1679 if ( (a & (Anchor_Word | Anchor_NonWord)) != 0 ) { 1691 if ( (a & (Anchor_Word | Anchor_NonWord)) != 0 ) {
1680 bool before = FALSE; 1692 bool before = FALSE;
1681 bool after = FALSE; 1693 bool after = FALSE;
1682 if ( mmPos + i != 0 ) 1694 if ( mmPos + i != 0 )
1683 before = mmIn[mmPos + i - 1].isLetterOrNumber(); 1695 before = isWord( mmIn[mmPos + i - 1] );
1684 if ( mmPos + i != mmLen ) 1696 if ( mmPos + i != mmLen )
1685 after = mmIn[mmPos + i].isLetterOrNumber(); 1697 after = isWord( mmIn[mmPos + i] );
1686 if ( (a & Anchor_Word) != 0 && (before == after) ) 1698 if ( (a & Anchor_Word) != 0 && (before == after) )
1687 return FALSE; 1699 return FALSE;
1688 if ( (a & Anchor_NonWord) != 0 && (before != after) ) 1700 if ( (a & Anchor_NonWord) != 0 && (before != after) )
1689 return FALSE; 1701 return FALSE;
1690 } 1702 }
1691#endif 1703#endif
1692#ifndef QT_NO_REGEXP_LOOKAHEAD 1704#ifndef QT_NO_REGEXP_LOOKAHEAD
1693 bool catchx = TRUE; 1705 bool catchx = TRUE;
1694 1706
1695 if ( (a & Anchor_LookaheadMask) != 0 ) { 1707 if ( (a & Anchor_LookaheadMask) != 0 ) {
1696 QConstString cstr = QConstString( (QChar *) mmIn + mmPos + i, 1708 QConstString cstr = QConstString( (QChar *) mmIn + mmPos + i,
1697 mmLen - mmPos - i ); 1709 mmLen - mmPos - i );
1698 for ( j = 0; j < (int) ahead.size(); j++ ) { 1710 for ( j = 0; j < (int) ahead.size(); j++ ) {
1699 if ( (a & (Anchor_FirstLookahead << j)) != 0 ) { 1711 if ( (a & (Anchor_FirstLookahead << j)) != 0 ) {
1700 catchx = ahead[j]->eng->match( cstr.string(), 0, TRUE, TRUE, 1712 catchx = ahead[j]->eng->match( cstr.string(), 0, TRUE, TRUE,
1701 mmCaretPos - mmPos - i )[0] == 0; 1713 mmCaretPos - mmPos - i )[0] == 0;
1702 if ( catchx == ahead[j]->neg ) 1714 if ( catchx == ahead[j]->neg )
1703 return FALSE; 1715 return FALSE;
1704 } 1716 }
1705 } 1717 }
1706 } 1718 }
1707#endif 1719#endif
1708#ifndef QT_NO_REGEXP_CAPTURE 1720#ifndef QT_NO_REGEXP_CAPTURE
1709#ifndef QT_NO_REGEXP_BACKREF 1721#ifndef QT_NO_REGEXP_BACKREF
@@ -2611,68 +2623,76 @@ int QRegExpEngine::getEscape()
2611 yyCh = getChar(); 2623 yyCh = getChar();
2612 } 2624 }
2613 if ( (val & ~0377) != 0 ) 2625 if ( (val & ~0377) != 0 )
2614 error( RXERR_OCTAL ); 2626 error( RXERR_OCTAL );
2615 return Tok_Char | val; 2627 return Tok_Char | val;
2616#endif 2628#endif
2617#ifndef QT_NO_REGEXP_ESCAPE 2629#ifndef QT_NO_REGEXP_ESCAPE
2618 case 'B': 2630 case 'B':
2619 return Tok_NonWord; 2631 return Tok_NonWord;
2620#endif 2632#endif
2621#ifndef QT_NO_REGEXP_CCLASS 2633#ifndef QT_NO_REGEXP_CCLASS
2622 case 'D': 2634 case 'D':
2623 // see QChar::isDigit() 2635 // see QChar::isDigit()
2624 yyCharClass->addCategories( 0x7fffffef ); 2636 yyCharClass->addCategories( 0x7fffffef );
2625 return Tok_CharClass; 2637 return Tok_CharClass;
2626 case 'S': 2638 case 'S':
2627 // see QChar::isSpace() 2639 // see QChar::isSpace()
2628 yyCharClass->addCategories( 0x7ffff87f ); 2640 yyCharClass->addCategories( 0x7ffff87f );
2629 yyCharClass->addRange( 0x0000, 0x0008 ); 2641 yyCharClass->addRange( 0x0000, 0x0008 );
2630 yyCharClass->addRange( 0x000e, 0x001f ); 2642 yyCharClass->addRange( 0x000e, 0x001f );
2631 yyCharClass->addRange( 0x007f, 0x009f ); 2643 yyCharClass->addRange( 0x007f, 0x009f );
2632 return Tok_CharClass; 2644 return Tok_CharClass;
2633 case 'W': 2645 case 'W':
2634 // see QChar::isLetterOrNumber() 2646 // see QChar::isLetterOrNumber()
2635 yyCharClass->addCategories( 0x7ff07f8f ); 2647 yyCharClass->addCategories( 0x7fe07f8f );
2648 yyCharClass->addRange( 0x203f, 0x2040 );
2649 yyCharClass->addSingleton( 0x2040 );
2650 yyCharClass->addSingleton( 0x30fb );
2651 yyCharClass->addRange( 0xfe33, 0xfe34 );
2652 yyCharClass->addRange( 0xfe4d, 0xfe4f );
2653 yyCharClass->addSingleton( 0xff3f );
2654 yyCharClass->addSingleton( 0xff65 );
2636 return Tok_CharClass; 2655 return Tok_CharClass;
2637#endif 2656#endif
2638#ifndef QT_NO_REGEXP_ESCAPE 2657#ifndef QT_NO_REGEXP_ESCAPE
2639 case 'b': 2658 case 'b':
2640 return Tok_Word; 2659 return Tok_Word;
2641#endif 2660#endif
2642#ifndef QT_NO_REGEXP_CCLASS 2661#ifndef QT_NO_REGEXP_CCLASS
2643 case 'd': 2662 case 'd':
2644 // see QChar::isDigit() 2663 // see QChar::isDigit()
2645 yyCharClass->addCategories( 0x00000010 ); 2664 yyCharClass->addCategories( 0x00000010 );
2646 return Tok_CharClass; 2665 return Tok_CharClass;
2647 case 's': 2666 case 's':
2648 // see QChar::isSpace() 2667 // see QChar::isSpace()
2649 yyCharClass->addCategories( 0x00000380 ); 2668 yyCharClass->addCategories( 0x00000380 );
2650 yyCharClass->addRange( 0x0009, 0x000d ); 2669 yyCharClass->addRange( 0x0009, 0x000d );
2651 return Tok_CharClass; 2670 return Tok_CharClass;
2652 case 'w': 2671 case 'w':
2653 // see QChar::isLetterOrNumber() 2672 // see QChar::isLetterOrNumber()
2654 yyCharClass->addCategories( 0x000f8070 ); 2673 yyCharClass->addCategories( 0x000f8070 );
2674 yyCharClass->addSingleton( 0x005f ); // '_'
2655 return Tok_CharClass; 2675 return Tok_CharClass;
2656#endif 2676#endif
2657#ifndef QT_NO_REGEXP_ESCAPE 2677#ifndef QT_NO_REGEXP_ESCAPE
2658 case 'x': 2678 case 'x':
2659 val = 0; 2679 val = 0;
2660 for ( i = 0; i < 4; i++ ) { 2680 for ( i = 0; i < 4; i++ ) {
2661 low = QChar( yyCh ).lower(); 2681 low = QChar( yyCh ).lower();
2662 if ( low >= '0' && low <= '9' ) 2682 if ( low >= '0' && low <= '9' )
2663 val = ( val << 4 ) | ( low - '0' ); 2683 val = ( val << 4 ) | ( low - '0' );
2664 else if ( low >= 'a' && low <= 'f' ) 2684 else if ( low >= 'a' && low <= 'f' )
2665 val = ( val << 4 ) | ( low - 'a' + 10 ); 2685 val = ( val << 4 ) | ( low - 'a' + 10 );
2666 else 2686 else
2667 break; 2687 break;
2668 yyCh = getChar(); 2688 yyCh = getChar();
2669 } 2689 }
2670 return Tok_Char | val; 2690 return Tok_Char | val;
2671#endif 2691#endif
2672 default: 2692 default:
2673 if ( prevCh >= '1' && prevCh <= '9' ) { 2693 if ( prevCh >= '1' && prevCh <= '9' ) {
2674#ifndef QT_NO_REGEXP_BACKREF 2694#ifndef QT_NO_REGEXP_BACKREF
2675 val = prevCh - '0'; 2695 val = prevCh - '0';
2676 while ( yyCh >= '0' && yyCh <= '9' ) { 2696 while ( yyCh >= '0' && yyCh <= '9' ) {
2677 val = ( val *= 10 ) | ( yyCh - '0' ); 2697 val = ( val *= 10 ) | ( yyCh - '0' );
2678 yyCh = getChar(); 2698 yyCh = getChar();
@@ -3162,69 +3182,71 @@ struct QRegExpPrivate
3162 QString rxpattern; // regular-expression pattern 3182 QString rxpattern; // regular-expression pattern
3163#ifndef QT_NO_REGEXP_WILDCARD 3183#ifndef QT_NO_REGEXP_WILDCARD
3164 bool wc; // wildcard mode? 3184 bool wc; // wildcard mode?
3165#endif 3185#endif
3166 bool min; // minimal matching? (instead of maximal) 3186 bool min; // minimal matching? (instead of maximal)
3167#ifndef QT_NO_REGEXP_CAPTURE 3187#ifndef QT_NO_REGEXP_CAPTURE
3168 QString t; // last string passed to QRegExp::search() or searchRev() 3188 QString t; // last string passed to QRegExp::search() or searchRev()
3169 QStringList capturedCache; // what QRegExp::capturedTexts() returned last 3189 QStringList capturedCache; // what QRegExp::capturedTexts() returned last
3170#endif 3190#endif
3171 QMemArray<int> captured; // what QRegExpEngine::search() returned last 3191 QMemArray<int> captured; // what QRegExpEngine::search() returned last
3172 3192
3173 QRegExpPrivate() { captured.fill( -1, 2 ); } 3193 QRegExpPrivate() { captured.fill( -1, 2 ); }
3174}; 3194};
3175 3195
3176#ifndef QT_NO_REGEXP_OPTIM 3196#ifndef QT_NO_REGEXP_OPTIM
3177static QCache<QRegExpEngine> *engineCache = 0; 3197static QCache<QRegExpEngine> *engineCache = 0;
3178static QSingleCleanupHandler<QCache<QRegExpEngine> > cleanup_cache; 3198static QSingleCleanupHandler<QCache<QRegExpEngine> > cleanup_cache;
3179#endif 3199#endif
3180 3200
3181static QRegExpEngine *newEngine( const QString& pattern, bool caseSensitive ) 3201static QRegExpEngine *newEngine( const QString& pattern, bool caseSensitive )
3182{ 3202{
3183#ifndef QT_NO_REGEXP_OPTIM 3203#ifndef QT_NO_REGEXP_OPTIM
3184 if ( engineCache != 0 ) { 3204 if ( engineCache != 0 ) {
3185#ifdef QT_THREAD_SUPPORT 3205#ifdef QT_THREAD_SUPPORT
3186 QMutexLocker locker( qt_global_mutexpool->get( &engineCache ) ); 3206 QMutexLocker locker( qt_global_mutexpool ?
3207 qt_global_mutexpool->get( &engineCache ) : 0 );
3187#endif 3208#endif
3188 QRegExpEngine *eng = engineCache->take( pattern ); 3209 QRegExpEngine *eng = engineCache->take( pattern );
3189 if ( eng == 0 || eng->caseSensitive() != caseSensitive ) { 3210 if ( eng == 0 || eng->caseSensitive() != caseSensitive ) {
3190 delete eng; 3211 delete eng;
3191 } else { 3212 } else {
3192 eng->ref(); 3213 eng->ref();
3193 return eng; 3214 return eng;
3194 } 3215 }
3195 } 3216 }
3196#endif 3217#endif
3197 return new QRegExpEngine( pattern, caseSensitive ); 3218 return new QRegExpEngine( pattern, caseSensitive );
3198} 3219}
3199 3220
3200static void derefEngine( QRegExpEngine *eng, const QString& pattern ) 3221static void derefEngine( QRegExpEngine *eng, const QString& pattern )
3201{ 3222{
3202 if ( eng != 0 && eng->deref() ) {
3203#ifndef QT_NO_REGEXP_OPTIM
3204#ifdef QT_THREAD_SUPPORT 3223#ifdef QT_THREAD_SUPPORT
3205 QMutexLocker locker( qt_global_mutexpool->get( &engineCache ) ); 3224 QMutexLocker locker( qt_global_mutexpool ?
3225 qt_global_mutexpool->get( &engineCache ) : 0 );
3206#endif 3226#endif
3227 if ( eng != 0 && eng->deref() ) {
3228#ifndef QT_NO_REGEXP_OPTIM
3207 if ( engineCache == 0 ) { 3229 if ( engineCache == 0 ) {
3208 engineCache = new QCache<QRegExpEngine>; 3230 engineCache = new QCache<QRegExpEngine>;
3209 engineCache->setAutoDelete( TRUE ); 3231 engineCache->setAutoDelete( TRUE );
3210 cleanup_cache.set( &engineCache ); 3232 cleanup_cache.set( &engineCache );
3211 } 3233 }
3212 if ( !pattern.isNull() && 3234 if ( !pattern.isNull() &&
3213 engineCache->insert(pattern, eng, 4 + pattern.length() / 4) ) 3235 engineCache->insert(pattern, eng, 4 + pattern.length() / 4) )
3214 return; 3236 return;
3215#else 3237#else
3216 Q_UNUSED( pattern ); 3238 Q_UNUSED( pattern );
3217#endif 3239#endif
3218 delete eng; 3240 delete eng;
3219 } 3241 }
3220} 3242}
3221 3243
3222/*! 3244/*!
3223 \enum QRegExp::CaretMode 3245 \enum QRegExp::CaretMode
3224 3246
3225 The CaretMode enum defines the different meanings of the caret 3247 The CaretMode enum defines the different meanings of the caret
3226 (<b>^</b>) in a regular expression. The possible values are: 3248 (<b>^</b>) in a regular expression. The possible values are:
3227 3249
3228 \value CaretAtZero 3250 \value CaretAtZero
3229 The caret corresponds to index 0 in the searched string. 3251 The caret corresponds to index 0 in the searched string.
3230 3252
@@ -3544,55 +3566,48 @@ bool QRegExp::exactMatch( const QString& str ) const
3544 Attempts to match in \a str, starting from position \a index. 3566 Attempts to match in \a str, starting from position \a index.
3545 Returns the position of the match, or -1 if there was no match. 3567 Returns the position of the match, or -1 if there was no match.
3546 3568
3547 The length of the match is stored in \a *len, unless \a len is a 3569 The length of the match is stored in \a *len, unless \a len is a
3548 null pointer. 3570 null pointer.
3549 3571
3550 If \a indexIsStart is TRUE (the default), the position \a index in 3572 If \a indexIsStart is TRUE (the default), the position \a index in
3551 the string will match the start of string anchor, <b>^</b>, in the 3573 the string will match the start of string anchor, <b>^</b>, in the
3552 regexp, if present. Otherwise, position 0 in \a str will match. 3574 regexp, if present. Otherwise, position 0 in \a str will match.
3553 3575
3554 Use search() and matchedLength() instead of this function. 3576 Use search() and matchedLength() instead of this function.
3555 3577
3556 \sa QString::mid() QConstString 3578 \sa QString::mid() QConstString
3557*/ 3579*/
3558int QRegExp::match( const QString& str, int index, int *len, 3580int QRegExp::match( const QString& str, int index, int *len,
3559 bool indexIsStart ) const 3581 bool indexIsStart ) const
3560{ 3582{
3561 int pos = search( str, index, indexIsStart ? CaretAtOffset : CaretAtZero ); 3583 int pos = search( str, index, indexIsStart ? CaretAtOffset : CaretAtZero );
3562 if ( len != 0 ) 3584 if ( len != 0 )
3563 *len = matchedLength(); 3585 *len = matchedLength();
3564 return pos; 3586 return pos;
3565} 3587}
3566#endif // QT_NO_COMPAT 3588#endif // QT_NO_COMPAT
3567 3589
3568/*!
3569 \overload
3570
3571 This convenience function searches with a \c CaretMode of \c
3572 CaretAtZero which is the most common usage.
3573*/
3574
3575int QRegExp::search( const QString& str, int offset ) const 3590int QRegExp::search( const QString& str, int offset ) const
3576{ 3591{
3577 return search( str, offset, CaretAtZero ); 3592 return search( str, offset, CaretAtZero );
3578} 3593}
3579 3594
3580/*! 3595/*!
3581 Attempts to find a match in \a str from position \a offset (0 by 3596 Attempts to find a match in \a str from position \a offset (0 by
3582 default). If \a offset is -1, the search starts at the last 3597 default). If \a offset is -1, the search starts at the last
3583 character; if -2, at the next to last character; etc. 3598 character; if -2, at the next to last character; etc.
3584 3599
3585 Returns the position of the first match, or -1 if there was no 3600 Returns the position of the first match, or -1 if there was no
3586 match. 3601 match.
3587 3602
3588 The \a caretMode parameter can be used to instruct whether <b>^</b> 3603 The \a caretMode parameter can be used to instruct whether <b>^</b>
3589 should match at index 0 or at \a offset. 3604 should match at index 0 or at \a offset.
3590 3605
3591 You might prefer to use QString::find(), QString::contains() or 3606 You might prefer to use QString::find(), QString::contains() or
3592 even QStringList::grep(). To replace matches use 3607 even QStringList::grep(). To replace matches use
3593 QString::replace(). 3608 QString::replace().
3594 3609
3595 Example: 3610 Example:
3596 \code 3611 \code
3597 QString str = "offsets: 1.23 .50 71.00 6.00"; 3612 QString str = "offsets: 1.23 .50 71.00 6.00";
3598 QRegExp rx( "\\d*\\.\\d+" ); // primitive floating point matching 3613 QRegExp rx( "\\d*\\.\\d+" ); // primitive floating point matching
@@ -3604,55 +3619,48 @@ int QRegExp::search( const QString& str, int offset ) const
3604 } 3619 }
3605 // pos will be 9, 14, 18 and finally 24; count will end up as 4 3620 // pos will be 9, 14, 18 and finally 24; count will end up as 4
3606 \endcode 3621 \endcode
3607 3622
3608 Although const, this function sets matchedLength(), 3623 Although const, this function sets matchedLength(),
3609 capturedTexts() and pos(). 3624 capturedTexts() and pos().
3610 3625
3611 \sa searchRev() exactMatch() 3626 \sa searchRev() exactMatch()
3612*/ 3627*/
3613 3628
3614int QRegExp::search( const QString& str, int offset, CaretMode caretMode ) const 3629int QRegExp::search( const QString& str, int offset, CaretMode caretMode ) const
3615{ 3630{
3616 if ( offset < 0 ) 3631 if ( offset < 0 )
3617 offset += str.length(); 3632 offset += str.length();
3618#ifndef QT_NO_REGEXP_CAPTURE 3633#ifndef QT_NO_REGEXP_CAPTURE
3619 priv->t = str; 3634 priv->t = str;
3620 priv->capturedCache.clear(); 3635 priv->capturedCache.clear();
3621#endif 3636#endif
3622 priv->captured = eng->match( str, offset, priv->min, FALSE, 3637 priv->captured = eng->match( str, offset, priv->min, FALSE,
3623 caretIndex(offset, caretMode) ); 3638 caretIndex(offset, caretMode) );
3624 return priv->captured[0]; 3639 return priv->captured[0];
3625} 3640}
3626 3641
3627 3642
3628/*!
3629 \overload
3630
3631 This convenience function searches with a \c CaretMode of \c
3632 CaretAtZero which is the most common usage.
3633*/
3634
3635int QRegExp::searchRev( const QString& str, int offset ) const 3643int QRegExp::searchRev( const QString& str, int offset ) const
3636{ 3644{
3637 return searchRev( str, offset, CaretAtZero ); 3645 return searchRev( str, offset, CaretAtZero );
3638} 3646}
3639 3647
3640/*! 3648/*!
3641 Attempts to find a match backwards in \a str from position \a 3649 Attempts to find a match backwards in \a str from position \a
3642 offset. If \a offset is -1 (the default), the search starts at the 3650 offset. If \a offset is -1 (the default), the search starts at the
3643 last character; if -2, at the next to last character; etc. 3651 last character; if -2, at the next to last character; etc.
3644 3652
3645 Returns the position of the first match, or -1 if there was no 3653 Returns the position of the first match, or -1 if there was no
3646 match. 3654 match.
3647 3655
3648 The \a caretMode parameter can be used to instruct whether <b>^</b> 3656 The \a caretMode parameter can be used to instruct whether <b>^</b>
3649 should match at index 0 or at \a offset. 3657 should match at index 0 or at \a offset.
3650 3658
3651 Although const, this function sets matchedLength(), 3659 Although const, this function sets matchedLength(),
3652 capturedTexts() and pos(). 3660 capturedTexts() and pos().
3653 3661
3654 \warning Searching backwards is much slower than searching 3662 \warning Searching backwards is much slower than searching
3655 forwards. 3663 forwards.
3656 3664
3657 \sa search() exactMatch() 3665 \sa search() exactMatch()
3658*/ 3666*/
@@ -3673,49 +3681,49 @@ int QRegExp::searchRev( const QString& str, int offset,
3673 } 3681 }
3674 3682
3675 while ( offset >= 0 ) { 3683 while ( offset >= 0 ) {
3676 priv->captured = eng->match( str, offset, priv->min, TRUE, 3684 priv->captured = eng->match( str, offset, priv->min, TRUE,
3677 caretIndex(offset, caretMode) ); 3685 caretIndex(offset, caretMode) );
3678 if ( priv->captured[0] == offset ) 3686 if ( priv->captured[0] == offset )
3679 return offset; 3687 return offset;
3680 offset--; 3688 offset--;
3681 } 3689 }
3682 return -1; 3690 return -1;
3683} 3691}
3684 3692
3685/*! 3693/*!
3686 Returns the length of the last matched string, or -1 if there was 3694 Returns the length of the last matched string, or -1 if there was
3687 no match. 3695 no match.
3688 3696
3689 \sa exactMatch() search() searchRev() 3697 \sa exactMatch() search() searchRev()
3690*/ 3698*/
3691int QRegExp::matchedLength() const 3699int QRegExp::matchedLength() const
3692{ 3700{
3693 return priv->captured[1]; 3701 return priv->captured[1];
3694} 3702}
3695 3703
3696#ifndef QT_NO_REGEXP_CAPTURE 3704#ifndef QT_NO_REGEXP_CAPTURE
3697/*! 3705/*!
3698 Returns the number of captures contained in the regular expression. 3706 Returns the number of captures contained in the regular expression.
3699 */ 3707 */
3700int QRegExp::numCaptures() const 3708int QRegExp::numCaptures() const
3701{ 3709{
3702 return eng->numCaptures(); 3710 return eng->numCaptures();
3703} 3711}
3704 3712
3705 3713
3706 3714
3707/*! 3715/*!
3708 Returns a list of the captured text strings. 3716 Returns a list of the captured text strings.
3709 3717
3710 The first string in the list is the entire matched string. Each 3718 The first string in the list is the entire matched string. Each
3711 subsequent list element contains a string that matched a 3719 subsequent list element contains a string that matched a
3712 (capturing) subexpression of the regexp. 3720 (capturing) subexpression of the regexp.
3713 3721
3714 For example: 3722 For example:
3715 \code 3723 \code
3716 QRegExp rx( "(\\d+)(\\s*)(cm|inch(es)?)" ); 3724 QRegExp rx( "(\\d+)(\\s*)(cm|inch(es)?)" );
3717 int pos = rx.search( "Length: 36 inches" ); 3725 int pos = rx.search( "Length: 36 inches" );
3718 QStringList list = rx.capturedTexts(); 3726 QStringList list = rx.capturedTexts();
3719 // list is now ( "36 inches", "36", " ", "inches", "es" ) 3727 // list is now ( "36 inches", "36", " ", "inches", "es" )
3720 \endcode 3728 \endcode
3721 3729
diff --git a/qmake/tools/qsemaphore_unix.cpp b/qmake/tools/qsemaphore_unix.cpp
index fcf28da..4516049 100644
--- a/qmake/tools/qsemaphore_unix.cpp
+++ b/qmake/tools/qsemaphore_unix.cpp
@@ -162,86 +162,84 @@ int QSemaphore::operator--(int)
162 d->mutex.lock(); 162 d->mutex.lock();
163 163
164 --(d->value); 164 --(d->value);
165 if (d->value < 0) d->value = 0; 165 if (d->value < 0) d->value = 0;
166 ret = d->value; 166 ret = d->value;
167 167
168 d->cond.wakeAll(); 168 d->cond.wakeAll();
169 d->mutex.unlock(); 169 d->mutex.unlock();
170 170
171 return ret; 171 return ret;
172} 172}
173 173
174 174
175/*! 175/*!
176 Try to get access to the semaphore. If \l available() \< \a n, this 176 Try to get access to the semaphore. If \l available() \< \a n, this
177 call will block until it can get all the accesses it wants, i.e. 177 call will block until it can get all the accesses it wants, i.e.
178 until available() \>= \a n. 178 until available() \>= \a n.
179*/ 179*/
180int QSemaphore::operator+=(int n) 180int QSemaphore::operator+=(int n)
181{ 181{
182 int ret; 182 int ret;
183 183
184 d->mutex.lock(); 184 d->mutex.lock();
185 185
186 if ( n < 0 || n > d->max ) {
187#ifdef QT_CHECK_RANGE
188 qWarning( "QSemaphore::operator+=: paramter %d out of range", n );
189#endif // QT_CHECK_RANGE
190 n = n < 0 ? 0 : d->max;
191 }
192
186 while (d->value + n > d->max) 193 while (d->value + n > d->max)
187 d->cond.wait(&(d->mutex)); 194 d->cond.wait(&(d->mutex));
188 195
189 d->value += n; 196 d->value += n;
190
191#ifdef QT_CHECK_RANGE
192 if (d->value > d->max) {
193 qWarning("QSemaphore::operator+=: attempt to allocate more resources than available");
194 d->value = d->max;
195 }
196#endif
197
198 ret = d->value; 197 ret = d->value;
199 198
200 d->mutex.unlock(); 199 d->mutex.unlock();
201 200
202 return ret; 201 return ret;
203} 202}
204 203
205 204
206/*! 205/*!
207 Release \a n accesses to the semaphore. 206 Release \a n accesses to the semaphore.
208*/ 207*/
209int QSemaphore::operator-=(int n) 208int QSemaphore::operator-=(int n)
210{ 209{
211 int ret; 210 int ret;
212 211
213 d->mutex.lock(); 212 d->mutex.lock();
214 213
215 d->value -= n; 214 if ( n < 0 || n > d->value ) {
216
217#ifdef QT_CHECK_RANGE 215#ifdef QT_CHECK_RANGE
218 if (d->value < 0) { 216 qWarning( "QSemaphore::operator-=: paramter %d out of range", n );
219 qWarning("QSemaphore::operator-=: attempt to deallocate more resources than taken"); 217#endif // QT_CHECK_RANGE
220 d->value = 0; 218 n = n < 0 ? 0 : d->value;
221 } 219 }
222#endif
223 220
221 d->value -= n;
224 ret = d->value; 222 ret = d->value;
225 223
226 d->cond.wakeOne(); 224 d->cond.wakeOne();
227 d->mutex.unlock(); 225 d->mutex.unlock();
228 226
229 return ret; 227 return ret;
230} 228}
231 229
232 230
233/*! 231/*!
234 Returns the number of accesses currently available to the 232 Returns the number of accesses currently available to the
235 semaphore. 233 semaphore.
236*/ 234*/
237int QSemaphore::available() const { 235int QSemaphore::available() const {
238 int ret; 236 int ret;
239 237
240 d->mutex.lock(); 238 d->mutex.lock();
241 ret = d->max - d->value; 239 ret = d->max - d->value;
242 d->mutex.unlock(); 240 d->mutex.unlock();
243 241
244 return ret; 242 return ret;
245} 243}
246 244
247 245
diff --git a/qmake/tools/qsettings.cpp b/qmake/tools/qsettings.cpp
index 5de105c..35fc039 100644
--- a/qmake/tools/qsettings.cpp
+++ b/qmake/tools/qsettings.cpp
@@ -1,30 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QSettings class 4** Implementation of QSettings class
5** 5**
6** Created: 2000.06.26 6** Created : 000626
7** 7**
8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 8** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
@@ -42,138 +42,167 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode )
42{ return ::open( pathname, flags, mode ); } 42{ return ::open( pathname, flags, mode ); }
43#if defined(open) 43#if defined(open)
44# undef open 44# undef open
45#endif 45#endif
46 46
47// POSIX Large File Support redefines truncate -> truncate64 47// POSIX Large File Support redefines truncate -> truncate64
48#if defined(truncate) 48#if defined(truncate)
49# undef truncate 49# undef truncate
50#endif 50#endif
51 51
52#include "qsettings.h" 52#include "qsettings.h"
53 53
54#ifndef QT_NO_SETTINGS 54#ifndef QT_NO_SETTINGS
55 55
56#include "qdir.h" 56#include "qdir.h"
57#include "qfile.h" 57#include "qfile.h"
58#include "qfileinfo.h" 58#include "qfileinfo.h"
59#include "qmap.h" 59#include "qmap.h"
60#include "qtextstream.h" 60#include "qtextstream.h"
61#include "qregexp.h" 61#include "qregexp.h"
62#include <private/qsettings_p.h> 62#include <private/qsettings_p.h>
63#include <errno.h> 63#include <errno.h>
64 64
65/*! 65/*!
66 \class QSettings 66 \class QSettings
67 \brief The QSettings class provides persistent platform-independent application settings. 67 \brief The QSettings class provides persistent platform-independent application settings.
68 68
69 \ingroup io 69 \ingroup io
70 \ingroup misc 70 \ingroup misc
71 \mainclass 71 \mainclass
72 72
73 On Unix systems, QSettings uses text files to store settings. On Windows 73 On Unix systems, QSettings uses text files to store settings. On Windows
74 systems, QSettings uses the system registry. On Mac OS X, QSettings will 74 systems, QSettings uses the system registry. On Mac OS X, QSettings uses
75 behave as on Unix, and store to text files. 75 the Carbon preferences API.
76 76
77 Each setting comprises an identifying key and the data associated with 77 Each setting comprises an identifying key and the data associated with
78 the key. A key is a unicode string which consists of \e two or more 78 the key. A key is a unicode string which consists of \e two or more
79 subkeys. A subkey is a slash, '/', followed by one or more unicode 79 subkeys. A subkey is a slash, '/', followed by one or more unicode
80 characters (excluding slashes, newlines, carriage returns and equals, 80 characters (excluding slashes, newlines, carriage returns and equals,
81 '=', signs). The associated data, called the entry or value, may be a 81 '=', signs). The associated data, called the entry or value, may be a
82 boolean, an integer, a double, a string or a list of strings. Entry 82 boolean, an integer, a double, a string or a list of strings. Entry
83 strings may contain any unicode characters. 83 strings may contain any unicode characters.
84 84
85 If you want to save and restore the entire desktop's settings, i.e. 85 If you want to save and restore the entire desktop's settings, i.e.
86 which applications are running, use QSettings to save the settings 86 which applications are running, use QSettings to save the settings
87 for each individual application and QSessionManager to save the 87 for each individual application and QSessionManager to save the
88 desktop's session. 88 desktop's session.
89 89
90 Example settings: 90 Example settings:
91 \code 91 \code
92 /MyCompany/MyApplication/background color 92 /MyCompany/MyApplication/background color
93 /MyCompany/MyApplication/foreground color 93 /MyCompany/MyApplication/foreground color
94 /MyCompany/MyApplication/geometry/x 94 /MyCompany/MyApplication/geometry/x
95 /MyCompany/MyApplication/geometry/y 95 /MyCompany/MyApplication/geometry/y
96 /MyCompany/MyApplication/geometry/width 96 /MyCompany/MyApplication/geometry/width
97 /MyCompany/MyApplication/geometry/height 97 /MyCompany/MyApplication/geometry/height
98 /MyCompany/MyApplication/recent files/1 98 /MyCompany/MyApplication/recent files/1
99 /MyCompany/MyApplication/recent files/2 99 /MyCompany/MyApplication/recent files/2
100 /MyCompany/MyApplication/recent files/3 100 /MyCompany/MyApplication/recent files/3
101 \endcode 101 \endcode
102 Each line above is a complete key, made up of subkeys. 102 Each line above is a complete key, made up of subkeys.
103 103
104 A typical usage pattern for application startup: 104 A typical usage pattern for reading application startup:
105 \code 105 \code
106 QSettings settings; 106 QSettings settings;
107 settings.insertSearchPath( QSettings::Windows, "/MyCompany" ); 107 settings.setPath( "MyCompany.com", "MyApplication" );
108 // No search path needed for Unix; see notes further on. 108
109 // Use default values if the keys don't exist 109 QString bgColor = settings.readEntry( "/colors/background", "white" );
110 QString bgColor = settings.readEntry( "/MyApplication/background color", "white" ); 110 int width = settings.readNumEntry( "/geometry/width", 640 );
111 int width = settings.readNumEntry( "/MyApplication/geometry/width", 640 );
112 // ... 111 // ...
113 \endcode 112 \endcode
114 113
115 A typical usage pattern for application exit or 'save preferences': 114 A typical usage pattern for application exit or 'save preferences':
116 \code 115 \code
117 QSettings settings; 116 QSettings settings;
118 settings.insertSearchPath( QSettings::Windows, "/MyCompany" ); 117 settings.setPath( "MyCompany.com", "MyApplication" );
119 // No search path needed for Unix; see notes further on. 118
120 settings.writeEntry( "/MyApplication/background color", bgColor ); 119 settings.writeEntry( "/colors/background", bgColor );
121 settings.writeEntry( "/MyApplication/geometry/width", width ); 120 settings.writeEntry( "/geometry/width", width );
122 // ... 121 // ...
123 \endcode 122 \endcode
124 123
124 QSettings can build a key prefix that is prepended to all keys. To
125 build the key prefix, use beginGroup() and endGroup().
126 \code
127 QSettings settings;
128
129 settings.beginGroup( "/MainWindow" );
130 settings.beginGroup( "/Geometry" );
131 int x = settings.readEntry( "/x" );
132 // ...
133 settings.endGroup();
134 settings.beginGroup( "/Toolbars" );
135 // ...
136 settings.endGroup();
137 settings.endGroup();
138 \endcode
139
125 You can get a list of entry-holding keys by calling entryList(), and 140 You can get a list of entry-holding keys by calling entryList(), and
126 a list of key-holding keys using subkeyList(). 141 a list of key-holding keys using subkeyList().
127 142
128 \code 143 \code
129 QStringList keys = entryList( "/MyApplication" ); 144 QStringList keys = entryList( "/MyApplication" );
130 // keys contains 'background color' and 'foreground color'. 145 // keys contains 'background color' and 'foreground color'.
131 146
132 QStringList keys = entryList( "/MyApplication/recent files" ); 147 QStringList keys = entryList( "/MyApplication/recent files" );
133 // keys contains '1', '2' and '3'. 148 // keys contains '1', '2' and '3'.
134 149
135 QStringList subkeys = subkeyList( "/MyApplication" ); 150 QStringList subkeys = subkeyList( "/MyApplication" );
136 // subkeys contains 'geometry' and 'recent files' 151 // subkeys contains 'geometry' and 'recent files'
137 152
138 QStringList subkeys = subkeyList( "/MyApplication/recent files" ); 153 QStringList subkeys = subkeyList( "/MyApplication/recent files" );
139 // subkeys is empty. 154 // subkeys is empty.
140 \endcode 155 \endcode
141 156
142 If you wish to use a different search path call insertSearchPath()
143 as often as necessary to add your preferred paths. Call
144 removeSearchPath() to remove any unwanted paths.
145
146 Since settings for Windows are stored in the registry there are size 157 Since settings for Windows are stored in the registry there are size
147 limits as follows: 158 limits as follows:
148 \list 159 \list
149 \i A subkey may not exceed 255 characters. 160 \i A subkey may not exceed 255 characters.
150 \i An entry's value may not exceed 16,300 characters. 161 \i An entry's value may not exceed 16,300 characters.
151 \i All the values of a key (for example, all the 'recent files' 162 \i All the values of a key (for example, all the 'recent files'
152 subkeys values), may not exceed 65,535 characters. 163 subkeys values), may not exceed 65,535 characters.
153 \endlist 164 \endlist
154 165
155 These limitations are not enforced on Unix. 166 These limitations are not enforced on Unix or Mac OS X.
167
168 If you wish to use a different search path call insertSearchPath()
169 as often as necessary to add your preferred paths. Call
170 removeSearchPath() to remove any unwanted paths.
171
172 \section1 Notes for Mac OS X Applications
173
174 Internal to the CFPreferences API it is not defined (for Mac OS 9
175 support) where the settings will ultimitely be stored. However, at the
176 time of this writing the settings will be stored (either on a global or
177 user basis, preferring locally) into a plist file in
178 $ROOT/System/Library/Preferences (in XML format). QSettings will create
179 an appropriate plist file (com.<first group name>.plist) out of the
180 full path to a key.
181
182 For further information on CFPreferences see also
183 \link http://developer.apple.com/techpubs/macosx/CoreFoundation/PreferenceServices/preferenceservices_carbon.html
184 Apple's Specifications\endlink
156 185
157 \section1 Notes for Unix Applications 186 \section1 Notes for Unix Applications
158 187
159 There is no universally accepted place for storing application 188 There is no universally accepted place for storing application
160 settings under Unix. In the examples the settings file will be 189 settings under Unix. In the examples the settings file will be
161 searched for in the following directories: 190 searched for in the following directories:
162 \list 1 191 \list 1
163 \i INSTALL/etc/settings 192 \i INSTALL/etc/settings
164 \i /opt/MyCompany/share/etc 193 \i /opt/MyCompany/share/etc
165 \i /opt/MyCompany/share/MyApplication/etc 194 \i /opt/MyCompany/share/MyApplication/etc
166 \i $HOME/.qt 195 \i $HOME/.qt
167 \endlist 196 \endlist
168 When reading settings the files are searched in the order shown 197 When reading settings the files are searched in the order shown
169 above, with later settings overriding earlier settings. Files for 198 above, with later settings overriding earlier settings. Files for
170 which the user doesn't have read permission are ignored. When saving 199 which the user doesn't have read permission are ignored. When saving
171 settings QSettings works in the order shown above, writing 200 settings QSettings works in the order shown above, writing
172 to the first settings file for which the user has write permission. 201 to the first settings file for which the user has write permission.
173 (\c INSTALL is the directory where Qt was installed. This can be 202 (\c INSTALL is the directory where Qt was installed. This can be
174 modified by using the configure script's -prefix argument ) 203 modified by using the configure script's -prefix argument )
175 204
176 If you want to put the settings in a particular place in the 205 If you want to put the settings in a particular place in the
177 filesystem you could do this: 206 filesystem you could do this:
178 \code 207 \code
179 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share" ); 208 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share" );
@@ -279,62 +308,62 @@ static void closelock( HANDLE fd )
279 // ignore the return value, so that the unlock fails silently 308 // ignore the return value, so that the unlock fails silently
280 (void) fcntl( fd, F_SETLKW, &fl ); 309 (void) fcntl( fd, F_SETLKW, &fl );
281 310
282 close( fd ); 311 close( fd );
283} 312}
284#elif defined(Q_WS_WIN) 313#elif defined(Q_WS_WIN)
285#define Q_LOCKREAD 1 314#define Q_LOCKREAD 1
286#define Q_LOCKWRITE 2 315#define Q_LOCKWRITE 2
287 316
288static HANDLE openlock( const QString &name, int /*type*/ ) 317static HANDLE openlock( const QString &name, int /*type*/ )
289{ 318{
290 if ( !QFile::exists( name ) ) 319 if ( !QFile::exists( name ) )
291 return 0; 320 return 0;
292 321
293 return 0; 322 return 0;
294 323
295 HANDLE fd = 0; 324 HANDLE fd = 0;
296 325
297 QT_WA( { 326 QT_WA( {
298 fd = CreateFileW( (TCHAR*)name.ucs2(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); 327 fd = CreateFileW( (TCHAR*)name.ucs2(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
299 } , { 328 } , {
300 fd = CreateFileA( name.local8Bit(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); 329 fd = CreateFileA( name.local8Bit(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
301 } ); 330 } );
302 331
303 if ( !LockFile( fd, 0, 0, -1, -1 ) ) { 332 if ( !LockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
304#ifdef QT_CHECK_STATE 333#ifdef QT_CHECK_STATE
305 qWarning( "QSettings: openlock failed!" ); 334 qWarning( "QSettings: openlock failed!" );
306#endif 335#endif
307 } 336 }
308 return fd; 337 return fd;
309} 338}
310 339
311void closelock( HANDLE fd ) 340static void closelock( HANDLE fd )
312{ 341{
313 if ( !fd ) 342 if ( !fd )
314 return; 343 return;
315 344
316 if ( !UnlockFile( fd, 0, 0, -1, -1 ) ) { 345 if ( !UnlockFile( fd, 0, 0, (DWORD)-1, (DWORD)-1 ) ) { // ### (DWORD)-1 ???
317#ifdef QT_CHECK_STATE 346#ifdef QT_CHECK_STATE
318 qWarning( "QSettings: closelock failed!"); 347 qWarning( "QSettings: closelock failed!");
319#endif 348#endif
320 } 349 }
321 CloseHandle( fd ); 350 CloseHandle( fd );
322} 351}
323#endif 352#endif
324 353
325 354
326QSettingsGroup::QSettingsGroup() 355QSettingsGroup::QSettingsGroup()
327 : modified(FALSE) 356 : modified(FALSE)
328{ 357{
329} 358}
330 359
331 360
332 361
333 362
334void QSettingsHeading::read(const QString &filename) 363void QSettingsHeading::read(const QString &filename)
335{ 364{
336 if (! QFileInfo(filename).exists()) 365 if (! QFileInfo(filename).exists())
337 return; 366 return;
338 367
339 HANDLE lockfd = openlock( filename, Q_LOCKREAD ); 368 HANDLE lockfd = openlock( filename, Q_LOCKREAD );
340 369
@@ -434,157 +463,165 @@ void QSettingsHeading::parseLine(QTextStream &stream)
434 } 463 }
435 } 464 }
436 465
437 (*git).insert(key, value); 466 (*git).insert(key, value);
438 } 467 }
439 } 468 }
440} 469}
441 470
442#ifdef Q_WS_WIN // for homedirpath reading from registry 471#ifdef Q_WS_WIN // for homedirpath reading from registry
443#include "qt_windows.h" 472#include "qt_windows.h"
444#include "qlibrary.h" 473#include "qlibrary.h"
445 474
446#ifndef CSIDL_APPDATA 475#ifndef CSIDL_APPDATA
447#define CSIDL_APPDATA 0x001a // <user name>\Application Data 476#define CSIDL_APPDATA 0x001a // <user name>\Application Data
448#endif 477#endif
449#ifndef CSIDL_COMMON_APPDATA 478#ifndef CSIDL_COMMON_APPDATA
450#define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data 479#define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data
451#endif 480#endif
452 481
453#endif 482#endif
454 483
455QSettingsPrivate::QSettingsPrivate( QSettings::Format format ) 484QSettingsPrivate::QSettingsPrivate( QSettings::Format format )
456 : groupDirty( TRUE ), modified(FALSE), globalScope(TRUE) 485 : groupDirty( TRUE ), modified(FALSE), globalScope(TRUE)
457{ 486{
458#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 487#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
459 if ( format != QSettings::Ini ) 488 if ( format != QSettings::Ini )
460 return; 489 return;
490#else
491 Q_UNUSED( format );
461#endif 492#endif
462 493
463 QString appSettings(QDir::homeDirPath() + "/.qt/"); 494 QString appSettings(QDir::homeDirPath() + "/.qt/");
464 QString defPath; 495 QString defPath;
465#ifdef Q_WS_WIN 496#ifdef Q_WS_WIN
466#ifdef Q_OS_TEMP 497#ifdef Q_OS_TEMP
467 TCHAR path[MAX_PATH]; 498 TCHAR path[MAX_PATH];
468 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); 499 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE );
469 appSettings = QString::fromUcs2( path ); 500 appSettings = QString::fromUcs2( path );
470 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); 501 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE );
471 defPath = QString::fromUcs2( path ); 502 defPath = QString::fromUcs2( path );
472#else 503#else
473 QLibrary library( "shell32" ); 504 QLibrary library( "shell32" );
474 library.setAutoUnload( FALSE ); 505 library.setAutoUnload( FALSE );
475 QT_WA( { 506 QT_WA( {
476 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL); 507 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL);
477 GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathW" ); 508 GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathW" );
478 if ( SHGetSpecialFolderPath ) { 509 if ( SHGetSpecialFolderPath ) {
479 TCHAR path[MAX_PATH]; 510 TCHAR path[MAX_PATH];
480 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); 511 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE );
481 appSettings = QString::fromUcs2( (ushort*)path ); 512 appSettings = QString::fromUcs2( (ushort*)path );
482 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); 513 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE );
483 defPath = QString::fromUcs2( (ushort*)path ); 514 defPath = QString::fromUcs2( (ushort*)path );
484 } 515 }
485 } , { 516 } , {
486 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, char*, int, BOOL); 517 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, char*, int, BOOL);
487 GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathA" ); 518 GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathA" );
488 if ( SHGetSpecialFolderPath ) { 519 if ( SHGetSpecialFolderPath ) {
489 char path[MAX_PATH]; 520 char path[MAX_PATH];
490 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); 521 SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE );
491 appSettings = QString::fromLocal8Bit( path ); 522 appSettings = QString::fromLocal8Bit( path );
492 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); 523 SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE );
493 defPath = QString::fromLocal8Bit( path ); 524 defPath = QString::fromLocal8Bit( path );
494 } 525 }
495 } ); 526 } );
496#endif // Q_OS_TEMP 527#endif // Q_OS_TEMP
497#else 528#else
498// for now 529// for now
499#define QSETTINGS_DEFAULT_PATH_SUFFIX "/etc/settings" 530#define QSETTINGS_DEFAULT_PATH_SUFFIX "/etc/settings"
500 531
501 defPath = qInstallPath(); 532 defPath = qInstallPath();
502 defPath += QSETTINGS_DEFAULT_PATH_SUFFIX; 533 defPath += QSETTINGS_DEFAULT_PATH_SUFFIX;
503#endif 534#endif
504 QDir dir(appSettings); 535 QDir dir(appSettings);
505 if (! dir.exists()) { 536 if (! dir.exists()) {
506 if (! dir.mkdir(dir.path())) 537 if (! dir.mkdir(dir.path()))
507#if defined(QT_CHECK_STATE) 538#if defined(QT_CHECK_STATE)
508 qWarning("QSettings: error creating %s", dir.path().latin1()); 539 qWarning("QSettings: error creating %s", dir.path().latin1());
540#else
541 ;
509#endif 542#endif
510 } 543 }
511 544
512 if ( !!defPath ) 545 if ( !!defPath )
513 searchPaths.append(defPath); 546 searchPaths.append(defPath);
514 searchPaths.append(dir.path()); 547 searchPaths.append(dir.path());
515} 548}
516 549
517QSettingsPrivate::~QSettingsPrivate() 550QSettingsPrivate::~QSettingsPrivate()
518{ 551{
519} 552}
520 553
521QSettingsGroup QSettingsPrivate::readGroup() 554QSettingsGroup QSettingsPrivate::readGroup()
522{ 555{
523 QSettingsHeading hd; 556 QSettingsHeading hd;
524 QSettingsGroup grp; 557 QSettingsGroup grp;
525 558
526 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading); 559 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading);
527 if (headingsit != headings.end()) 560 if (headingsit != headings.end())
528 hd = *headingsit; 561 hd = *headingsit;
529 562
530 QSettingsHeading::Iterator grpit = hd.find(group); 563 QSettingsHeading::Iterator grpit = hd.find(group);
531 if (grpit == hd.end()) { 564 if (grpit == hd.end()) {
532 QStringList::Iterator it = searchPaths.begin(); 565 QStringList::Iterator it = searchPaths.begin();
566 if ( !globalScope )
567 ++it;
533 while (it != searchPaths.end()) { 568 while (it != searchPaths.end()) {
534 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); 569 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_");
535 QString fn((*it++) + "/" + filebase + "rc"); 570 QString fn((*it++) + "/" + filebase + "rc");
536 if (! hd.contains(fn + "cached")) { 571 if (! hd.contains(fn + "cached")) {
537 hd.read(fn); 572 hd.read(fn);
538 hd.insert(fn + "cached", QSettingsGroup()); 573 hd.insert(fn + "cached", QSettingsGroup());
539 } 574 }
540 } 575 }
541 576
542 headings.replace(heading, hd); 577 headings.replace(heading, hd);
543 578
544 grpit = hd.find(group); 579 grpit = hd.find(group);
545 if (grpit != hd.end()) 580 if (grpit != hd.end())
546 grp = *grpit; 581 grp = *grpit;
547 } else if (hd.count() != 0) 582 } else if (hd.count() != 0)
548 grp = *grpit; 583 grp = *grpit;
549 584
550 return grp; 585 return grp;
551} 586}
552 587
553 588
554void QSettingsPrivate::removeGroup(const QString &key) 589void QSettingsPrivate::removeGroup(const QString &key)
555{ 590{
556 QSettingsHeading hd; 591 QSettingsHeading hd;
557 QSettingsGroup grp; 592 QSettingsGroup grp;
558 bool found = FALSE; 593 bool found = FALSE;
559 594
560 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading); 595 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading);
561 if (headingsit != headings.end()) 596 if (headingsit != headings.end())
562 hd = *headingsit; 597 hd = *headingsit;
563 598
564 QSettingsHeading::Iterator grpit = hd.find(group); 599 QSettingsHeading::Iterator grpit = hd.find(group);
565 if (grpit == hd.end()) { 600 if (grpit == hd.end()) {
566 QStringList::Iterator it = searchPaths.begin(); 601 QStringList::Iterator it = searchPaths.begin();
602 if ( !globalScope )
603 ++it;
567 while (it != searchPaths.end()) { 604 while (it != searchPaths.end()) {
568 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); 605 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_");
569 QString fn((*it++) + "/" + filebase + "rc"); 606 QString fn((*it++) + "/" + filebase + "rc");
570 if (! hd.contains(fn + "cached")) { 607 if (! hd.contains(fn + "cached")) {
571 hd.read(fn); 608 hd.read(fn);
572 hd.insert(fn + "cached", QSettingsGroup()); 609 hd.insert(fn + "cached", QSettingsGroup());
573 } 610 }
574 } 611 }
575 612
576 headings.replace(heading, hd); 613 headings.replace(heading, hd);
577 614
578 grpit = hd.find(group); 615 grpit = hd.find(group);
579 if (grpit != hd.end()) { 616 if (grpit != hd.end()) {
580 found = TRUE; 617 found = TRUE;
581 grp = *grpit; 618 grp = *grpit;
582 } 619 }
583 } else if (hd.count() != 0) { 620 } else if (hd.count() != 0) {
584 found = TRUE; 621 found = TRUE;
585 grp = *grpit; 622 grp = *grpit;
586 } 623 }
587 624
588 if (found) { 625 if (found) {
589 grp.remove(key); 626 grp.remove(key);
590 627
@@ -594,797 +631,814 @@ void QSettingsPrivate::removeGroup(const QString &key)
594 hd.remove(group); 631 hd.remove(group);
595 632
596 if (hd.count() > 0) 633 if (hd.count() > 0)
597 headings.replace(heading, hd); 634 headings.replace(heading, hd);
598 else 635 else
599 headings.remove(heading); 636 headings.remove(heading);
600 637
601 modified = TRUE; 638 modified = TRUE;
602 } 639 }
603} 640}
604 641
605 642
606void QSettingsPrivate::writeGroup(const QString &key, const QString &value) 643void QSettingsPrivate::writeGroup(const QString &key, const QString &value)
607{ 644{
608 QSettingsHeading hd; 645 QSettingsHeading hd;
609 QSettingsGroup grp; 646 QSettingsGroup grp;
610 647
611 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading); 648 QMap<QString,QSettingsHeading>::Iterator headingsit = headings.find(heading);
612 if (headingsit != headings.end()) 649 if (headingsit != headings.end())
613 hd = *headingsit; 650 hd = *headingsit;
614 651
615 QSettingsHeading::Iterator grpit = hd.find(group); 652 QSettingsHeading::Iterator grpit = hd.find(group);
616 if (grpit == hd.end()) { 653 if (grpit == hd.end()) {
617 QStringList::Iterator it = searchPaths.begin(); 654 QStringList::Iterator it = searchPaths.begin();
655 if ( !globalScope )
656 ++it;
618 while (it != searchPaths.end()) { 657 while (it != searchPaths.end()) {
619 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_"); 658 QString filebase = heading.lower().replace(QRegExp("\\s+"), "_");
620 QString fn((*it++) + "/" + filebase + "rc"); 659 QString fn((*it++) + "/" + filebase + "rc");
621 if (! hd.contains(fn + "cached")) { 660 if (! hd.contains(fn + "cached")) {
622 hd.read(fn); 661 hd.read(fn);
623 hd.insert(fn + "cached", QSettingsGroup()); 662 hd.insert(fn + "cached", QSettingsGroup());
624 } 663 }
625 } 664 }
626 665
627 headings.replace(heading, hd); 666 headings.replace(heading, hd);
628 667
629 grpit = hd.find(group); 668 grpit = hd.find(group);
630 if (grpit != hd.end()) 669 if (grpit != hd.end())
631 grp = *grpit; 670 grp = *grpit;
632 } else if (hd.count() != 0) 671 } else if (hd.count() != 0)
633 grp = *grpit; 672 grp = *grpit;
634 673
635 grp.modified = TRUE; 674 grp.modified = TRUE;
636 grp.replace(key, value); 675 grp.replace(key, value);
637 hd.replace(group, grp); 676 hd.replace(group, grp);
638 headings.replace(heading, hd); 677 headings.replace(heading, hd);
639 678
640 modified = TRUE; 679 modified = TRUE;
641} 680}
642 681
643 682
644QDateTime QSettingsPrivate::modificationTime() 683QDateTime QSettingsPrivate::modificationTime()
645{ 684{
646 QSettingsHeading hd = headings[heading]; 685 QSettingsHeading hd = headings[heading];
647 QSettingsGroup grp = hd[group]; 686 QSettingsGroup grp = hd[group];
648 687
649 QDateTime datetime; 688 QDateTime datetime;
650 689
651 QStringList::Iterator it = searchPaths.begin(); 690 QStringList::Iterator it = searchPaths.begin();
691 if ( !globalScope )
692 ++it;
652 while (it != searchPaths.end()) { 693 while (it != searchPaths.end()) {
653 QFileInfo fi((*it++) + "/" + heading + "rc"); 694 QFileInfo fi((*it++) + "/" + heading + "rc");
654 if (fi.exists() && fi.lastModified() > datetime) 695 if (fi.exists() && fi.lastModified() > datetime)
655 datetime = fi.lastModified(); 696 datetime = fi.lastModified();
656 } 697 }
657 698
658 return datetime; 699 return datetime;
659} 700}
660 701
661static bool verifyKey( const QString &key ) 702bool qt_verify_key( const QString &key )
662{ 703{
663 if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) ) 704 if ( key.isEmpty() || key[0] != '/' || key.contains( QRegExp("[=\\\\r\\\\n" ) ) )
664 return FALSE; 705 return FALSE;
665 return TRUE; 706 return TRUE;
666} 707}
667 708
668static inline QString groupKey( const QString &group, const QString &key ) 709static inline QString groupKey( const QString &group, const QString &key )
669{ 710{
670 if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) 711 if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) {
712 // group is empty, or it contains a single '/', so we just return the key
713 if ( key.startsWith( "/" ) )
714 return key;
715 return "/" + key;
716 } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) {
671 return group + key; 717 return group + key;
718 }
672 return group + "/" + key; 719 return group + "/" + key;
673} 720}
674 721
675/*! 722/*!
676 Inserts \a path into the settings search path. The semantics of \a 723 Inserts \a path into the settings search path. The semantics of \a
677 path depends on the system \a s. 724 path depends on the system \a s.
678 725
679 When \a s is \e Windows and the execution environment is \e not 726 When \a s is \e Windows and the execution environment is \e not
680 Windows the function does nothing. Similarly when \a s is \e Unix and 727 Windows the function does nothing. Similarly when \a s is \e Unix and
681 the execution environment is \e not Unix the function does nothing. 728 the execution environment is \e not Unix the function does nothing.
682 729
683 When \a s is \e Windows, and the execution environment is Windows, the 730 When \a s is \e Windows, and the execution environment is Windows, the
684 search path list will be used as the first subfolder of the "Software" 731 search path list will be used as the first subfolder of the "Software"
685 folder in the registry. 732 folder in the registry.
686 733
687 When reading settings the folders are searched forwards from the 734 When reading settings the folders are searched forwards from the
688 first folder (listed below) to the last, returning the first 735 first folder (listed below) to the last, returning the first
689 settings found, and ignoring any folders for which the user doesn't 736 settings found, and ignoring any folders for which the user doesn't
690 have read permission. 737 have read permission.
691 \list 1 738 \list 1
692 \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication 739 \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication
693 \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication 740 \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
694 \i HKEY_CURRENT_USER/Software/MyApplication 741 \i HKEY_CURRENT_USER/Software/MyApplication
695 \i HKEY_LOCAL_MACHINE/Software/MyApplication 742 \i HKEY_LOCAL_MACHINE/Software/MyApplication
696 \endlist 743 \endlist
697 744
698 \code 745 \code
699 QSettings settings; 746 QSettings settings;
700 settings.insertSearchPath( QSettings::Windows, "/MyCompany" ); 747 settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
701 settings.writeEntry( "/MyApplication/Tip of the day", TRUE ); 748 settings.writeEntry( "/MyApplication/Tip of the day", TRUE );
702 \endcode 749 \endcode
703 The code above will write the subkey "Tip of the day" into the \e 750 The code above will write the subkey "Tip of the day" into the \e
704 first of the registry folders listed below that is found and for 751 first of the registry folders listed below that is found and for
705 which the user has write permission. 752 which the user has write permission.
706 \list 1 753 \list 1
707 \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication 754 \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
708 \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication 755 \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication
709 \i HKEY_LOCAL_MACHINE/Software/MyApplication 756 \i HKEY_LOCAL_MACHINE/Software/MyApplication
710 \i HKEY_CURRENT_USER/Software/MyApplication 757 \i HKEY_CURRENT_USER/Software/MyApplication
711 \endlist 758 \endlist
712 If a setting is found in the HKEY_CURRENT_USER space, this setting 759 If a setting is found in the HKEY_CURRENT_USER space, this setting
713 is overwritten independently of write permissions in the 760 is overwritten independently of write permissions in the
714 HKEY_LOCAL_MACHINE space. 761 HKEY_LOCAL_MACHINE space.
715 762
716 When \a s is \e Unix, and the execution environment is Unix, the 763 When \a s is \e Unix, and the execution environment is Unix, the
717 search path list will be used when trying to determine a suitable 764 search path list will be used when trying to determine a suitable
718 filename for reading and writing settings files. By default, there are 765 filename for reading and writing settings files. By default, there are
719 two entries in the search path: 766 two entries in the search path:
720 767
721 \list 1 768 \list 1
722 \i INSTALL/etc - where \c INSTALL is the directory where Qt was installed. 769 \i INSTALL/etc - where \c INSTALL is the directory where Qt was installed.
723 \i $HOME/.qt/ - where \c $HOME is the user's home directory. 770 \i $HOME/.qt/ - where \c $HOME is the user's home directory.
724 \endlist 771 \endlist
725 772
726 All insertions into the search path will go before $HOME/.qt/. 773 All insertions into the search path will go before $HOME/.qt/.
727 For example: 774 For example:
728 \code 775 \code
729 QSettings settings; 776 QSettings settings;
730 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/etc" ); 777 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/etc" );
731 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/MyApplication/etc" ); 778 settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/MyApplication/etc" );
732 // ... 779 // ...
733 \endcode 780 \endcode
734 Will result in a search path of: 781 Will result in a search path of:
735 \list 1 782 \list 1
736 \i INSTALL/etc 783 \i INSTALL/etc
737 \i /opt/MyCompany/share/etc 784 \i /opt/MyCompany/share/etc
738 \i /opt/MyCompany/share/MyApplication/etc 785 \i /opt/MyCompany/share/MyApplication/etc
739 \i $HOME/.qt 786 \i $HOME/.qt
740 \endlist 787 \endlist
741 When reading settings the files are searched in the order shown 788 When reading settings the files are searched in the order shown
742 above, with later settings overriding earlier settings. Files for 789 above, with later settings overriding earlier settings. Files for
743 which the user doesn't have read permission are ignored. When saving 790 which the user doesn't have read permission are ignored. When saving
744 settings QSettings works in the order shown above, writing 791 settings QSettings works in the order shown above, writing
745 to the first settings file for which the user has write permission. 792 to the first settings file for which the user has write permission.
746 793
747 Settings under Unix are stored in files whose names are based on the 794 Settings under Unix are stored in files whose names are based on the
748 first subkey of the key (not including the search path). The algorithm 795 first subkey of the key (not including the search path). The algorithm
749 for creating names is essentially: lowercase the first subkey, replace 796 for creating names is essentially: lowercase the first subkey, replace
750 spaces with underscores and add 'rc', e.g. 797 spaces with underscores and add 'rc', e.g.
751 <tt>/MyCompany/MyApplication/background color</tt> will be stored in 798 <tt>/MyCompany/MyApplication/background color</tt> will be stored in
752 <tt>myapplicationrc</tt> (assuming that <tt>/MyCompany</tt> is part of 799 <tt>myapplicationrc</tt> (assuming that <tt>/MyCompany</tt> is part of
753 the search path). 800 the search path).
754 801
755 \sa removeSearchPath() 802 \sa removeSearchPath()
756 803
757*/ 804*/
758void QSettings::insertSearchPath( System s, const QString &path) 805void QSettings::insertSearchPath( System s, const QString &path)
759{ 806{
760#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 807#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
761 if ( d->sysd ) { 808 if ( d->sysd ) {
762 d->sysInsertSearchPath( s, path ); 809 d->sysInsertSearchPath( s, path );
763 return; 810 return;
764 } 811 }
765#endif 812#endif
766 813
767 if ( !verifyKey( path ) ) { 814#if !defined(Q_WS_WIN)
815 if ( s == Windows )
816 return;
817#endif
818#if !defined(Q_WS_WIN)
819 if ( s == Mac )
820 return;
821#endif
822
823 if ( !qt_verify_key( path ) ) {
768#if defined(QT_CHECK_STATE) 824#if defined(QT_CHECK_STATE)
769 qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); 825 qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() );
770#endif 826#endif
771 return; 827 return;
772 } 828 }
773 829
774#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 830#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
775 if ( d->sysd && s != Unix ) { 831 if ( d->sysd && s != Unix ) {
776#else 832#else
777 if ( s != Unix ) { 833 if ( s != Unix ) {
778#endif 834#endif
779#ifdef Q_OS_MAC 835#if !defined(QWS) && defined(Q_OS_MAC)
780 if(s != Mac) //mac is respected on the mac as well 836 if(s != Mac) //mac is respected on the mac as well
781#endif 837#endif
782 return; 838 return;
783 } 839 }
784 840
841 QString realPath = path;
842#if defined(Q_WS_WIN)
843 QString defPath = d->globalScope ? d->searchPaths.first() : d->searchPaths.last();
844 realPath = defPath + path;
845#endif
846
785 QStringList::Iterator it = d->searchPaths.find(d->searchPaths.last()); 847 QStringList::Iterator it = d->searchPaths.find(d->searchPaths.last());
786 if (it != d->searchPaths.end()) { 848 if (it != d->searchPaths.end()) {
787 d->searchPaths.insert(it, path); 849 d->searchPaths.insert(it, realPath);
788 } 850 }
789} 851}
790 852
791 853
792/*! 854/*!
793 Removes all occurrences of \a path (using exact matching) from the 855 Removes all occurrences of \a path (using exact matching) from the
794 settings search path for system \a s. Note that the default search 856 settings search path for system \a s. Note that the default search
795 paths cannot be removed. 857 paths cannot be removed.
796 858
797 \sa insertSearchPath() 859 \sa insertSearchPath()
798*/ 860*/
799void QSettings::removeSearchPath( System s, const QString &path) 861void QSettings::removeSearchPath( System s, const QString &path)
800{ 862{
801 if ( !verifyKey( path ) ) { 863 if ( !qt_verify_key( path ) ) {
802#if defined(QT_CHECK_STATE) 864#if defined(QT_CHECK_STATE)
803 qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); 865 qWarning( "QSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() );
804#endif 866#endif
805 return; 867 return;
806 } 868 }
807 869
808#ifdef Q_WS_WIN 870#ifdef Q_WS_WIN
809 if ( d->sysd ) { 871 if ( d->sysd ) {
810 d->sysRemoveSearchPath( s, path ); 872 d->sysRemoveSearchPath( s, path );
811 return; 873 return;
812 } 874 }
813#endif 875#endif
814#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 876#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
815 if ( d->sysd && s != Unix ) { 877 if ( d->sysd && s != Unix ) {
816#else 878#else
817 if ( s != Unix ) { 879 if ( s != Unix ) {
818#endif 880#endif
819#ifdef Q_OS_MAC 881#if !defined(QWS) && defined(Q_OS_MAC)
820 if(s != Mac) //mac is respected on the mac as well 882 if(s != Mac) //mac is respected on the mac as well
821#endif 883#endif
822 return; 884 return;
823 } 885 }
824 886
825 if (path == d->searchPaths.first() || path == d->searchPaths.last()) 887 if (path == d->searchPaths.first() || path == d->searchPaths.last())
826 return; 888 return;
827 889
828 d->searchPaths.remove(path); 890 d->searchPaths.remove(path);
829} 891}
830 892
831 893
832/*! 894/*!
833 Creates a settings object. 895 Creates a settings object.
834*/ 896*/
835QSettings::QSettings() 897QSettings::QSettings()
836{ 898{
837 d = new QSettingsPrivate( Native ); 899 d = new QSettingsPrivate( Native );
838 Q_CHECK_PTR(d); 900 Q_CHECK_PTR(d);
839 901
840#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 902#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
841 d->sysd = 0; 903 d->sysd = 0;
842 d->sysInit(); 904 d->sysInit();
843#endif 905#endif
844} 906}
845 907
846/*! 908/*!
847 Creates a settings object. If \a format is 'Ini' the settings will 909 Creates a settings object. If \a format is 'Ini' the settings will
848 be stored in a text file, using the Unix strategy (see above). If \a format 910 be stored in a text file, using the Unix strategy (see above). If \a format
849 is 'Native', the settings will be stored in a platform specific way 911 is 'Native', the settings will be stored in a platform specific way
850 (ie. the Windows registry). 912 (ie. the Windows registry).
851*/ 913*/
852QSettings::QSettings( Format format ) 914QSettings::QSettings( Format format )
853{ 915{
854 d = new QSettingsPrivate( format ); 916 d = new QSettingsPrivate( format );
855 Q_CHECK_PTR(d); 917 Q_CHECK_PTR(d);
856 918
857#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 919#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
858 d->sysd = 0; 920 d->sysd = 0;
859 if ( format == Native ) 921 if ( format == Native )
860 d->sysInit(); 922 d->sysInit();
861#else 923#else
862 Q_UNUSED(format); 924 Q_UNUSED(format);
863#endif 925#endif
864} 926}
865 927
866/*! 928/*!
867 Destroys the settings object. All modifications made to the settings 929 Destroys the settings object. All modifications made to the settings
868 will automatically be saved. 930 will automatically be saved.
869 931
870*/ 932*/
871QSettings::~QSettings() 933QSettings::~QSettings()
872{ 934{
873 sync(); 935 sync();
874 936
875#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 937#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
876 if ( d->sysd ) 938 if ( d->sysd )
877 d->sysClear(); 939 d->sysClear();
878#endif 940#endif
879 941
880 delete d; 942 delete d;
881} 943}
882 944
883 945
884/*! \internal 946/*! \internal
885 Writes all modifications to the settings to disk. If any errors are 947 Writes all modifications to the settings to disk. If any errors are
886 encountered, this function returns FALSE, otherwise it will return TRUE. 948 encountered, this function returns FALSE, otherwise it will return TRUE.
887*/ 949*/
888bool QSettings::sync() 950bool QSettings::sync()
889{ 951{
890#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 952#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
891 if ( d->sysd ) 953 if ( d->sysd )
892 return d->sysSync(); 954 return d->sysSync();
893#endif 955#endif
894 if (! d->modified) 956 if (! d->modified)
895 // fake success 957 // fake success
896 return TRUE; 958 return TRUE;
897 959
898 bool success = TRUE; 960 bool success = TRUE;
899 QMap<QString,QSettingsHeading>::Iterator it = d->headings.begin(); 961 QMap<QString,QSettingsHeading>::Iterator it = d->headings.begin();
900 962
901 while (it != d->headings.end()) { 963 while (it != d->headings.end()) {
902 // determine filename 964 // determine filename
903 QSettingsHeading hd(*it); 965 QSettingsHeading hd(*it);
904 QSettingsHeading::Iterator hdit = hd.begin(); 966 QSettingsHeading::Iterator hdit = hd.begin();
905 QFile file; 967 QFile file;
906 968
907 QStringList::Iterator pit = d->searchPaths.begin(); 969 QStringList::Iterator pit = d->searchPaths.begin();
970 if ( !d->globalScope )
971 ++pit;
908 while (pit != d->searchPaths.end()) { 972 while (pit != d->searchPaths.end()) {
909 QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_"); 973 QString filebase = it.key().lower().replace(QRegExp("\\s+"), "_");
910 QFileInfo di(*pit); 974 QFileInfo di(*pit);
911 QFileInfo fi((*pit++) + "/" + filebase + "rc"); 975 QFileInfo fi((*pit++) + "/" + filebase + "rc");
912 976
913 if ((fi.exists() && fi.isFile() && fi.isWritable()) || 977 if ((fi.exists() && fi.isFile() && fi.isWritable()) ||
914 (! fi.exists() && di.isDir() && di.isWritable())) { 978 (! fi.exists() && di.isDir() && di.isWritable())) {
915 file.setName(fi.filePath()); 979 file.setName(fi.filePath());
916 break; 980 break;
917 } 981 }
918 } 982 }
919 983
920 it++; 984 ++it;
921 985
922 if (file.name().isNull() || file.name().isEmpty()) { 986 if ( file.name().isEmpty() ) {
923 987
924#ifdef QT_CHECK_STATE 988#ifdef QT_CHECK_STATE
925 qWarning("QSettings::sync: filename is null/empty"); 989 qWarning("QSettings::sync: filename is null/empty");
926#endif // QT_CHECK_STATE 990#endif // QT_CHECK_STATE
927 991
928 success = FALSE; 992 success = FALSE;
929 continue; 993 continue;
930 } 994 }
931 995
932 HANDLE lockfd = openlock( file.name(), Q_LOCKWRITE ); 996 HANDLE lockfd = openlock( file.name(), Q_LOCKWRITE );
933 997
934 if (! file.open(IO_WriteOnly)) { 998 if (! file.open(IO_WriteOnly)) {
935 999
936#ifdef QT_CHECK_STATE 1000#ifdef QT_CHECK_STATE
937 qWarning("QSettings::sync: failed to open '%s' for writing", 1001 qWarning("QSettings::sync: failed to open '%s' for writing",
938 file.name().latin1()); 1002 file.name().latin1());
939#endif // QT_CHECK_STATE 1003#endif // QT_CHECK_STATE
940 1004
941 success = FALSE; 1005 success = FALSE;
942 continue; 1006 continue;
943 } 1007 }
944 1008
945 // spew to file 1009 // spew to file
946 QTextStream stream(&file); 1010 QTextStream stream(&file);
947 stream.setEncoding(QTextStream::UnicodeUTF8); 1011 stream.setEncoding(QTextStream::UnicodeUTF8);
948 1012
949 while (hdit != hd.end()) { 1013 while (hdit != hd.end()) {
950 if ((*hdit).count() > 0) { 1014 if ((*hdit).count() > 0) {
951 stream << "[" << hdit.key() << "]" << endl; 1015 stream << "[" << hdit.key() << "]" << endl;
952 1016
953 QSettingsGroup grp(*hdit); 1017 QSettingsGroup grp(*hdit);
954 QSettingsGroup::Iterator grpit = grp.begin(); 1018 QSettingsGroup::Iterator grpit = grp.begin();
955 1019
956 while (grpit != grp.end()) { 1020 while (grpit != grp.end()) {
957 QString v = grpit.data(); 1021 QString v = grpit.data();
958 if ( v.isNull() ) { 1022 if ( v.isNull() ) {
959 v = "\\0"; // escape null string 1023 v = "\\0"; // escape null string
960 } else { 1024 } else {
961 v.replace("\\", "\\\\"); // escape backslash 1025 v.replace("\\", "\\\\"); // escape backslash
962 v.replace("\n", "\\n"); // escape newlines 1026 v.replace("\n", "\\n"); // escape newlines
963 } 1027 }
964 1028
965 stream << grpit.key() << "=" << v << endl; 1029 stream << grpit.key() << "=" << v << endl;
966 grpit++; 1030 ++grpit;
967 } 1031 }
968 1032
969 stream << endl; 1033 stream << endl;
970 } 1034 }
971 1035
972 hdit++; 1036 ++hdit;
973 } 1037 }
974 1038
975 if (file.status() != IO_Ok) { 1039 if (file.status() != IO_Ok) {
976 1040
977#ifdef QT_CHECK_STATE 1041#ifdef QT_CHECK_STATE
978 qWarning("QSettings::sync: error at end of write"); 1042 qWarning("QSettings::sync: error at end of write");
979#endif // QT_CHECK_STATE 1043#endif // QT_CHECK_STATE
980 1044
981 success = FALSE; 1045 success = FALSE;
982 } 1046 }
983 1047
984 file.close(); 1048 file.close();
985 1049
986 closelock( lockfd ); 1050 closelock( lockfd );
987 } 1051 }
988 1052
989 d->modified = FALSE; 1053 d->modified = FALSE;
990 1054
991 return success; 1055 return success;
992} 1056}
993 1057
994 1058
995/*! 1059/*!
996 \fn bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) const 1060 \fn bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) const
997 1061
998 Reads the entry specified by \a key, and returns a bool, or the 1062 Reads the entry specified by \a key, and returns a bool, or the
999 default value, \a def, if the entry couldn't be read. 1063 default value, \a def, if the entry couldn't be read.
1000 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE 1064 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE
1001 otherwise. 1065 otherwise.
1002 1066
1003 \sa readEntry(), readNumEntry(), readDoubleEntry(), writeEntry(), removeEntry() 1067 \sa readEntry(), readNumEntry(), readDoubleEntry(), writeEntry(), removeEntry()
1004*/ 1068*/
1005 1069
1006/*! 1070/*!
1007 \internal 1071 \internal
1008*/ 1072*/
1009bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok ) 1073bool QSettings::readBoolEntry(const QString &key, bool def, bool *ok )
1010{ 1074{
1011 if ( !verifyKey( key ) ) { 1075 if ( !qt_verify_key( key ) ) {
1012#if defined(QT_CHECK_STATE) 1076#if defined(QT_CHECK_STATE)
1013 qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1077 qWarning( "QSettings::readBoolEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1014#endif 1078#endif
1015 if ( ok ) 1079 if ( ok )
1016 *ok = FALSE; 1080 *ok = FALSE;
1017 1081
1018 return def; 1082 return def;
1019 } 1083 }
1020 1084
1021 QString theKey = groupKey( group(), key ); 1085#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1022#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1023 if ( d->sysd ) 1086 if ( d->sysd )
1024 return d->sysReadBoolEntry( theKey, def, ok ); 1087 return d->sysReadBoolEntry( groupKey( group(), key ), def, ok );
1025#endif 1088#endif
1026 1089
1027 QString value = readEntry( theKey, ( def ? "true" : "false" ), ok ); 1090 QString value = readEntry( key, ( def ? "true" : "false" ), ok );
1028 1091
1029 if (value.lower() == "true") 1092 if (value.lower() == "true")
1030 return TRUE; 1093 return TRUE;
1031 else if (value.lower() == "false") 1094 else if (value.lower() == "false")
1032 return FALSE; 1095 return FALSE;
1033 else if (value == "1") 1096 else if (value == "1")
1034 return TRUE; 1097 return TRUE;
1035 else if (value == "0") 1098 else if (value == "0")
1036 return FALSE; 1099 return FALSE;
1037 1100
1038 if (! value.isEmpty()) 1101 if (! value.isEmpty())
1039 qWarning("QSettings::readBoolEntry: '%s' is not 'true' or 'false'", 1102 qWarning("QSettings::readBoolEntry: '%s' is not 'true' or 'false'",
1040 value.latin1()); 1103 value.latin1());
1041 if ( ok ) 1104 if ( ok )
1042 *ok = FALSE; 1105 *ok = FALSE;
1043 return def; 1106 return def;
1044} 1107}
1045 1108
1046 1109
1047/*! 1110/*!
1048 \fn double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) const 1111 \fn double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) const
1049 1112
1050 Reads the entry specified by \a key, and returns a double, or the 1113 Reads the entry specified by \a key, and returns a double, or the
1051 default value, \a def, if the entry couldn't be read. 1114 default value, \a def, if the entry couldn't be read.
1052 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE 1115 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE
1053 otherwise. 1116 otherwise.
1054 1117
1055 \sa readEntry(), readNumEntry(), readBoolEntry(), writeEntry(), removeEntry() 1118 \sa readEntry(), readNumEntry(), readBoolEntry(), writeEntry(), removeEntry()
1056*/ 1119*/
1057 1120
1058/*! 1121/*!
1059 \internal 1122 \internal
1060*/ 1123*/
1061double QSettings::readDoubleEntry(const QString &key, double def, bool *ok ) 1124double QSettings::readDoubleEntry(const QString &key, double def, bool *ok )
1062{ 1125{
1063 if ( !verifyKey( key ) ) { 1126 if ( !qt_verify_key( key ) ) {
1064#if defined(QT_CHECK_STATE) 1127#if defined(QT_CHECK_STATE)
1065 qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1128 qWarning( "QSettings::readDoubleEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1066#endif 1129#endif
1067 if ( ok ) 1130 if ( ok )
1068 *ok = FALSE; 1131 *ok = FALSE;
1069 1132
1070 return def; 1133 return def;
1071 } 1134 }
1072 1135
1073 QString theKey = groupKey( group(), key ); 1136#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1074#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1075 if ( d->sysd ) 1137 if ( d->sysd )
1076 return d->sysReadDoubleEntry( theKey, def, ok ); 1138 return d->sysReadDoubleEntry( groupKey( group(), key ), def, ok );
1077#endif 1139#endif
1078 1140
1079 QString value = readEntry( theKey, QString::number(def), ok ); 1141 QString value = readEntry( key, QString::number(def), ok );
1080 bool conv_ok; 1142 bool conv_ok;
1081 double retval = value.toDouble( &conv_ok ); 1143 double retval = value.toDouble( &conv_ok );
1082 if ( conv_ok ) 1144 if ( conv_ok )
1083 return retval; 1145 return retval;
1084 if ( ! value.isEmpty() ) 1146 if ( ! value.isEmpty() )
1085 qWarning( "QSettings::readDoubleEntry: '%s' is not a number", 1147 qWarning( "QSettings::readDoubleEntry: '%s' is not a number",
1086 value.latin1() ); 1148 value.latin1() );
1087 if ( ok ) 1149 if ( ok )
1088 *ok = FALSE; 1150 *ok = FALSE;
1089 return def; 1151 return def;
1090} 1152}
1091 1153
1092 1154
1093/*! 1155/*!
1094 \fn int QSettings::readNumEntry(const QString &key, int def, bool *ok ) const 1156 \fn int QSettings::readNumEntry(const QString &key, int def, bool *ok ) const
1095 1157
1096 Reads the entry specified by \a key, and returns an integer, or the 1158 Reads the entry specified by \a key, and returns an integer, or the
1097 default value, \a def, if the entry couldn't be read. 1159 default value, \a def, if the entry couldn't be read.
1098 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE 1160 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE
1099 otherwise. 1161 otherwise.
1100 1162
1101 \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry() 1163 \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry()
1102*/ 1164*/
1103 1165
1104/*! 1166/*!
1105 \internal 1167 \internal
1106*/ 1168*/
1107int QSettings::readNumEntry(const QString &key, int def, bool *ok ) 1169int QSettings::readNumEntry(const QString &key, int def, bool *ok )
1108{ 1170{
1109 if ( !verifyKey( key ) ) { 1171 if ( !qt_verify_key( key ) ) {
1110#if defined(QT_CHECK_STATE) 1172#if defined(QT_CHECK_STATE)
1111 qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1173 qWarning( "QSettings::readNumEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1112#endif 1174#endif
1113 if ( ok ) 1175 if ( ok )
1114 *ok = FALSE; 1176 *ok = FALSE;
1115 return def; 1177 return def;
1116 } 1178 }
1117 1179
1118 QString theKey = groupKey( group(), key ); 1180#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1119
1120#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1121 if ( d->sysd ) 1181 if ( d->sysd )
1122 return d->sysReadNumEntry( theKey, def, ok ); 1182 return d->sysReadNumEntry( groupKey( group(), key ), def, ok );
1123#endif 1183#endif
1124 1184
1125 QString value = readEntry( theKey, QString::number( def ), ok ); 1185 QString value = readEntry( key, QString::number( def ), ok );
1126 bool conv_ok; 1186 bool conv_ok;
1127 int retval = value.toInt( &conv_ok ); 1187 int retval = value.toInt( &conv_ok );
1128 if ( conv_ok ) 1188 if ( conv_ok )
1129 return retval; 1189 return retval;
1130 if ( ! value.isEmpty() ) 1190 if ( ! value.isEmpty() )
1131 qWarning( "QSettings::readNumEntry: '%s' is not a number", 1191 qWarning( "QSettings::readNumEntry: '%s' is not a number",
1132 value.latin1() ); 1192 value.latin1() );
1133 if ( ok ) 1193 if ( ok )
1134 *ok = FALSE; 1194 *ok = FALSE;
1135 return def; 1195 return def;
1136} 1196}
1137 1197
1138 1198
1139/*! 1199/*!
1140 \fn QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) const 1200 \fn QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) const
1141 1201
1142 Reads the entry specified by \a key, and returns a QString, or the 1202 Reads the entry specified by \a key, and returns a QString, or the
1143 default value, \a def, if the entry couldn't be read. 1203 default value, \a def, if the entry couldn't be read.
1144 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE 1204 If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE
1145 otherwise. 1205 otherwise.
1146 1206
1147 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry() 1207 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry()
1148*/ 1208*/
1149 1209
1150/*! 1210/*!
1151 \internal 1211 \internal
1152*/ 1212*/
1153QString QSettings::readEntry(const QString &key, const QString &def, bool *ok ) 1213QString QSettings::readEntry(const QString &key, const QString &def, bool *ok )
1154{ 1214{
1155 if ( !verifyKey( key ) ) { 1215 if ( !qt_verify_key( key ) ) {
1156#if defined(QT_CHECK_STATE) 1216#if defined(QT_CHECK_STATE)
1157 qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1217 qWarning( "QSettings::readEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1158#endif 1218#endif
1159 if ( ok ) 1219 if ( ok )
1160 *ok = FALSE; 1220 *ok = FALSE;
1161 1221
1162 return def; 1222 return def;
1163 } 1223 }
1164 1224
1165 QString theKey = groupKey( group(), key ); 1225 QString theKey = groupKey( group(), key );
1166 1226
1167#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1227#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1168 if ( d->sysd ) 1228 if ( d->sysd )
1169 return d->sysReadEntry( theKey, def, ok ); 1229 return d->sysReadEntry( theKey, def, ok );
1170#endif 1230#endif
1171 1231
1172 if ( ok ) // no, everything is not ok 1232 if ( ok ) // no, everything is not ok
1173 *ok = FALSE; 1233 *ok = FALSE;
1174 1234
1175 QString realkey; 1235 QString realkey;
1176 1236
1177 if (theKey[0] == '/') { 1237 if (theKey[0] == '/') {
1178 // parse our key 1238 // parse our key
1179 QStringList list(QStringList::split('/', theKey)); 1239 QStringList list(QStringList::split('/', theKey));
1180 1240
1181 if (list.count() < 2) { 1241 if (list.count() < 2) {
1182#ifdef QT_CHECK_STATE 1242#ifdef QT_CHECK_STATE
1183 qWarning("QSettings::readEntry: invalid key '%s'", theKey.latin1()); 1243 qWarning("QSettings::readEntry: invalid key '%s'", theKey.latin1());
1184#endif // QT_CHECK_STATE 1244#endif // QT_CHECK_STATE
1185 if ( ok ) 1245 if ( ok )
1186 *ok = FALSE; 1246 *ok = FALSE;
1187 return def; 1247 return def;
1188 } 1248 }
1189 1249
1190 if (list.count() == 2) { 1250 if (list.count() == 2) {
1191 d->heading = list[0]; 1251 d->heading = list[0];
1192 d->group = "General"; 1252 d->group = "General";
1193 realkey = list[1]; 1253 realkey = list[1];
1194 } else { 1254 } else {
1195 d->heading = list[0]; 1255 d->heading = list[0];
1196 d->group = list[1]; 1256 d->group = list[1];
1197 1257
1198 // remove the group from the list 1258 // remove the group from the list
1199 list.remove(list.at(1)); 1259 list.remove(list.at(1));
1200 // remove the heading from the list 1260 // remove the heading from the list
1201 list.remove(list.at(0)); 1261 list.remove(list.at(0));
1202 1262
1203 realkey = list.join("/"); 1263 realkey = list.join("/");
1204 } 1264 }
1205 } else 1265 } else
1206 realkey = theKey; 1266 realkey = theKey;
1207 1267
1208 QSettingsGroup grp = d->readGroup(); 1268 QSettingsGroup grp = d->readGroup();
1209 QString retval = grp[realkey]; 1269 QSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end();
1210 if ( retval.isNull() ) 1270 QString retval = def;
1211 retval = def; 1271 if ( it != end ) {
1212 else if ( ok ) // everything is ok 1272 // found the value we needed
1213 *ok = TRUE; 1273 retval = *it;
1274 if ( ok ) *ok = TRUE;
1275 }
1214 return retval; 1276 return retval;
1215} 1277}
1216 1278
1217 1279
1218#if !defined(Q_NO_BOOL_TYPE) 1280#if !defined(Q_NO_BOOL_TYPE)
1219/*! 1281/*!
1220 Writes the boolean entry \a value into key \a key. The \a key is 1282 Writes the boolean entry \a value into key \a key. The \a key is
1221 created if it doesn't exist. Any previous value is overwritten by \a 1283 created if it doesn't exist. Any previous value is overwritten by \a
1222 value. 1284 value.
1223 1285
1224 If an error occurs the settings are left unchanged and FALSE is 1286 If an error occurs the settings are left unchanged and FALSE is
1225 returned; otherwise TRUE is returned. 1287 returned; otherwise TRUE is returned.
1226 1288
1227 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1289 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
1228*/ 1290*/
1229bool QSettings::writeEntry(const QString &key, bool value) 1291bool QSettings::writeEntry(const QString &key, bool value)
1230{ 1292{
1231 if ( !verifyKey( key ) ) { 1293 if ( !qt_verify_key( key ) ) {
1232#if defined(QT_CHECK_STATE) 1294#if defined(QT_CHECK_STATE)
1233 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1295 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1234#endif 1296#endif
1235 return FALSE; 1297 return FALSE;
1236 } 1298 }
1237 1299
1238 QString theKey = groupKey( group(), key ); 1300#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1239
1240#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1241 if ( d->sysd ) 1301 if ( d->sysd )
1242 return d->sysWriteEntry( theKey, value ); 1302 return d->sysWriteEntry( groupKey( group(), key ), value );
1243#endif 1303#endif
1244 QString s(value ? "true" : "false"); 1304 QString s(value ? "true" : "false");
1245 return writeEntry(theKey, s); 1305 return writeEntry(key, s);
1246} 1306}
1247#endif 1307#endif
1248 1308
1249 1309
1250/*! 1310/*!
1251 \overload 1311 \overload
1252 Writes the double entry \a value into key \a key. The \a key is 1312 Writes the double entry \a value into key \a key. The \a key is
1253 created if it doesn't exist. Any previous value is overwritten by \a 1313 created if it doesn't exist. Any previous value is overwritten by \a
1254 value. 1314 value.
1255 1315
1256 If an error occurs the settings are left unchanged and FALSE is 1316 If an error occurs the settings are left unchanged and FALSE is
1257 returned; otherwise TRUE is returned. 1317 returned; otherwise TRUE is returned.
1258 1318
1259 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1319 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
1260*/ 1320*/
1261bool QSettings::writeEntry(const QString &key, double value) 1321bool QSettings::writeEntry(const QString &key, double value)
1262{ 1322{
1263 if ( !verifyKey( key ) ) { 1323 if ( !qt_verify_key( key ) ) {
1264#if defined(QT_CHECK_STATE) 1324#if defined(QT_CHECK_STATE)
1265 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1325 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1266#endif 1326#endif
1267 return FALSE; 1327 return FALSE;
1268 } 1328 }
1269 1329
1270 QString theKey = groupKey( group(), key ); 1330#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1271
1272#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1273 if ( d->sysd ) 1331 if ( d->sysd )
1274 return d->sysWriteEntry( theKey, value ); 1332 return d->sysWriteEntry( groupKey( group(), key ), value );
1275#endif 1333#endif
1276 QString s(QString::number(value)); 1334 QString s(QString::number(value));
1277 return writeEntry(theKey, s); 1335 return writeEntry(key, s);
1278} 1336}
1279 1337
1280 1338
1281/*! 1339/*!
1282 \overload 1340 \overload
1283 Writes the integer entry \a value into key \a key. The \a key is 1341 Writes the integer entry \a value into key \a key. The \a key is
1284 created if it doesn't exist. Any previous value is overwritten by \a 1342 created if it doesn't exist. Any previous value is overwritten by \a
1285 value. 1343 value.
1286 1344
1287 If an error occurs the settings are left unchanged and FALSE is 1345 If an error occurs the settings are left unchanged and FALSE is
1288 returned; otherwise TRUE is returned. 1346 returned; otherwise TRUE is returned.
1289 1347
1290 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1348 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
1291*/ 1349*/
1292bool QSettings::writeEntry(const QString &key, int value) 1350bool QSettings::writeEntry(const QString &key, int value)
1293{ 1351{
1294 if ( !verifyKey( key ) ) { 1352 if ( !qt_verify_key( key ) ) {
1295#if defined(QT_CHECK_STATE) 1353#if defined(QT_CHECK_STATE)
1296 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1354 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1297#endif 1355#endif
1298 return FALSE; 1356 return FALSE;
1299 } 1357 }
1300 1358
1301 QString theKey = groupKey( group(), key ); 1359#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1302
1303#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
1304 if ( d->sysd ) 1360 if ( d->sysd )
1305 return d->sysWriteEntry( theKey, value ); 1361 return d->sysWriteEntry( groupKey( group(), key ), value );
1306#endif 1362#endif
1307 QString s(QString::number(value)); 1363 QString s(QString::number(value));
1308 return writeEntry(theKey, s); 1364 return writeEntry(key, s);
1309} 1365}
1310 1366
1311 1367
1312/*! 1368/*!
1313 \internal 1369 \internal
1314 1370
1315 Writes the entry specified by \a key with the string-literal \a value, 1371 Writes the entry specified by \a key with the string-literal \a value,
1316 replacing any previous setting. If \a value is zero-length or null, the 1372 replacing any previous setting. If \a value is zero-length or null, the
1317 entry is replaced by an empty setting. 1373 entry is replaced by an empty setting.
1318 1374
1319 \e NOTE: This function is provided because some compilers use the 1375 \e NOTE: This function is provided because some compilers use the
1320 writeEntry (const QString &, bool) overload for this code: 1376 writeEntry (const QString &, bool) overload for this code:
1321 writeEntry ("/foo/bar", "baz") 1377 writeEntry ("/foo/bar", "baz")
1322 1378
1323 If an error occurs, this functions returns FALSE and the object is left 1379 If an error occurs, this functions returns FALSE and the object is left
1324 unchanged. 1380 unchanged.
1325 1381
1326 \sa readEntry(), removeEntry() 1382 \sa readEntry(), removeEntry()
1327*/ 1383*/
1328bool QSettings::writeEntry(const QString &key, const char *value) 1384bool QSettings::writeEntry(const QString &key, const char *value)
1329{ 1385{
1330 if ( !verifyKey( key ) ) { 1386 if ( !qt_verify_key( key ) ) {
1331#if defined(QT_CHECK_STATE) 1387#if defined(QT_CHECK_STATE)
1332 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1388 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1333#endif 1389#endif
1334 return FALSE; 1390 return FALSE;
1335 } 1391 }
1336 1392
1337 QString theKey = groupKey( group(), key ); 1393 return writeEntry(key, QString(value));
1338
1339 return writeEntry(theKey, QString(value));
1340} 1394}
1341 1395
1342 1396
1343/*! 1397/*!
1344 \overload 1398 \overload
1345 Writes the string entry \a value into key \a key. The \a key is 1399 Writes the string entry \a value into key \a key. The \a key is
1346 created if it doesn't exist. Any previous value is overwritten by \a 1400 created if it doesn't exist. Any previous value is overwritten by \a
1347 value. If \a value is an empty string or a null string the key's 1401 value. If \a value is an empty string or a null string the key's
1348 value will be an empty string. 1402 value will be an empty string.
1349 1403
1350 If an error occurs the settings are left unchanged and FALSE is 1404 If an error occurs the settings are left unchanged and FALSE is
1351 returned; otherwise TRUE is returned. 1405 returned; otherwise TRUE is returned.
1352 1406
1353 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1407 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
1354*/ 1408*/
1355bool QSettings::writeEntry(const QString &key, const QString &value) 1409bool QSettings::writeEntry(const QString &key, const QString &value)
1356{ 1410{
1357 if ( !verifyKey( key ) ) { 1411 if ( !qt_verify_key( key ) ) {
1358#if defined(QT_CHECK_STATE) 1412#if defined(QT_CHECK_STATE)
1359 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1413 qWarning( "QSettings::writeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1360#endif 1414#endif
1361 return FALSE; 1415 return FALSE;
1362 } 1416 }
1363 1417
1364 QString theKey = groupKey( group(), key ); 1418 QString theKey = groupKey( group(), key );
1365 1419
1366#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1420#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1367 if ( d->sysd ) 1421 if ( d->sysd )
1368 return d->sysWriteEntry( theKey, value ); 1422 return d->sysWriteEntry( theKey, value );
1369#endif 1423#endif
1370 // NOTE: we *do* allow value to be a null/empty string 1424 // NOTE: we *do* allow value to be a null/empty string
1371 1425
1372 QString realkey; 1426 QString realkey;
1373 1427
1374 if (theKey[0] == '/') { 1428 if (theKey[0] == '/') {
1375 // parse our key 1429 // parse our key
1376 QStringList list(QStringList::split('/', theKey)); 1430 QStringList list(QStringList::split('/', theKey));
1377 1431
1378 if (list.count() < 2) { 1432 if (list.count() < 2) {
1379#ifdef QT_CHECK_STATE 1433#ifdef QT_CHECK_STATE
1380 qWarning("QSettings::writeEntry: invalid key '%s'", theKey.latin1()); 1434 qWarning("QSettings::writeEntry: invalid key '%s'", theKey.latin1());
1381#endif // QT_CHECK_STATE 1435#endif // QT_CHECK_STATE
1382 1436
1383 return FALSE; 1437 return FALSE;
1384 } 1438 }
1385 1439
1386 if (list.count() == 2) { 1440 if (list.count() == 2) {
1387 d->heading = list[0]; 1441 d->heading = list[0];
1388 d->group = "General"; 1442 d->group = "General";
1389 realkey = list[1]; 1443 realkey = list[1];
1390 } else { 1444 } else {
@@ -1394,58 +1448,58 @@ bool QSettings::writeEntry(const QString &key, const QString &value)
1394 // remove the group from the list 1448 // remove the group from the list
1395 list.remove(list.at(1)); 1449 list.remove(list.at(1));
1396 // remove the heading from the list 1450 // remove the heading from the list
1397 list.remove(list.at(0)); 1451 list.remove(list.at(0));
1398 1452
1399 realkey = list.join("/"); 1453 realkey = list.join("/");
1400 } 1454 }
1401 } else 1455 } else
1402 realkey = theKey; 1456 realkey = theKey;
1403 1457
1404 d->writeGroup(realkey, value); 1458 d->writeGroup(realkey, value);
1405 return TRUE; 1459 return TRUE;
1406} 1460}
1407 1461
1408 1462
1409/*! 1463/*!
1410 Removes the entry specified by \a key. 1464 Removes the entry specified by \a key.
1411 1465
1412 Returns TRUE if the entry existed and was removed; otherwise returns FALSE. 1466 Returns TRUE if the entry existed and was removed; otherwise returns FALSE.
1413 1467
1414 \sa readEntry(), writeEntry() 1468 \sa readEntry(), writeEntry()
1415*/ 1469*/
1416bool QSettings::removeEntry(const QString &key) 1470bool QSettings::removeEntry(const QString &key)
1417{ 1471{
1418 if ( !verifyKey( key ) ) { 1472 if ( !qt_verify_key( key ) ) {
1419#if defined(QT_CHECK_STATE) 1473#if defined(QT_CHECK_STATE)
1420 qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1474 qWarning( "QSettings::removeEntry: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1421#endif 1475#endif
1422 return FALSE; 1476 return FALSE;
1423 } 1477 }
1424 1478
1425 QString theKey = groupKey( group(), key ); 1479 QString theKey = groupKey( group(), key );
1426 1480
1427#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1481#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1428 if ( d->sysd ) 1482 if ( d->sysd )
1429 return d->sysRemoveEntry( theKey ); 1483 return d->sysRemoveEntry( theKey );
1430#endif 1484#endif
1431 1485
1432 QString realkey; 1486 QString realkey;
1433 1487
1434 if (theKey[0] == '/') { 1488 if (theKey[0] == '/') {
1435 // parse our key 1489 // parse our key
1436 QStringList list(QStringList::split('/', theKey)); 1490 QStringList list(QStringList::split('/', theKey));
1437 1491
1438 if (list.count() < 2) { 1492 if (list.count() < 2) {
1439#ifdef QT_CHECK_STATE 1493#ifdef QT_CHECK_STATE
1440 qWarning("QSettings::removeEntry: invalid key '%s'", theKey.latin1()); 1494 qWarning("QSettings::removeEntry: invalid key '%s'", theKey.latin1());
1441#endif // QT_CHECK_STATE 1495#endif // QT_CHECK_STATE
1442 1496
1443 return FALSE; 1497 return FALSE;
1444 } 1498 }
1445 1499
1446 if (list.count() == 2) { 1500 if (list.count() == 2) {
1447 d->heading = list[0]; 1501 d->heading = list[0];
1448 d->group = "General"; 1502 d->group = "General";
1449 realkey = list[1]; 1503 realkey = list[1];
1450 } else { 1504 } else {
1451 d->heading = list[0]; 1505 d->heading = list[0];
@@ -1473,272 +1527,295 @@ bool QSettings::removeEntry(const QString &key)
1473 Example settings: 1527 Example settings:
1474 \code 1528 \code
1475 /MyCompany/MyApplication/background color 1529 /MyCompany/MyApplication/background color
1476 /MyCompany/MyApplication/foreground color 1530 /MyCompany/MyApplication/foreground color
1477 /MyCompany/MyApplication/geometry/x 1531 /MyCompany/MyApplication/geometry/x
1478 /MyCompany/MyApplication/geometry/y 1532 /MyCompany/MyApplication/geometry/y
1479 /MyCompany/MyApplication/geometry/width 1533 /MyCompany/MyApplication/geometry/width
1480 /MyCompany/MyApplication/geometry/height 1534 /MyCompany/MyApplication/geometry/height
1481 \endcode 1535 \endcode
1482 \code 1536 \code
1483 QStringList keys = entryList( "/MyCompany/MyApplication" ); 1537 QStringList keys = entryList( "/MyCompany/MyApplication" );
1484 \endcode 1538 \endcode
1485 \c keys contains 'background color' and 'foreground color'. It does 1539 \c keys contains 'background color' and 'foreground color'. It does
1486 not contain 'geometry' because this key contains keys not entries. 1540 not contain 'geometry' because this key contains keys not entries.
1487 1541
1488 To access the geometry values could either use subkeyList() to read 1542 To access the geometry values could either use subkeyList() to read
1489 the keys and then read each entry, or simply read each entry 1543 the keys and then read each entry, or simply read each entry
1490 directly by specifying its full key, e.g. 1544 directly by specifying its full key, e.g.
1491 "/MyCompany/MyApplication/geometry/y". 1545 "/MyCompany/MyApplication/geometry/y".
1492 1546
1493 \sa subkeyList() 1547 \sa subkeyList()
1494*/ 1548*/
1495QStringList QSettings::entryList(const QString &key) const 1549QStringList QSettings::entryList(const QString &key) const
1496{ 1550{
1497 if ( !verifyKey( key ) ) { 1551 if ( !qt_verify_key( key ) ) {
1498#if defined(QT_CHECK_STATE) 1552#if defined(QT_CHECK_STATE)
1499 qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); 1553 qWarning( "QSettings::entryList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() );
1500#endif 1554#endif
1501 return QStringList(); 1555 return QStringList();
1502 } 1556 }
1503 1557
1504 QString theKey = groupKey( group(), key ); 1558 QString theKey = groupKey( group(), key );
1505 1559
1506#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1560#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1507 if ( d->sysd ) 1561 if ( d->sysd )
1508 return d->sysEntryList( theKey ); 1562 return d->sysEntryList( theKey );
1509#endif 1563#endif
1510 1564
1511 QString realkey; 1565 QString realkey;
1512 if (theKey[0] == '/') { 1566 if (theKey[0] == '/') {
1513 // parse our key 1567 // parse our key
1514 QStringList list(QStringList::split('/', theKey)); 1568 QStringList list(QStringList::split('/', theKey));
1515 1569
1516 if (list.count() < 1) { 1570 if (list.count() < 1) {
1517#ifdef QT_CHECK_STATE 1571#ifdef QT_CHECK_STATE
1518 qWarning("QSettings::listEntries: invalid key '%s'", theKey.latin1()); 1572 qWarning("QSettings::listEntries: invalid key '%s'", theKey.latin1());
1519#endif // QT_CHECK_STATE 1573#endif // QT_CHECK_STATE
1520 1574
1521 return QStringList(); 1575 return QStringList();
1522 } 1576 }
1523 1577
1524 if (list.count() == 1) { 1578 if (list.count() == 1) {
1525 d->heading = list[0]; 1579 d->heading = list[0];
1526 d->group = "General"; 1580 d->group = "General";
1527 } else { 1581 } else {
1528 d->heading = list[0]; 1582 d->heading = list[0];
1529 d->group = list[1]; 1583 d->group = list[1];
1530 1584
1531 // remove the group from the list 1585 // remove the group from the list
1532 list.remove(list.at(1)); 1586 list.remove(list.at(1));
1533 // remove the heading from the list 1587 // remove the heading from the list
1534 list.remove(list.at(0)); 1588 list.remove(list.at(0));
1535 1589
1536 realkey = list.join("/"); 1590 realkey = list.join("/");
1537 } 1591 }
1538 } else 1592 } else
1539 realkey = theKey; 1593 realkey = theKey;
1540 1594
1541 QSettingsGroup grp = d->readGroup(); 1595 QSettingsGroup grp = d->readGroup();
1542 QSettingsGroup::Iterator it = grp.begin(); 1596 QSettingsGroup::Iterator it = grp.begin();
1543 QStringList ret; 1597 QStringList ret;
1544 QString itkey; 1598 QString itkey;
1545 while (it != grp.end()) { 1599 while (it != grp.end()) {
1546 itkey = it.key(); 1600 itkey = it.key();
1547 it++; 1601 ++it;
1548 1602
1549 if ( realkey.length() > 0 ) { 1603 if ( realkey.length() > 0 ) {
1550 if ( itkey.left( realkey.length() ) != realkey ) 1604 if ( itkey.left( realkey.length() ) != realkey )
1551 continue; 1605 continue;
1552 else 1606 else
1553 itkey.remove( 0, realkey.length() + 1 ); 1607 itkey.remove( 0, realkey.length() + 1 );
1554 } 1608 }
1555 1609
1556 if ( itkey.find( '/' ) != -1 ) 1610 if ( itkey.find( '/' ) != -1 )
1557 continue; 1611 continue;
1558 1612
1559 ret << itkey; 1613 ret << itkey;
1560 } 1614 }
1561 1615
1562 return ret; 1616 return ret;
1563} 1617}
1564 1618
1565 1619
1566/*! 1620/*!
1567 Returns a list of the keys which contain keys under \a key. Does \e 1621 Returns a list of the keys which contain keys under \a key. Does \e
1568 not return any keys that contain entries. 1622 not return any keys that contain entries.
1569 1623
1570 Example settings: 1624 Example settings:
1571 \code 1625 \code
1572 /MyCompany/MyApplication/background color 1626 /MyCompany/MyApplication/background color
1573 /MyCompany/MyApplication/foreground color 1627 /MyCompany/MyApplication/foreground color
1574 /MyCompany/MyApplication/geometry/x 1628 /MyCompany/MyApplication/geometry/x
1575 /MyCompany/MyApplication/geometry/y 1629 /MyCompany/MyApplication/geometry/y
1576 /MyCompany/MyApplication/geometry/width 1630 /MyCompany/MyApplication/geometry/width
1577 /MyCompany/MyApplication/geometry/height 1631 /MyCompany/MyApplication/geometry/height
1578 /MyCompany/MyApplication/recent files/1 1632 /MyCompany/MyApplication/recent files/1
1579 /MyCompany/MyApplication/recent files/2 1633 /MyCompany/MyApplication/recent files/2
1580 /MyCompany/MyApplication/recent files/3 1634 /MyCompany/MyApplication/recent files/3
1581 \endcode 1635 \endcode
1582 \code 1636 \code
1583 QStringList keys = subkeyList( "/MyCompany/MyApplication" ); 1637 QStringList keys = subkeyList( "/MyCompany/MyApplication" );
1584 \endcode 1638 \endcode
1585 \c keys contains 'geometry' and 'recent files'. It does not contain 1639 \c keys contains 'geometry' and 'recent files'. It does not contain
1586 'background color' or 'foreground color' because they are keys which 1640 'background color' or 'foreground color' because they are keys which
1587 contain entries not keys. To get a list of keys that have values 1641 contain entries not keys. To get a list of keys that have values
1588 rather than subkeys use entryList(). 1642 rather than subkeys use entryList().
1589 1643
1590 \sa entryList() 1644 \sa entryList()
1591*/ 1645*/
1592QStringList QSettings::subkeyList(const QString &key) const 1646QStringList QSettings::subkeyList(const QString &key) const
1593{ 1647{
1594 if ( !verifyKey( key ) ) { 1648 if ( !qt_verify_key( key ) ) {
1595#if defined(QT_CHECK_STATE) 1649#if defined(QT_CHECK_STATE)
1596 qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() ); 1650 qWarning( "QSettings::subkeyList: Invalid key: %s", key.isNull() ? "(null)" : key.latin1() );
1597#endif 1651#endif
1598 return QStringList(); 1652 return QStringList();
1599 } 1653 }
1600 1654
1601 QString theKey = groupKey( group(), key ); 1655 QString theKey = groupKey( group(), key );
1602 1656
1603#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1657#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1604 if ( d->sysd ) 1658 if ( d->sysd )
1605 return d->sysSubkeyList( theKey ); 1659 return d->sysSubkeyList( theKey );
1606#endif 1660#endif
1607 1661
1608 QString realkey; 1662 QString realkey;
1663 int subkeycount = 2;
1609 if (theKey[0] == '/') { 1664 if (theKey[0] == '/') {
1610 // parse our key 1665 // parse our key
1611 QStringList list(QStringList::split('/', theKey)); 1666 QStringList list(QStringList::split('/', theKey));
1612 1667
1613 if (list.count() < 1) { 1668 if (list.count() < 1) {
1614#ifdef QT_CHECK_STATE 1669#ifdef QT_CHECK_STATE
1615 qWarning("QSettings::subkeyList: invalid key '%s'", theKey.latin1()); 1670 qWarning("QSettings::subkeyList: invalid key '%s'", theKey.latin1());
1616#endif // QT_CHECK_STATE 1671#endif // QT_CHECK_STATE
1617 1672
1618 return QStringList(); 1673 return QStringList();
1619 } 1674 }
1620 1675
1676 subkeycount = list.count();
1677
1621 if (list.count() == 1) { 1678 if (list.count() == 1) {
1622 d->heading = list[0]; 1679 d->heading = list[0];
1623 d->group = "General"; 1680 d->group = "General";
1624 } else { 1681 } else {
1625 d->heading = list[0]; 1682 d->heading = list[0];
1626 d->group = list[1]; 1683 d->group = list[1];
1627 1684
1628 // remove the group from the list 1685 // remove the group from the list
1629 list.remove(list.at(1)); 1686 list.remove(list.at(1));
1630 // remove the heading from the list 1687 // remove the heading from the list
1631 list.remove(list.at(0)); 1688 list.remove(list.at(0));
1632 1689
1633 realkey = list.join("/"); 1690 realkey = list.join("/");
1634 } 1691 }
1692
1635 } else 1693 } else
1636 realkey = theKey; 1694 realkey = theKey;
1637 1695
1696 QStringList ret;
1697 if ( subkeycount == 1 ) {
1698 QMap<QString,QSettingsHeading>::Iterator it = d->headings.begin();
1699 while ( it != d->headings.end() ) {
1700 if ( it.key() != "General" && ! ret.contains( it.key() ) )
1701 ret << it.key();
1702 ++it;
1703 }
1704
1705 return ret;
1706 }
1707
1638 QSettingsGroup grp = d->readGroup(); 1708 QSettingsGroup grp = d->readGroup();
1639 QSettingsGroup::Iterator it = grp.begin(); 1709 QSettingsGroup::Iterator it = grp.begin();
1640 QStringList ret;
1641 QString itkey; 1710 QString itkey;
1642 while (it != grp.end()) { 1711 while (it != grp.end()) {
1643 itkey = it.key(); 1712 itkey = it.key();
1644 it++; 1713 ++it;
1645 1714
1646 if ( realkey.length() > 0 ) { 1715 if ( realkey.length() > 0 ) {
1647 if ( itkey.left( realkey.length() ) != realkey ) 1716 if ( itkey.left( realkey.length() ) != realkey )
1648 continue; 1717 continue;
1649 else 1718 else
1650 itkey.remove( 0, realkey.length() + 1 ); 1719 itkey.remove( 0, realkey.length() + 1 );
1651 } 1720 }
1652 1721
1653 int slash = itkey.find( '/' ); 1722 int slash = itkey.find( '/' );
1654 if ( slash == -1 ) 1723 if ( slash == -1 )
1655 continue; 1724 continue;
1656 itkey.truncate( slash ); 1725 itkey.truncate( slash );
1657 1726
1658 if ( ! ret.contains( itkey ) ) 1727 if ( ! ret.contains( itkey ) )
1659 ret << itkey; 1728 ret << itkey;
1660 } 1729 }
1661 1730
1662 return ret; 1731 return ret;
1663} 1732}
1664 1733
1665 1734
1666/*! 1735/*!
1667 \internal 1736 \internal
1668 1737
1669 This function returns the time of last modification for \a key. 1738 This function returns the time of last modification for \a key.
1670*/ 1739*/
1671QDateTime QSettings::lastModficationTime(const QString &key) 1740QDateTime QSettings::lastModficationTime(const QString &key)
1672{ 1741{
1673 if ( !verifyKey( key ) ) { 1742 if ( !qt_verify_key( key ) ) {
1674#if defined(QT_CHECK_STATE) 1743#if defined(QT_CHECK_STATE)
1675 qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() ); 1744 qWarning( "QSettings::lastModficationTime: Invalid key: '%s'", key.isNull() ? "(null)" : key.latin1() );
1676#endif 1745#endif
1677 return QDateTime(); 1746 return QDateTime();
1678 } 1747 }
1679 1748
1680 QString theKey = groupKey( group(), key ); 1749 QString theKey = groupKey( group(), key );
1681 1750
1682#if defined(Q_WS_WIN) || defined(Q_OS_MAC) 1751#if !defined(QWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC))
1683 if ( d->sysd ) 1752 if ( d->sysd )
1684 return QDateTime(); 1753 return QDateTime();
1685#endif 1754#endif
1686 1755
1687 if (theKey[0] == '/') { 1756 if (theKey[0] == '/') {
1688 // parse our key 1757 // parse our key
1689 QStringList list(QStringList::split('/', theKey)); 1758 QStringList list(QStringList::split('/', theKey));
1690 1759
1691 if (list.count() < 2) { 1760 if (list.count() < 2) {
1692#ifdef QT_CHECK_STATE 1761#ifdef QT_CHECK_STATE
1693 qWarning("QSettings::lastModficationTime: invalid key '%s'", theKey.latin1()); 1762 qWarning("QSettings::lastModficationTime: invalid key '%s'", theKey.latin1());
1694#endif // QT_CHECK_STATE 1763#endif // QT_CHECK_STATE
1695 1764
1696 return QDateTime(); 1765 return QDateTime();
1697 } 1766 }
1698 1767
1699 if (list.count() == 2) { 1768 if (list.count() == 2) {
1700 d->heading = list[0]; 1769 d->heading = list[0];
1701 d->group = "General"; 1770 d->group = "General";
1702 } else { 1771 } else {
1703 d->heading = list[0]; 1772 d->heading = list[0];
1704 d->group = list[1]; 1773 d->group = list[1];
1705 } 1774 }
1706 } 1775 }
1707 1776
1708 return d->modificationTime(); 1777 return d->modificationTime();
1709} 1778}
1710 1779
1711 1780
1712/*! 1781/*!
1713 \overload 1782 \overload
1714 1783
1715 Writes the string list entry \a value into key \a key. The \a key 1784 Writes the string list entry \a value into key \a key. The \a key
1716 is created if it doesn't exist. Any previous value is overwritten 1785 is created if it doesn't exist. Any previous value is overwritten
1717 by \a value. The list is stored as a sequence of strings separated 1786 by \a value. The list is stored as a sequence of strings separated
1718 by \a separator, so none of the strings in the list should contain 1787 by \a separator (using QStringList::join()), so none of the
1719 the separator. If the list is empty or null the key's value will 1788 strings in the list should contain the separator. If the list is
1720 be an empty string. 1789 empty or null the key's value will be an empty string.
1790
1791 \warning The list should not contain empty or null strings, as
1792 readListEntry() will use QStringList::split() to recreate the
1793 list. As the documentation states, QStringList::split() will omit
1794 empty strings from the list. Because of this, it is impossible to
1795 retrieve identical list data that is stored with this function.
1796 We recommend using the writeEntry() and readListEntry() overloads
1797 that do not take a \a separator argument.
1721 1798
1722 If an error occurs the settings are left unchanged and FALSE is 1799 If an error occurs the settings are left unchanged and FALSE is
1723 returned; otherwise returns TRUE. 1800 returned; otherwise returns TRUE.
1724 1801
1725 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1802 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
1726*/ 1803*/
1727bool QSettings::writeEntry(const QString &key, const QStringList &value, 1804bool QSettings::writeEntry(const QString &key, const QStringList &value,
1728 const QChar &separator) 1805 const QChar &separator)
1729{ 1806{
1730 QString s(value.join(separator)); 1807 QString s(value.join(separator));
1731 return writeEntry(key, s); 1808 return writeEntry(key, s);
1732} 1809}
1733 1810
1734/*! 1811/*!
1735 \overload 1812 \overload
1736 1813
1737 Writes the string list entry \a value into key \a key. The \a key 1814 Writes the string list entry \a value into key \a key. The \a key
1738 is created if it doesn't exist. Any previous value is overwritten 1815 is created if it doesn't exist. Any previous value is overwritten
1739 by \a value. 1816 by \a value.
1740 1817
1741 If an error occurs the settings are left unchanged and FALSE is 1818 If an error occurs the settings are left unchanged and FALSE is
1742 returned; otherwise returns TRUE. 1819 returned; otherwise returns TRUE.
1743 1820
1744 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() 1821 \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry()
@@ -1747,48 +1824,55 @@ bool QSettings::writeEntry(const QString &key, const QStringList &value)
1747{ 1824{
1748 QString s; 1825 QString s;
1749 for (QStringList::ConstIterator it=value.begin(); it!=value.end(); ++it) { 1826 for (QStringList::ConstIterator it=value.begin(); it!=value.end(); ++it) {
1750 QString el = *it; 1827 QString el = *it;
1751 if ( el.isNull() ) { 1828 if ( el.isNull() ) {
1752 el = "^0"; 1829 el = "^0";
1753 } else { 1830 } else {
1754 el.replace("^", "^^"); 1831 el.replace("^", "^^");
1755 } 1832 }
1756 s+=el; 1833 s+=el;
1757 s+="^e"; // end of element 1834 s+="^e"; // end of element
1758 } 1835 }
1759 return writeEntry(key, s); 1836 return writeEntry(key, s);
1760} 1837}
1761 1838
1762 1839
1763/*! 1840/*!
1764 \overload QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) const 1841 \overload QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) const
1765 1842
1766 Reads the entry specified by \a key as a string. The \a separator 1843 Reads the entry specified by \a key as a string. The \a separator
1767 is used to create a QStringList by calling QStringList::split(\a 1844 is used to create a QStringList by calling QStringList::split(\a
1768 separator, entry). If \a ok is not 0: \a *ok is set to TRUE if the 1845 separator, entry). If \a ok is not 0: \a *ok is set to TRUE if the
1769 key was read, otherwise \a *ok is set to FALSE. 1846 key was read, otherwise \a *ok is set to FALSE.
1770 1847
1848 \warning As the documentation states, QStringList::split() will
1849 omit empty strings from the list. Because of this, it is
1850 impossible to retrieve identical list data with this function. We
1851 recommend using the readListEntry() and writeEntry() overloads
1852 that do not take a \a separator argument.
1853
1854
1771 Note that if you want to iterate over the list, you should iterate 1855 Note that if you want to iterate over the list, you should iterate
1772 over a copy, e.g. 1856 over a copy, e.g.
1773 \code 1857 \code
1774 QStringList list = mySettings.readListEntry( "size", " " ); 1858 QStringList list = mySettings.readListEntry( "size", " " );
1775 QStringList::Iterator it = list.begin(); 1859 QStringList::Iterator it = list.begin();
1776 while( it != list.end() ) { 1860 while( it != list.end() ) {
1777 myProcessing( *it ); 1861 myProcessing( *it );
1778 ++it; 1862 ++it;
1779 } 1863 }
1780 \endcode 1864 \endcode
1781 1865
1782 \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), QStringList::split() 1866 \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), QStringList::split()
1783*/ 1867*/
1784 1868
1785/*! 1869/*!
1786 \internal 1870 \internal
1787*/ 1871*/
1788QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok ) 1872QStringList QSettings::readListEntry(const QString &key, const QChar &separator, bool *ok )
1789{ 1873{
1790 QString value = readEntry( key, QString::null, ok ); 1874 QString value = readEntry( key, QString::null, ok );
1791 if ( ok && !*ok ) 1875 if ( ok && !*ok )
1792 return QStringList(); 1876 return QStringList();
1793 1877
1794 return QStringList::split(separator, value); 1878 return QStringList::split(separator, value);
@@ -1826,130 +1910,151 @@ QStringList QSettings::readListEntry(const QString &key, bool *ok )
1826 QString s; 1910 QString s;
1827 bool esc=FALSE; 1911 bool esc=FALSE;
1828 for (int i=0; i<(int)value.length(); i++) { 1912 for (int i=0; i<(int)value.length(); i++) {
1829 if ( esc ) { 1913 if ( esc ) {
1830 if ( value[i] == 'e' ) { // end-of-string 1914 if ( value[i] == 'e' ) { // end-of-string
1831 l.append(s); 1915 l.append(s);
1832 s=""; 1916 s="";
1833 } else if ( value[i] == '0' ) { // null string 1917 } else if ( value[i] == '0' ) { // null string
1834 s=QString::null; 1918 s=QString::null;
1835 } else { 1919 } else {
1836 s.append(value[i]); 1920 s.append(value[i]);
1837 } 1921 }
1838 esc=FALSE; 1922 esc=FALSE;
1839 } else if ( value[i] == '^' ) { 1923 } else if ( value[i] == '^' ) {
1840 esc = TRUE; 1924 esc = TRUE;
1841 } else { 1925 } else {
1842 s.append(value[i]); 1926 s.append(value[i]);
1843 if ( i == (int)value.length()-1 ) 1927 if ( i == (int)value.length()-1 )
1844 l.append(s); 1928 l.append(s);
1845 } 1929 }
1846 } 1930 }
1847 return l; 1931 return l;
1848} 1932}
1849 1933
1934#ifdef Q_OS_MAC
1935void qt_setSettingsBasePath(const QString &); //qsettings_mac.cpp
1936#endif
1937
1850/*! 1938/*!
1851 Insert platform-dependent paths from platform-independent information. 1939 Insert platform-dependent paths from platform-independent information.
1940
1941 The \a domain should be an Internet domain name
1942 controlled by the producer of the software, eg. Trolltech products
1943 use "trolltech.com".
1852 1944
1853 The \a domain should be an Internet domain name 1945 The \a product should be the official name of the product.
1854 controlled by the producer of the software, eg. Trolltech products
1855 use "trolltech.com".
1856 1946
1857 The \a product should be the official name of the product. 1947 The \a scope should be
1948 QSettings::User for user-specific settings, or
1949 QSettings::Global for system-wide settings (generally
1950 these will be read-only to many users).
1858 1951
1859 The \a scope should be 1952 Not all information is relevant on all systems (e.g. scoping is
1860 QSettings::User for user-specific settings, or 1953 currently used only if QSettings accesses the Windows registry).
1861 QSettings::Global for system-wide settings (generally
1862 these will be read-only to many users).
1863*/ 1954*/
1864 1955
1865void QSettings::setPath( const QString &domain, const QString &product, Scope scope ) 1956void QSettings::setPath( const QString &domain, const QString &product, Scope scope )
1866{ 1957{
1867// On Windows, any trailing ".com(\..*)" is stripped from the domain. The 1958// On Windows, any trailing ".com(\..*)" is stripped from the domain. The
1868// Global scope corresponds to HKEY_LOCAL_MACHINE, and User corresponds to 1959// Global scope corresponds to HKEY_LOCAL_MACHINE, and User corresponds to
1869// HKEY_CURRENT_USER. Note that on some installations, not all users can 1960// HKEY_CURRENT_USER. Note that on some installations, not all users can
1870// write to the Global scope. On UNIX, any trailing ".com(\..*)" is stripped 1961// write to the Global scope. On UNIX, any trailing ".com(\..*)" is stripped
1871// from the domain. The Global scope corresponds to "/opt" (this would be 1962// from the domain. The Global scope corresponds to "/opt" (this would be
1872// configurable at library build time - eg. to "/usr/local" or "/usr"), 1963// configurable at library build time - eg. to "/usr/local" or "/usr"),
1873// while the User scope corresponds to $HOME/.*rc. 1964// while the User scope corresponds to $HOME/.*rc.
1874// Note that on most installations, not all users can write to the System 1965// Note that on most installations, not all users can write to the System
1875// scope. 1966// scope.
1876// 1967//
1877// On MacOS X, if there is no "." in domain, append ".com", then reverse the 1968// On MacOS X, if there is no "." in domain, append ".com", then reverse the
1878// order of the elements (Mac OS uses "com.apple.finder" as domain+product). 1969// order of the elements (Mac OS uses "com.apple.finder" as domain+product).
1879// The Global scope corresponds to /Library/Preferences/*.plist, while the 1970// The Global scope corresponds to /Library/Preferences/*.plist, while the
1880// User scope corresponds to ~/Library/Preferences/*.plist. 1971// User scope corresponds to ~/Library/Preferences/*.plist.
1881// Note that on most installations, not all users can write to the System 1972// Note that on most installations, not all users can write to the System
1882// scope. 1973// scope.
1974 d->globalScope = scope == Global;
1975
1883 QString actualSearchPath; 1976 QString actualSearchPath;
1884 int lastDot = domain.findRev( '.' ); 1977 int lastDot = domain.findRev( '.' );
1885 1978
1886#if defined(Q_WS_WIN) 1979#if defined(Q_WS_WIN)
1887 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; 1980 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product;
1888 insertSearchPath( Windows, actualSearchPath ); 1981 insertSearchPath( Windows, actualSearchPath );
1889#elif defined(Q_WS_MAC) 1982#elif !defined(QWS) && defined(Q_OS_MAC)
1890 QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; 1983 QString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + ".";
1891 if ( topLevelDomain.isEmpty() ) 1984 if ( !topLevelDomain.isEmpty() )
1892 topLevelDomain = "com."; 1985 qt_setSettingsBasePath( topLevelDomain );
1893 actualSearchPath = "/" + topLevelDomain + domain.left( lastDot ) + product; 1986 actualSearchPath = "/" + domain.left( lastDot ) + product;
1894 insertSearchPath( Mac, actualSearchPath ); 1987 insertSearchPath( Mac, actualSearchPath );
1895#else 1988#else
1896 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; 1989 actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product;
1897 insertSearchPath( Unix, actualSearchPath ); 1990 insertSearchPath( Unix, actualSearchPath );
1898#endif 1991#endif
1899
1900 d->globalScope = scope == Global;
1901} 1992}
1902 1993
1903/*! 1994/*!
1904 Appends \a group to the current key prefix. 1995 Appends \a group to the current key prefix.
1996
1997 \code
1998 QSettings settings;
1999 settings.beginGroup( "/MainWindow" );
2000 // read values
2001 settings.endGroup();
2002 \endcode
1905*/ 2003*/
1906void QSettings::beginGroup( const QString &group ) 2004void QSettings::beginGroup( const QString &group )
1907{ 2005{
1908 d->groupStack.push( group ); 2006 d->groupStack.push( group );
1909 d->groupDirty = TRUE; 2007 d->groupDirty = TRUE;
1910} 2008}
1911 2009
1912/*! 2010/*!
1913 Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone 2011 Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone
1914 by a single call to endGroup(). 2012 by a single call to endGroup().
2013
2014 \code
2015 QSettings settings;
2016 settings.beginGroup( "/MainWindow/Geometry" );
2017 // read values
2018 settings.endGroup();
2019 \endcode
1915*/ 2020*/
1916void QSettings::endGroup() 2021void QSettings::endGroup()
1917{ 2022{
1918 d->groupStack.pop(); 2023 d->groupStack.pop();
1919 d->groupDirty = TRUE; 2024 d->groupDirty = TRUE;
1920} 2025}
1921 2026
1922/*! 2027/*!
1923 Set the current key prefix to the empty string. 2028 Set the current key prefix to the empty string.
1924*/ 2029*/
1925void QSettings::resetGroup() 2030void QSettings::resetGroup()
1926{ 2031{
1927 d->groupStack.clear(); 2032 d->groupStack.clear();
1928 d->groupDirty = FALSE; 2033 d->groupDirty = FALSE;
1929 d->groupPrefix = QString::null; 2034 d->groupPrefix = QString::null;
1930} 2035}
1931 2036
1932/*! 2037/*!
1933 Returns the current key prefix, or a null string if there is no key prefix set. 2038 Returns the current key prefix, or a null string if there is no key prefix set.
1934 2039
1935 \sa beginGroup(); 2040 \sa beginGroup();
1936*/ 2041*/
1937QString QSettings::group() const 2042QString QSettings::group() const
1938{ 2043{
1939 if ( d->groupDirty ) { 2044 if ( d->groupDirty ) {
1940 d->groupDirty = FALSE; 2045 d->groupDirty = FALSE;
1941 d->groupPrefix = QString::null; 2046 d->groupPrefix = QString::null;
1942 2047
1943 QValueStack<QString>::Iterator it = d->groupStack.begin(); 2048 QValueStack<QString>::Iterator it = d->groupStack.begin();
1944 while ( it != d->groupStack.end() ) { 2049 while ( it != d->groupStack.end() ) {
1945 QString group = *it; 2050 QString group = *it;
1946 ++it; 2051 ++it;
1947 if ( group[0] != '/' ) 2052 if ( group[0] != '/' )
1948 group = "/" + group; 2053 group.prepend( "/" );
1949 d->groupPrefix += group; 2054 d->groupPrefix += group;
1950 } 2055 }
1951 } 2056 }
1952 return d->groupPrefix; 2057 return d->groupPrefix;
1953} 2058}
1954 2059
1955#endif 2060#endif
diff --git a/qmake/tools/qstring.cpp b/qmake/tools/qstring.cpp
index 56df62b..7f1fac3 100644
--- a/qmake/tools/qstring.cpp
+++ b/qmake/tools/qstring.cpp
@@ -1,85 +1,89 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of the QString class and related Unicode functions 4** Implementation of the QString class and related Unicode functions
5** 5**
6** Created : 920722 6** Created : 920722
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the tools module of the Qt GUI Toolkit. 10** This file is part of the tools module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38// Don't define it while compiling this module, or USERS of Qt will 38// Don't define it while compiling this module, or USERS of Qt will
39// not be able to link. 39// not be able to link.
40#ifdef QT_NO_CAST_ASCII 40#ifdef QT_NO_CAST_ASCII
41#undef QT_NO_CAST_ASCII 41#undef QT_NO_CAST_ASCII
42#endif 42#endif
43 43
44#include "qstring.h" 44#include "qstring.h"
45#include "qregexp.h" 45#include "qregexp.h"
46#include "qdatastream.h" 46#include "qdatastream.h"
47#ifndef QT_NO_TEXTCODEC 47#ifndef QT_NO_TEXTCODEC
48#include "qtextcodec.h" 48#include "qtextcodec.h"
49#endif 49#endif
50#include <ctype.h>
51#include <limits.h> 50#include <limits.h>
52#include <stdarg.h> 51#include <stdarg.h>
53#include <stdio.h> 52#include <stdio.h>
54#include <stdlib.h> 53#include <stdlib.h>
54#include <string.h>
55#if defined(Q_WS_WIN) 55#if defined(Q_WS_WIN)
56#include "qt_windows.h" 56#include "qt_windows.h"
57#endif 57#endif
58#if !defined( QT_NO_COMPONENT ) && !defined( QT_LITE_COMPONENT ) 58#if !defined( QT_NO_COMPONENT ) && !defined( QT_LITE_COMPONENT )
59#include "qcleanuphandler.h" 59#include "qcleanuphandler.h"
60#endif 60#endif
61 61
62#ifdef QT_NO_UNICODETABLES
63# include <ctype.h>
64#endif
65
62 66
63/* ------------------------------------------------------------------------- 67/* -------------------------------------------------------------------------
64 * unicode information 68 * unicode information
65 * these tables are generated from the unicode reference file 69 * these tables are generated from the unicode reference file
66 * ftp://ftp.unicode.org/Public/3.2-Update/UnicodeData.txt 70 * ftp://ftp.unicode.org/Public/3.2-Update/UnicodeData.txt
67 * 71 *
68 * Lars 72 * Lars
69 * ------------------------------------------------------------------------- 73 * -------------------------------------------------------------------------
70 */ 74 */
71 75
72/* Perl script to generate (run perl -x tools/qstring.cpp) 76/* Perl script to generate (run perl -x tools/qstring.cpp)
73 77
74#!perl 78#!perl
75 79
76sub numberize 80sub numberize
77{ 81{
78 my(%r, $n, $id); 82 my(%r, $n, $id);
79 for $id ( @_ ) { 83 for $id ( @_ ) {
80 $i = $id; 84 $i = $id;
81 $i="" if $i eq "EMPTY"; 85 $i="" if $i eq "EMPTY";
82 $r{$i}=$n++; 86 $r{$i}=$n++;
83 } 87 }
84 return %r; 88 return %r;
85} 89}
@@ -11766,60 +11770,62 @@ static inline QChar upper( const QChar &c )
11766#ifndef QT_NO_UNICODETABLES 11770#ifndef QT_NO_UNICODETABLES
11767 uchar row = c.row(); 11771 uchar row = c.row();
11768 uchar cell = c.cell(); 11772 uchar cell = c.cell();
11769 if ( unicode_info[row][cell] != QChar::Letter_Lowercase ) 11773 if ( unicode_info[row][cell] != QChar::Letter_Lowercase )
11770 return c; 11774 return c;
11771 Q_UINT16 upper = *(case_info[row]+cell); 11775 Q_UINT16 upper = *(case_info[row]+cell);
11772 if ( upper == 0 ) 11776 if ( upper == 0 )
11773 return c; 11777 return c;
11774 return upper; 11778 return upper;
11775#else 11779#else
11776 if ( c.row() ) 11780 if ( c.row() )
11777 return c; 11781 return c;
11778 else 11782 else
11779 return QChar( toupper((uchar) c.latin1()) ); 11783 return QChar( toupper((uchar) c.latin1()) );
11780#endif 11784#endif
11781} 11785}
11782 11786
11783static inline QChar::Direction direction( const QChar &c ) 11787static inline QChar::Direction direction( const QChar &c )
11784{ 11788{
11785#ifndef QT_NO_UNICODETABLES 11789#ifndef QT_NO_UNICODETABLES
11786 const Q_UINT8 *rowp = direction_info[c.row()]; 11790 const Q_UINT8 *rowp = direction_info[c.row()];
11787 if(!rowp) return QChar::DirL; 11791 if(!rowp) return QChar::DirL;
11788 return (QChar::Direction) ( *(rowp+c.cell()) & 0x1f ); 11792 return (QChar::Direction) ( *(rowp+c.cell()) & 0x1f );
11789#else 11793#else
11794 Q_UNUSED(c);
11790 return QChar::DirL; 11795 return QChar::DirL;
11791#endif 11796#endif
11792} 11797}
11793 11798
11794static inline bool mirrored( const QChar &c ) 11799static inline bool mirrored( const QChar &c )
11795{ 11800{
11796#ifndef QT_NO_UNICODETABLES 11801#ifndef QT_NO_UNICODETABLES
11797 const Q_UINT8 *rowp = direction_info[c.row()]; 11802 const Q_UINT8 *rowp = direction_info[c.row()];
11798 if ( !rowp ) 11803 if ( !rowp )
11799 return FALSE; 11804 return FALSE;
11800 return *(rowp+c.cell())>128; 11805 return *(rowp+c.cell())>128;
11801#else 11806#else
11807 Q_UNUSED(c);
11802 return FALSE; 11808 return FALSE;
11803#endif 11809#endif
11804} 11810}
11805 11811
11806#ifndef QT_NO_UNICODETABLES 11812#ifndef QT_NO_UNICODETABLES
11807static const Q_UINT16 symmetricPairs[] = { 11813static const Q_UINT16 symmetricPairs[] = {
11808 0x0028, 0x0029, 0x003C, 0x003E, 0x005B, 0x005D, 0x007B, 0x007D, 11814 0x0028, 0x0029, 0x003C, 0x003E, 0x005B, 0x005D, 0x007B, 0x007D,
11809 0x00AB, 0x00BB, 0x2039, 0x203A, 0x2045, 0x2046, 0x207D, 0x207E, 11815 0x00AB, 0x00BB, 0x2039, 0x203A, 0x2045, 0x2046, 0x207D, 0x207E,
11810 0x208D, 0x208E, 0x2208, 0x220B, 0x2209, 0x220C, 0x220A, 0x220D, 11816 0x208D, 0x208E, 0x2208, 0x220B, 0x2209, 0x220C, 0x220A, 0x220D,
11811 0x2215, 0x29F5, 0x223C, 0x223D, 0x2243, 0x22CD, 0x2252, 0x2253, 11817 0x2215, 0x29F5, 0x223C, 0x223D, 0x2243, 0x22CD, 0x2252, 0x2253,
11812 0x2254, 0x2255, 0x2264, 0x2265, 0x2266, 0x2267, 0x2268, 0x2269, 11818 0x2254, 0x2255, 0x2264, 0x2265, 0x2266, 0x2267, 0x2268, 0x2269,
11813 0x226A, 0x226B, 0x226E, 0x226F, 0x2270, 0x2271, 0x2272, 0x2273, 11819 0x226A, 0x226B, 0x226E, 0x226F, 0x2270, 0x2271, 0x2272, 0x2273,
11814 0x2274, 0x2275, 0x2276, 0x2277, 0x2278, 0x2279, 0x227A, 0x227B, 11820 0x2274, 0x2275, 0x2276, 0x2277, 0x2278, 0x2279, 0x227A, 0x227B,
11815 0x227C, 0x227D, 0x227E, 0x227F, 0x2280, 0x2281, 0x2282, 0x2283, 11821 0x227C, 0x227D, 0x227E, 0x227F, 0x2280, 0x2281, 0x2282, 0x2283,
11816 0x2284, 0x2285, 0x2286, 0x2287, 0x2288, 0x2289, 0x228A, 0x228B, 11822 0x2284, 0x2285, 0x2286, 0x2287, 0x2288, 0x2289, 0x228A, 0x228B,
11817 0x228F, 0x2290, 0x2291, 0x2292, 0x2298, 0x29B8, 0x22A2, 0x22A3, 11823 0x228F, 0x2290, 0x2291, 0x2292, 0x2298, 0x29B8, 0x22A2, 0x22A3,
11818 0x22A6, 0x2ADE, 0x22A8, 0x2AE4, 0x22A9, 0x2AE3, 0x22AB, 0x2AE5, 11824 0x22A6, 0x2ADE, 0x22A8, 0x2AE4, 0x22A9, 0x2AE3, 0x22AB, 0x2AE5,
11819 0x22B0, 0x22B1, 0x22B2, 0x22B3, 0x22B4, 0x22B5, 0x22B6, 0x22B7, 11825 0x22B0, 0x22B1, 0x22B2, 0x22B3, 0x22B4, 0x22B5, 0x22B6, 0x22B7,
11820 0x22C9, 0x22CA, 0x22CB, 0x22CC, 0x22D0, 0x22D1, 0x22D6, 0x22D7, 11826 0x22C9, 0x22CA, 0x22CB, 0x22CC, 0x22D0, 0x22D1, 0x22D6, 0x22D7,
11821 0x22D8, 0x22D9, 0x22DA, 0x22DB, 0x22DC, 0x22DD, 0x22DE, 0x22DF, 11827 0x22D8, 0x22D9, 0x22DA, 0x22DB, 0x22DC, 0x22DD, 0x22DE, 0x22DF,
11822 0x22E0, 0x22E1, 0x22E2, 0x22E3, 0x22E4, 0x22E5, 0x22E6, 0x22E7, 11828 0x22E0, 0x22E1, 0x22E2, 0x22E3, 0x22E4, 0x22E5, 0x22E6, 0x22E7,
11823 0x22E8, 0x22E9, 0x22EA, 0x22EB, 0x22EC, 0x22ED, 0x22F0, 0x22F1, 11829 0x22E8, 0x22E9, 0x22EA, 0x22EB, 0x22EC, 0x22ED, 0x22F0, 0x22F1,
11824 0x22F2, 0x22FA, 0x22F3, 0x22FB, 0x22F4, 0x22FC, 0x22F6, 0x22FD, 11830 0x22F2, 0x22FA, 0x22F3, 0x22FB, 0x22F4, 0x22FC, 0x22F6, 0x22FD,
11825 0x22F7, 0x22FE, 0x2308, 0x2309, 0x230A, 0x230B, 0x2329, 0x232A, 11831 0x22F7, 0x22FE, 0x2308, 0x2309, 0x230A, 0x230B, 0x2329, 0x232A,
@@ -11879,49 +11885,49 @@ static int ucstrcmp( const QString &as, const QString &bs )
11879 11885
11880static int ucstrncmp( const QChar *a, const QChar *b, int l ) 11886static int ucstrncmp( const QChar *a, const QChar *b, int l )
11881{ 11887{
11882 while ( l-- && *a == *b ) 11888 while ( l-- && *a == *b )
11883 a++,b++; 11889 a++,b++;
11884 if ( l==-1 ) 11890 if ( l==-1 )
11885 return 0; 11891 return 0;
11886 return a->unicode() - b->unicode(); 11892 return a->unicode() - b->unicode();
11887} 11893}
11888 11894
11889static int ucstrnicmp( const QChar *a, const QChar *b, int l ) 11895static int ucstrnicmp( const QChar *a, const QChar *b, int l )
11890{ 11896{
11891 while ( l-- && ::lower( *a ) == ::lower( *b ) ) 11897 while ( l-- && ::lower( *a ) == ::lower( *b ) )
11892 a++,b++; 11898 a++,b++;
11893 if ( l==-1 ) 11899 if ( l==-1 )
11894 return 0; 11900 return 0;
11895 return ::lower( *a ).unicode() - ::lower( *b ).unicode(); 11901 return ::lower( *a ).unicode() - ::lower( *b ).unicode();
11896} 11902}
11897 11903
11898static uint computeNewMax( uint len ) 11904static uint computeNewMax( uint len )
11899{ 11905{
11900 uint newMax = 4; 11906 uint newMax = 4;
11901 while ( newMax < len ) 11907 while ( newMax < len )
11902 newMax *= 2; 11908 newMax *= 2;
11903 // try to spare some memory 11909 // try to save some memory
11904 if ( newMax >= 1024 * 1024 && len <= newMax - (newMax >> 2) ) 11910 if ( newMax >= 1024 * 1024 && len <= newMax - (newMax >> 2) )
11905 newMax -= newMax >> 2; 11911 newMax -= newMax >> 2;
11906 return newMax; 11912 return newMax;
11907} 11913}
11908 11914
11909/*! 11915/*!
11910 \class QCharRef qstring.h 11916 \class QCharRef qstring.h
11911 \reentrant 11917 \reentrant
11912 \brief The QCharRef class is a helper class for QString. 11918 \brief The QCharRef class is a helper class for QString.
11913 11919
11914 \ingroup text 11920 \ingroup text
11915 11921
11916 When you get an object of type QCharRef, if you can assign to it, 11922 When you get an object of type QCharRef, if you can assign to it,
11917 the assignment will apply to the character in the string from 11923 the assignment will apply to the character in the string from
11918 which you got the reference. That is its whole purpose in life. 11924 which you got the reference. That is its whole purpose in life.
11919 The QCharRef becomes invalid once modifications are made to the 11925 The QCharRef becomes invalid once modifications are made to the
11920 string: if you want to keep the character, copy it into a QChar. 11926 string: if you want to keep the character, copy it into a QChar.
11921 11927
11922 Most of the QChar member functions also exist in QCharRef. 11928 Most of the QChar member functions also exist in QCharRef.
11923 However, they are not explicitly documented here. 11929 However, they are not explicitly documented here.
11924 11930
11925 \sa QString::operator[]() QString::at() QChar 11931 \sa QString::operator[]() QString::at() QChar
11926*/ 11932*/
11927 11933
@@ -12870,152 +12876,152 @@ void QString::compose()
12870 cindex++; 12876 cindex++;
12871 index++; 12877 index++;
12872 } 12878 }
12873 *this = composed; 12879 *this = composed;
12874#endif 12880#endif
12875} 12881}
12876 12882
12877 12883
12878// These macros are used for efficient allocation of QChar strings. 12884// These macros are used for efficient allocation of QChar strings.
12879// IMPORTANT! If you change these, make sure you also change the 12885// IMPORTANT! If you change these, make sure you also change the
12880// "delete unicode" statement in ~QStringData() in qstring.h correspondingly! 12886// "delete unicode" statement in ~QStringData() in qstring.h correspondingly!
12881 12887
12882#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ] 12888#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ]
12883#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P )) 12889#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P ))
12884 12890
12885 12891
12886/*! 12892/*!
12887 This utility function converts the 8-bit string \a ba to Unicode, 12893 This utility function converts the 8-bit string \a ba to Unicode,
12888 returning the result. 12894 returning the result.
12889 12895
12890 The caller is responsible for deleting the return value with 12896 The caller is responsible for deleting the return value with
12891 delete[]. 12897 delete[].
12892*/ 12898*/
12893 12899
12894QChar* QString::asciiToUnicode( const QByteArray& ba, uint* len ) 12900QChar* QString::latin1ToUnicode( const QByteArray& ba, uint* len )
12895{ 12901{
12896 if ( ba.isNull() ) { 12902 if ( ba.isNull() ) {
12897 *len = 0; 12903 *len = 0;
12898 return 0; 12904 return 0;
12899 } 12905 }
12900 int l = 0; 12906 int l = 0;
12901 while ( l < (int)ba.size() && ba[l] ) 12907 while ( l < (int)ba.size() && ba[l] )
12902 l++; 12908 l++;
12903 char* str = ba.data(); 12909 char* str = ba.data();
12904 QChar *uc = new QChar[ l ]; // Can't use macro, since function is public 12910 QChar *uc = new QChar[ l ]; // Can't use macro, since function is public
12905 QChar *result = uc; 12911 QChar *result = uc;
12906 if ( len ) 12912 if ( len )
12907 *len = l; 12913 *len = l;
12908 while (l--) 12914 while (l--)
12909 *uc++ = *str++; 12915 *uc++ = *str++;
12910 return result; 12916 return result;
12911} 12917}
12912 12918
12913static QChar* internalAsciiToUnicode( const QByteArray& ba, uint* len ) 12919static QChar* internalLatin1ToUnicode( const QByteArray& ba, uint* len )
12914{ 12920{
12915 if ( ba.isNull() ) { 12921 if ( ba.isNull() ) {
12916 *len = 0; 12922 *len = 0;
12917 return 0; 12923 return 0;
12918 } 12924 }
12919 int l = 0; 12925 int l = 0;
12920 while ( l < (int)ba.size() && ba[l] ) 12926 while ( l < (int)ba.size() && ba[l] )
12921 l++; 12927 l++;
12922 char* str = ba.data(); 12928 char* str = ba.data();
12923 QChar *uc = QT_ALLOC_QCHAR_VEC( l ); 12929 QChar *uc = QT_ALLOC_QCHAR_VEC( l );
12924 QChar *result = uc; 12930 QChar *result = uc;
12925 if ( len ) 12931 if ( len )
12926 *len = l; 12932 *len = l;
12927 while (l--) 12933 while (l--)
12928 *uc++ = *str++; 12934 *uc++ = *str++;
12929 return result; 12935 return result;
12930} 12936}
12931 12937
12932/*! 12938/*!
12933 \overload 12939 \overload
12934 12940
12935 This utility function converts the '\0'-terminated 8-bit string \a 12941 This utility function converts the '\0'-terminated 8-bit string \a
12936 str to Unicode, returning the result and setting \a *len to the 12942 str to Unicode, returning the result and setting \a *len to the
12937 length of the Unicode string. 12943 length of the Unicode string.
12938 12944
12939 The caller is responsible for deleting the return value with 12945 The caller is responsible for deleting the return value with
12940 delete[]. 12946 delete[].
12941*/ 12947*/
12942 12948
12943QChar* QString::asciiToUnicode( const char *str, uint* len, uint maxlen ) 12949QChar* QString::latin1ToUnicode( const char *str, uint* len, uint maxlen )
12944{ 12950{
12945 QChar* result = 0; 12951 QChar* result = 0;
12946 uint l = 0; 12952 uint l = 0;
12947 if ( str ) { 12953 if ( str ) {
12948 if ( maxlen != (uint)-1 ) { 12954 if ( maxlen != (uint)-1 ) {
12949 while ( l < maxlen && str[l] ) 12955 while ( l < maxlen && str[l] )
12950 l++; 12956 l++;
12951 } else { 12957 } else {
12952 // Faster? 12958 // Faster?
12953 l = qstrlen(str); 12959 l = strlen( str );
12954 } 12960 }
12955 QChar *uc = new QChar[ l ]; // Can't use macro since function is public 12961 QChar *uc = new QChar[ l ]; // Can't use macro since function is public
12956 result = uc; 12962 result = uc;
12957 uint i = l; 12963 uint i = l;
12958 while ( i-- ) 12964 while ( i-- )
12959 *uc++ = *str++; 12965 *uc++ = *str++;
12960 } 12966 }
12961 if ( len ) 12967 if ( len )
12962 *len = l; 12968 *len = l;
12963 return result; 12969 return result;
12964} 12970}
12965 12971
12966static QChar* internalAsciiToUnicode( const char *str, uint* len, 12972static QChar* internalLatin1ToUnicode( const char *str, uint* len,
12967 uint maxlen = (uint)-1 ) 12973 uint maxlen = (uint)-1 )
12968{ 12974{
12969 QChar* result = 0; 12975 QChar* result = 0;
12970 uint l = 0; 12976 uint l = 0;
12971 if ( str ) { 12977 if ( str ) {
12972 if ( maxlen != (uint)-1 ) { 12978 if ( maxlen != (uint)-1 ) {
12973 while ( l < maxlen && str[l] ) 12979 while ( l < maxlen && str[l] )
12974 l++; 12980 l++;
12975 } else { 12981 } else {
12976 // Faster? 12982 // Faster?
12977 l = qstrlen(str); 12983 l = strlen( str );
12978 } 12984 }
12979 QChar *uc = QT_ALLOC_QCHAR_VEC( l ); 12985 QChar *uc = QT_ALLOC_QCHAR_VEC( l );
12980 result = uc; 12986 result = uc;
12981 uint i = l; 12987 uint i = l;
12982 while ( i-- ) 12988 while ( i-- )
12983 *uc++ = *str++; 12989 *uc++ = *str++;
12984 } 12990 }
12985 if ( len ) 12991 if ( len )
12986 *len = l; 12992 *len = l;
12987 return result; 12993 return result;
12988} 12994}
12989 12995
12990/*! 12996/*!
12991 This utility function converts \a l 16-bit characters from \a uc 12997 This utility function converts \a l 16-bit characters from \a uc
12992 to ASCII, returning a '\0'-terminated string. 12998 to ASCII, returning a '\0'-terminated string.
12993 12999
12994 The caller is responsible for deleting the resultant string with 13000 The caller is responsible for deleting the resultant string with
12995 delete[]. 13001 delete[].
12996*/ 13002*/
12997char* QString::unicodeToAscii(const QChar *uc, uint l) 13003char* QString::unicodeToLatin1(const QChar *uc, uint l)
12998{ 13004{
12999 if (!uc) { 13005 if (!uc) {
13000 return 0; 13006 return 0;
13001 } 13007 }
13002 char *a = new char[l+1]; 13008 char *a = new char[l+1];
13003 char *result = a; 13009 char *result = a;
13004 while (l--) { 13010 while (l--) {
13005 *a++ = (uc->unicode() > 0xff) ? '?' : (char)uc->unicode(); 13011 *a++ = (uc->unicode() > 0xff) ? '?' : (char)uc->unicode();
13006 uc++; 13012 uc++;
13007 } 13013 }
13008 *a = '\0'; 13014 *a = '\0';
13009 return result; 13015 return result;
13010} 13016}
13011 13017
13012/***************************************************************************** 13018/*****************************************************************************
13013 QString member functions 13019 QString member functions
13014 *****************************************************************************/ 13020 *****************************************************************************/
13015 13021
13016/*! 13022/*!
13017 \class QString qstring.h 13023 \class QString qstring.h
13018 \reentrant 13024 \reentrant
13019 13025
13020 \brief The QString class provides an abstraction of Unicode text 13026 \brief The QString class provides an abstraction of Unicode text
13021 and the classic C '\0'-terminated char array. 13027 and the classic C '\0'-terminated char array.
@@ -13136,143 +13142,116 @@ char* QString::unicodeToAscii(const QChar *uc, uint l)
13136 13142
13137 Matching is case-insensitive unless \c CaseSensitive is set. \c 13143 Matching is case-insensitive unless \c CaseSensitive is set. \c
13138 CaseSensitive may be OR-ed with any combination of the other 13144 CaseSensitive may be OR-ed with any combination of the other
13139 flags. 13145 flags.
13140 13146
13141*/ 13147*/
13142Q_EXPORT QStringData *QString::shared_null = 0; 13148Q_EXPORT QStringData *QString::shared_null = 0;
13143QT_STATIC_CONST_IMPL QString QString::null; 13149QT_STATIC_CONST_IMPL QString QString::null;
13144QT_STATIC_CONST_IMPL QChar QChar::null; 13150QT_STATIC_CONST_IMPL QChar QChar::null;
13145QT_STATIC_CONST_IMPL QChar QChar::replacement((ushort)0xfffd); 13151QT_STATIC_CONST_IMPL QChar QChar::replacement((ushort)0xfffd);
13146QT_STATIC_CONST_IMPL QChar QChar::byteOrderMark((ushort)0xfeff); 13152QT_STATIC_CONST_IMPL QChar QChar::byteOrderMark((ushort)0xfeff);
13147QT_STATIC_CONST_IMPL QChar QChar::byteOrderSwapped((ushort)0xfffe); 13153QT_STATIC_CONST_IMPL QChar QChar::byteOrderSwapped((ushort)0xfffe);
13148QT_STATIC_CONST_IMPL QChar QChar::nbsp((ushort)0x00a0); 13154QT_STATIC_CONST_IMPL QChar QChar::nbsp((ushort)0x00a0);
13149 13155
13150QStringData* QString::makeSharedNull() 13156QStringData* QString::makeSharedNull()
13151{ 13157{
13152 QString::shared_null = new QStringData; 13158 QString::shared_null = new QStringData;
13153#if defined( Q_OS_MAC ) 13159#if defined( Q_OS_MAC )
13154 QString *that = const_cast<QString *>(&QString::null); 13160 QString *that = const_cast<QString *>(&QString::null);
13155 that->d = QString::shared_null; 13161 that->d = QString::shared_null;
13156#endif 13162#endif
13157 return QString::shared_null; 13163 return QString::shared_null;
13158} 13164}
13159 13165
13160// Uncomment this to get some useful statistics.
13161// #define Q2HELPER(x) x
13162
13163#ifdef Q2HELPER
13164static int stat_construct_charstar=0;
13165static int stat_construct_charstar_size=0;
13166static int stat_construct_null=0;
13167static int stat_construct_int=0;
13168static int stat_construct_int_size=0;
13169static int stat_construct_ba=0;
13170static int stat_get_ascii=0;
13171static int stat_get_ascii_size=0;
13172static int stat_copy_on_write=0;
13173static int stat_copy_on_write_size=0;
13174static int stat_fast_copy=0;
13175Q_EXPORT void qt_qstring_stats()
13176{
13177 qDebug("construct_charstar = %d (%d chars)", stat_construct_charstar, stat_construct_charstar_size);
13178 qDebug("construct_null = %d", stat_construct_null);
13179 qDebug("construct_int = %d (%d chars)", stat_construct_int, stat_construct_int_size);
13180 qDebug("construct_ba = %d", stat_construct_ba);
13181 qDebug("get_ascii = %d (%d chars)", stat_get_ascii, stat_get_ascii_size);
13182 qDebug("copy_on_write = %d (%d chars)", stat_copy_on_write, stat_copy_on_write_size);
13183 qDebug("fast_copy = %d", stat_fast_copy);
13184}
13185#else
13186#define Q2HELPER(x)
13187#endif
13188
13189/*! 13166/*!
13190 \fn QString::QString() 13167 \fn QString::QString()
13191 13168
13192 Constructs a null string, i.e. both the length and data pointer 13169 Constructs a null string, i.e. both the length and data pointer
13193 are 0. 13170 are 0.
13194 13171
13195 \sa isNull() 13172 \sa isNull()
13196*/ 13173*/
13197 13174
13198/*! 13175/*!
13199 Constructs a string of length one, containing the character \a ch. 13176 Constructs a string of length one, containing the character \a ch.
13200*/ 13177*/
13201QString::QString( QChar ch ) 13178QString::QString( QChar ch )
13202{ 13179{
13203 d = new QStringData( QT_ALLOC_QCHAR_VEC( 1 ), 1, 1 ); 13180 d = new QStringData( QT_ALLOC_QCHAR_VEC( 1 ), 1, 1 );
13204 d->unicode[0] = ch; 13181 d->unicode[0] = ch;
13205} 13182}
13206 13183
13207/*! 13184/*!
13208 Constructs an implicitly shared copy of \a s. This is very fast 13185 Constructs an implicitly shared copy of \a s. This is very fast
13209 since it only involves incrementing a reference count. 13186 since it only involves incrementing a reference count.
13210*/ 13187*/
13211QString::QString( const QString &s ) : 13188QString::QString( const QString &s ) :
13212 d(s.d) 13189 d(s.d)
13213{ 13190{
13214 Q2HELPER(stat_fast_copy++)
13215 d->ref(); 13191 d->ref();
13216} 13192}
13217 13193
13218/*! 13194/*!
13219 \internal 13195 \internal
13220 13196
13221 Private function. 13197 Private function.
13222 13198
13223 Constructs a string with preallocated space for \a size characters. 13199 Constructs a string with preallocated space for \a size characters.
13224 13200
13225 The string is empty. 13201 The string is empty.
13226 13202
13227 \sa isNull() 13203 \sa isNull()
13228*/ 13204*/
13229 13205
13230QString::QString( int size, bool /*dummy*/ ) 13206QString::QString( int size, bool /*dummy*/ )
13231{ 13207{
13232 if ( size ) { 13208 if ( size ) {
13233 Q2HELPER(stat_construct_int++)
13234 int l = size; 13209 int l = size;
13235 Q2HELPER(stat_construct_int_size+=l)
13236 QChar* uc = QT_ALLOC_QCHAR_VEC( l ); 13210 QChar* uc = QT_ALLOC_QCHAR_VEC( l );
13237 d = new QStringData( uc, 0, l ); 13211 d = new QStringData( uc, 0, l );
13238 } else { 13212 } else {
13239 Q2HELPER(stat_construct_null++)
13240 d = shared_null ? shared_null : (shared_null=new QStringData); 13213 d = shared_null ? shared_null : (shared_null=new QStringData);
13241 d->ref(); 13214 d->ref();
13242 } 13215 }
13243} 13216}
13244 13217
13245/*! 13218/*!
13246 Constructs a string that is a deep copy of \a ba interpreted as a 13219 Constructs a string that is a deep copy of \a ba interpreted as a
13247 classic C string. 13220 classic C string.
13248*/ 13221*/
13249 13222
13250QString::QString( const QByteArray& ba ) 13223QString::QString( const QByteArray& ba )
13251{ 13224{
13252 Q2HELPER(stat_construct_ba++) 13225#ifndef QT_NO_TEXTCODEC
13226 if ( QTextCodec::codecForCStrings() ) {
13227 d = 0;
13228 *this = fromAscii( ba.data(), ba.size() );
13229 return;
13230 }
13231#endif
13253 uint l; 13232 uint l;
13254 QChar *uc = internalAsciiToUnicode(ba,&l); 13233 QChar *uc = internalLatin1ToUnicode(ba,&l);
13255 d = new QStringData(uc,l,l); 13234 d = new QStringData(uc,l,l);
13256} 13235}
13257 13236
13258/*! 13237/*!
13259 Constructs a string that is a deep copy of the first \a length 13238 Constructs a string that is a deep copy of the first \a length
13260 characters in the QChar array. 13239 characters in the QChar array.
13261 13240
13262 If \a unicode and \a length are 0, then a null string is created. 13241 If \a unicode and \a length are 0, then a null string is created.
13263 13242
13264 If only \a unicode is 0, the string is empty but has \a length 13243 If only \a unicode is 0, the string is empty but has \a length
13265 characters of space preallocated: QString expands automatically 13244 characters of space preallocated: QString expands automatically
13266 anyway, but this may speed up some cases a little. We recommend 13245 anyway, but this may speed up some cases a little. We recommend
13267 using the plain constructor and setLength() for this purpose since 13246 using the plain constructor and setLength() for this purpose since
13268 it will result in more readable code. 13247 it will result in more readable code.
13269 13248
13270 \sa isNull() setLength() 13249 \sa isNull() setLength()
13271*/ 13250*/
13272 13251
13273QString::QString( const QChar* unicode, uint length ) 13252QString::QString( const QChar* unicode, uint length )
13274{ 13253{
13275 if ( !unicode && !length ) { 13254 if ( !unicode && !length ) {
13276 d = shared_null ? shared_null : makeSharedNull(); 13255 d = shared_null ? shared_null : makeSharedNull();
13277 d->ref(); 13256 d->ref();
13278 } else { 13257 } else {
@@ -13281,146 +13260,181 @@ QString::QString( const QChar* unicode, uint length )
13281 memcpy(uc, unicode, length*sizeof(QChar)); 13260 memcpy(uc, unicode, length*sizeof(QChar));
13282 d = new QStringData(uc,unicode ? length : 0,length); 13261 d = new QStringData(uc,unicode ? length : 0,length);
13283 } 13262 }
13284} 13263}
13285 13264
13286/*! 13265/*!
13287 Constructs a string that is a deep copy of \a str, interpreted as 13266 Constructs a string that is a deep copy of \a str, interpreted as
13288 a classic C string. 13267 a classic C string.
13289 13268
13290 If \a str is 0, then a null string is created. 13269 If \a str is 0, then a null string is created.
13291 13270
13292 This is a cast constructor, but it is perfectly safe: converting a 13271 This is a cast constructor, but it is perfectly safe: converting a
13293 Latin1 const char* to QString preserves all the information. You 13272 Latin1 const char* to QString preserves all the information. You
13294 can disable this constructor by defining \c QT_NO_CAST_ASCII when 13273 can disable this constructor by defining \c QT_NO_CAST_ASCII when
13295 you compile your applications. You can also make QString objects 13274 you compile your applications. You can also make QString objects
13296 by using setLatin1(), fromLatin1(), fromLocal8Bit(), and 13275 by using setLatin1(), fromLatin1(), fromLocal8Bit(), and
13297 fromUtf8(). Or whatever encoding is appropriate for the 8-bit data 13276 fromUtf8(). Or whatever encoding is appropriate for the 8-bit data
13298 you have. 13277 you have.
13299 13278
13300 \sa isNull() 13279 \sa isNull()
13301*/ 13280*/
13302 13281
13303QString::QString( const char *str ) 13282QString::QString( const char *str )
13304{ 13283{
13305 Q2HELPER(stat_construct_charstar++) 13284#ifndef QT_NO_TEXTCODEC
13285 if ( QTextCodec::codecForCStrings() ) {
13286 d = 0;
13287 *this = fromAscii( str );
13288 return;
13289 }
13290#endif
13291 uint l;
13292 QChar *uc = internalLatin1ToUnicode(str,&l);
13293 d = new QStringData(uc,l,l);
13294}
13295
13296#ifndef QT_NO_STL
13297/*!
13298 Constructs a string that is a deep copy of \a str.
13299
13300 This is the same as fromAscii(\a str).
13301*/
13302
13303QString::QString( const std::string &str )
13304{
13305#ifndef QT_NO_TEXTCODEC
13306 if ( QTextCodec::codecForCStrings() ) {
13307 d = 0;
13308 *this = fromAscii( str.c_str() );
13309 return;
13310 }
13311#endif
13306 uint l; 13312 uint l;
13307 QChar *uc = internalAsciiToUnicode(str,&l); 13313 QChar *uc = internalLatin1ToUnicode(str.c_str(),&l);
13308 Q2HELPER(stat_construct_charstar_size+=l)
13309 d = new QStringData(uc,l,l); 13314 d = new QStringData(uc,l,l);
13310} 13315}
13316#endif
13311 13317
13312/*! 13318/*!
13313 \fn QString::~QString() 13319 \fn QString::~QString()
13314 13320
13315 Destroys the string and frees the string's data if this is the 13321 Destroys the string and frees the string's data if this is the
13316 last reference to the string. 13322 last reference to the string.
13317*/ 13323*/
13318 13324
13319 13325
13320/*! 13326/*!
13321 Deallocates any space reserved solely by this QString. 13327 Deallocates any space reserved solely by this QString.
13322 13328
13323 If the string does not share its data with another QString 13329 If the string does not share its data with another QString
13324 instance, nothing happens; otherwise the function creates a new, 13330 instance, nothing happens; otherwise the function creates a new,
13325 unique copy of this string. This function is called whenever the 13331 unique copy of this string. This function is called whenever the
13326 string is modified. 13332 string is modified.
13327*/ 13333*/
13328 13334
13329void QString::real_detach() 13335void QString::real_detach()
13330{ 13336{
13331 setLength( length() ); 13337 setLength( length() );
13332} 13338}
13333 13339
13334void QString::deref() 13340void QString::deref()
13335{ 13341{
13336 if ( d->deref() ) { 13342 if ( d && d->deref() ) {
13337 if ( d != shared_null ) 13343 if ( d != shared_null )
13338 delete d; 13344 delete d;
13339 d = 0; // helps debugging 13345 d = 0;
13340 } 13346 }
13341} 13347}
13342 13348
13343void QStringData::deleteSelf() 13349void QStringData::deleteSelf()
13344{ 13350{
13345 delete this; 13351 delete this;
13346} 13352}
13347 13353
13348/*! 13354/*!
13349 \fn QString& QString::operator=( QChar c ) 13355 \fn QString& QString::operator=( QChar c )
13350 13356
13351 Sets the string to contain just the single character \a c. 13357 Sets the string to contain just the single character \a c.
13352*/ 13358*/
13353 13359
13354/*! 13360/*!
13361 \fn QString& QString::operator=( const std::string& s )
13362
13363 \overload
13364
13365 Makes a deep copy of \a s and returns a reference to the deep
13366 copy.
13367*/
13368
13369/*!
13355 \fn QString& QString::operator=( char c ) 13370 \fn QString& QString::operator=( char c )
13356 13371
13357 \overload 13372 \overload
13358 13373
13359 Sets the string to contain just the single character \a c. 13374 Sets the string to contain just the single character \a c.
13360*/ 13375*/
13361 13376
13362/*! 13377/*!
13363 \overload 13378 \overload
13364 13379
13365 Assigns a shallow copy of \a s to this string and returns a 13380 Assigns a shallow copy of \a s to this string and returns a
13366 reference to this string. This is very fast because the string 13381 reference to this string. This is very fast because the string
13367 isn't actually copied. 13382 isn't actually copied.
13368*/ 13383*/
13369QString &QString::operator=( const QString &s ) 13384QString &QString::operator=( const QString &s )
13370{ 13385{
13371 Q2HELPER(stat_fast_copy++)
13372 s.d->ref(); 13386 s.d->ref();
13373 deref(); 13387 deref();
13374 d = s.d; 13388 d = s.d;
13375 return *this; 13389 return *this;
13376} 13390}
13377 13391
13378/*! 13392/*!
13379 \overload 13393 \overload
13380 13394
13381 Assigns a deep copy of \a cs, interpreted as a classic C string, 13395 Assigns a deep copy of \a cs, interpreted as a classic C string,
13382 to this string and returns a reference to this string. 13396 to this string and returns a reference to this string.
13383*/ 13397*/
13384QString &QString::operator=( const QCString& cs ) 13398QString &QString::operator=( const QCString& cs )
13385{ 13399{
13386 return setLatin1(cs); 13400 return setAscii(cs);
13387} 13401}
13388 13402
13389 13403
13390/*! 13404/*!
13391 \overload 13405 \overload
13392 13406
13393 Assigns a deep copy of \a str, interpreted as a classic C string 13407 Assigns a deep copy of \a str, interpreted as a classic C string
13394 to this string and returns a reference to this string. 13408 to this string and returns a reference to this string.
13395 13409
13396 If \a str is 0, then a null string is created. 13410 If \a str is 0, then a null string is created.
13397 13411
13398 \sa isNull() 13412 \sa isNull()
13399*/ 13413*/
13400QString &QString::operator=( const char *str ) 13414QString &QString::operator=( const char *str )
13401{ 13415{
13402 return setLatin1(str); 13416 return setAscii(str);
13403} 13417}
13404 13418
13405 13419
13406/*! 13420/*!
13407 \fn bool QString::isNull() const 13421 \fn bool QString::isNull() const
13408 13422
13409 Returns TRUE if the string is null; otherwise returns FALSE. A 13423 Returns TRUE if the string is null; otherwise returns FALSE. A
13410 null string is always empty. 13424 null string is always empty.
13411 13425
13412 \code 13426 \code
13413 QString a; // a.unicode() == 0, a.length() == 0 13427 QString a; // a.unicode() == 0, a.length() == 0
13414 a.isNull(); // TRUE, because a.unicode() == 0 13428 a.isNull(); // TRUE, because a.unicode() == 0
13415 a.isEmpty(); // TRUE 13429 a.isEmpty(); // TRUE
13416 \endcode 13430 \endcode
13417 13431
13418 \sa isEmpty(), length() 13432 \sa isEmpty(), length()
13419*/ 13433*/
13420 13434
13421/*! 13435/*!
13422 \fn bool QString::isEmpty() const 13436 \fn bool QString::isEmpty() const
13423 13437
13424 Returns TRUE if the string is empty, i.e. if length() == 0; 13438 Returns TRUE if the string is empty, i.e. if length() == 0;
13425 otherwise returns FALSE. Null strings are also empty. 13439 otherwise returns FALSE. Null strings are also empty.
13426 13440
@@ -13450,122 +13464,118 @@ QString &QString::operator=( const char *str )
13450/*! 13464/*!
13451 If \a newLen is less than the length of the string, then the 13465 If \a newLen is less than the length of the string, then the
13452 string is truncated at position \a newLen. Otherwise nothing 13466 string is truncated at position \a newLen. Otherwise nothing
13453 happens. 13467 happens.
13454 13468
13455 \code 13469 \code
13456 QString s = "truncate me"; 13470 QString s = "truncate me";
13457 s.truncate( 5 ); // s == "trunc" 13471 s.truncate( 5 ); // s == "trunc"
13458 \endcode 13472 \endcode
13459 13473
13460 \sa setLength() 13474 \sa setLength()
13461*/ 13475*/
13462 13476
13463void QString::truncate( uint newLen ) 13477void QString::truncate( uint newLen )
13464{ 13478{
13465 if ( newLen < d->len ) 13479 if ( newLen < d->len )
13466 setLength( newLen ); 13480 setLength( newLen );
13467} 13481}
13468 13482
13469/*! 13483/*!
13470 Ensures that at least \a newLen characters are allocated to the 13484 Ensures that at least \a newLen characters are allocated to the
13471 string, and sets the length of the string to \a newLen. Any new 13485 string, and sets the length of the string to \a newLen. Any new
13472 space allocated contains arbitrary data. 13486 space allocated contains arbitrary data.
13473 13487
13474 If \a newLen is 0, then the string becomes empty, unless the 13488 If \a newLen is 0, then the string becomes empty (non-null).
13475 string is null, in which case it remains null.
13476 13489
13477 If it is not possible to allocate enough memory, the string 13490 If it is not possible to allocate enough memory, the string
13478 remains unchanged. 13491 remains unchanged.
13479 13492
13480 This function always detaches the string from other references to 13493 This function always detaches the string from other references to
13481 the same data. 13494 the same data.
13482 13495
13483 This function is useful for code that needs to build up a long 13496 This function is useful for code that needs to build up a long
13484 string and wants to avoid repeated reallocation. In this example, 13497 string and wants to avoid repeated reallocation. In this example,
13485 we want to add to the string until some condition is true, and 13498 we want to add to the string until some condition is true, and
13486 we're fairly sure that size is big enough: 13499 we're fairly sure that size is big enough:
13487 \code 13500 \code
13488 QString result; 13501 QString result;
13489 int resultLength = 0; 13502 int len = 0;
13490 result.setLength( newLen ) // allocate some space 13503 result.setLength( maxLen ); // allocate some space
13491 while ( ... ) { 13504 while ( ... ) {
13492 result[resultLength++] = ... // fill (part of) the space with data 13505 result[len++] = ... // fill part of the space
13493 } 13506 }
13494 result.truncate[resultLength]; // and get rid of the undefined junk 13507 result.truncate( len ); // and get rid of the rest
13495 \endcode 13508 \endcode
13496 13509
13497 If \a newLen is an underestimate, the worst that will happen is 13510 If \a newLen is an underestimate, the worst that will happen is
13498 that the loop will slow down. 13511 that the loop will slow down.
13499 13512
13500 \sa truncate(), isNull(), isEmpty(), length() 13513 \sa truncate(), isNull(), isEmpty(), length()
13501*/ 13514*/
13502 13515
13503void QString::setLength( uint newLen ) 13516void QString::setLength( uint newLen )
13504{ 13517{
13505 if ( d->count != 1 || newLen > d->maxl || 13518 if ( d->count != 1 || newLen > d->maxl ||
13506 ( newLen * 4 < d->maxl && d->maxl > 4 ) ) { 13519 ( newLen * 4 < d->maxl && d->maxl > 4 ) ) {
13507 // detach, grow or shrink 13520 // detach, grow or shrink
13508 Q2HELPER(stat_copy_on_write++)
13509 Q2HELPER(stat_copy_on_write_size+=d->len)
13510 uint newMax = computeNewMax( newLen ); 13521 uint newMax = computeNewMax( newLen );
13511 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); 13522 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax );
13512 if ( nd ) { 13523 if ( nd ) {
13513 uint len = QMIN( d->len, newLen ); 13524 uint len = QMIN( d->len, newLen );
13514 if ( d->unicode ) 13525 if ( d->unicode )
13515 memcpy( nd, d->unicode, sizeof(QChar)*len ); 13526 memcpy( nd, d->unicode, sizeof(QChar)*len );
13516 deref(); 13527 deref();
13517 d = new QStringData( nd, newLen, newMax ); 13528 d = new QStringData( nd, newLen, newMax );
13518 } 13529 }
13519 } else { 13530 } else {
13520 d->len = newLen; 13531 d->len = newLen;
13521 d->setDirty(); 13532 d->setDirty();
13522 } 13533 }
13523} 13534}
13524 13535
13525/*! 13536/*!
13526 This function will return a string that replaces the lowest 13537 This function will return a string that replaces the lowest
13527 numbered occurrence of \c %1, \c %2, ..., \c %9 with \a a. 13538 numbered occurrence of \c %1, \c %2, ..., \c %9 with \a a.
13528 13539
13529 The \a fieldwidth value specifies the minimum amount of space that 13540 The \a fieldwidth value specifies the minimum amount of space that
13530 \a a is padded to. A positive value will produce right-aligned 13541 \a a is padded to. A positive value will produce right-aligned
13531 text, whereas a negative value will produce left-aligned text. 13542 text, whereas a negative value will produce left-aligned text.
13532 13543
13544 The following example shows how we could create a 'status' string
13545 when processing a list of files:
13533 \code 13546 \code
13534 QString firstName( "Joe" ); 13547 QString status = QString( "Processing file %1 of %2: %3" )
13535 QString lastName( "Bloggs" ); 13548 .arg( i ) // current file's number
13536 QString fullName; 13549 .arg( total ) // number of files to process
13537 fullName = QString( "First name is '%1', last name is '%2'" ) 13550 .arg( fileName ); // current file's name
13538 .arg( firstName )
13539 .arg( lastName );
13540
13541 // fullName == First name is 'Joe', last name is 'Bloggs'
13542 \endcode 13551 \endcode
13543 13552
13544 Note that using arg() to construct sentences as we've done in the 13553 It is generally fine to use filenames and numbers as we have done
13545 example above does not usually translate well into other languages 13554 in the example above. But note that using arg() to construct
13546 because sentence structure and word order often differ between 13555 natural language sentences does not usually translate well into
13547 languages. 13556 other languages because sentence structure and word order often
13557 differ between languages.
13548 13558
13549 If there is no place marker (\c %1 or \c %2, etc.), a warning 13559 If there is no place marker (\c %1 or \c %2, etc.), a warning
13550 message (qWarning()) is output and the text is appended at the 13560 message (qWarning()) is output and the text is appended at the
13551 end of the string. We recommend that the correct number of place 13561 end of the string. We recommend that the correct number of place
13552 markers is always used in production code. 13562 markers is always used in production code.
13553*/ 13563*/
13554QString QString::arg( const QString& a, int fieldwidth ) const 13564QString QString::arg( const QString& a, int fieldwidth ) const
13555{ 13565{
13556 int pos, len; 13566 int pos, len;
13557 QString r = *this; 13567 QString r = *this;
13558 13568
13559 if ( !findArg( pos, len ) ) { 13569 if ( !findArg( pos, len ) ) {
13560 qWarning( "QString::arg(): Argument missing: %s, %s", 13570 qWarning( "QString::arg(): Argument missing: %s, %s",
13561 latin1(), a.latin1() ); 13571 latin1(), a.latin1() );
13562 // Make sure the text at least appears SOMEWHERE 13572 // Make sure the text at least appears SOMEWHERE
13563 r += ' '; 13573 r += ' ';
13564 pos = r.length(); 13574 pos = r.length();
13565 len = 0; 13575 len = 0;
13566 } 13576 }
13567 13577
13568 r.replace( pos, len, a ); 13578 r.replace( pos, len, a );
13569 if ( fieldwidth < 0 ) { 13579 if ( fieldwidth < 0 ) {
13570 QString s; 13580 QString s;
13571 while ( (uint)-fieldwidth > a.length() ) { 13581 while ( (uint)-fieldwidth > a.length() ) {
@@ -13753,49 +13763,49 @@ bool QString::findArg( int& pos, int& len ) const
13753 int x = ...; 13763 int x = ...;
13754 QTextOStream( &str ) << s << " : " << x; 13764 QTextOStream( &str ) << s << " : " << x;
13755 \endcode 13765 \endcode
13756 13766
13757 For \link QObject::tr() translations,\endlink especially if the 13767 For \link QObject::tr() translations,\endlink especially if the
13758 strings contains more than one escape sequence, you should 13768 strings contains more than one escape sequence, you should
13759 consider using the arg() function instead. This allows the order 13769 consider using the arg() function instead. This allows the order
13760 of the replacements to be controlled by the translator, and has 13770 of the replacements to be controlled by the translator, and has
13761 Unicode support. 13771 Unicode support.
13762 13772
13763 \sa arg() 13773 \sa arg()
13764*/ 13774*/
13765 13775
13766#ifndef QT_NO_SPRINTF 13776#ifndef QT_NO_SPRINTF
13767QString &QString::sprintf( const char* cformat, ... ) 13777QString &QString::sprintf( const char* cformat, ... )
13768{ 13778{
13769 va_list ap; 13779 va_list ap;
13770 va_start( ap, cformat ); 13780 va_start( ap, cformat );
13771 13781
13772 if ( !cformat || !*cformat ) { 13782 if ( !cformat || !*cformat ) {
13773 // Qt 1.x compat 13783 // Qt 1.x compat
13774 *this = fromLatin1( "" ); 13784 *this = fromLatin1( "" );
13775 return *this; 13785 return *this;
13776 } 13786 }
13777 QString format = fromLatin1( cformat ); 13787 QString format = fromAscii( cformat );
13778 13788
13779 QRegExp escape( "%#?0?-? ?\\+?'?[0-9*]*\\.?[0-9*]*h?l?L?q?Z?" ); 13789 QRegExp escape( "%#?0?-? ?\\+?'?[0-9*]*\\.?[0-9*]*h?l?L?q?Z?" );
13780 QString result; 13790 QString result;
13781 uint last = 0; 13791 uint last = 0;
13782 int pos; 13792 int pos;
13783 int len = 0; 13793 int len = 0;
13784 13794
13785 for (;;) { 13795 for (;;) {
13786 pos = escape.search( format, last ); 13796 pos = escape.search( format, last );
13787 len = escape.matchedLength(); 13797 len = escape.matchedLength();
13788 // Non-escaped text 13798 // Non-escaped text
13789 if ( pos > (int)last ) 13799 if ( pos > (int)last )
13790 result += format.mid( last, pos - last ); 13800 result += format.mid( last, pos - last );
13791 if ( pos < 0 ) { 13801 if ( pos < 0 ) {
13792 // The rest 13802 // The rest
13793 if ( last < format.length() ) 13803 if ( last < format.length() )
13794 result += format.mid( last ); 13804 result += format.mid( last );
13795 break; 13805 break;
13796 } 13806 }
13797 last = pos + len + 1; 13807 last = pos + len + 1;
13798 13808
13799 // Escape 13809 // Escape
13800 QString f = format.mid( pos, len ); 13810 QString f = format.mid( pos, len );
13801 uint width, decimals; 13811 uint width, decimals;
@@ -13892,49 +13902,49 @@ QString &QString::sprintf( const char* cformat, ... )
13892 break; 13902 break;
13893 case 1: 13903 case 1:
13894 ::sprintf( out, in, width, value ); 13904 ::sprintf( out, in, width, value );
13895 break; 13905 break;
13896 case 2: 13906 case 2:
13897 ::sprintf( out, in, width, decimals, value ); 13907 ::sprintf( out, in, width, decimals, value );
13898 } 13908 }
13899 } 13909 }
13900 break; 13910 break;
13901 case 'p': 13911 case 'p':
13902 { 13912 {
13903 void* value = va_arg( ap, void * ); 13913 void* value = va_arg( ap, void * );
13904 switch ( params ) { 13914 switch ( params ) {
13905 case 0: 13915 case 0:
13906 ::sprintf( out, in, value ); 13916 ::sprintf( out, in, value );
13907 break; 13917 break;
13908 case 1: 13918 case 1:
13909 ::sprintf( out, in, width, value ); 13919 ::sprintf( out, in, width, value );
13910 break; 13920 break;
13911 case 2: 13921 case 2:
13912 ::sprintf( out, in, width, decimals, value ); 13922 ::sprintf( out, in, width, decimals, value );
13913 } 13923 }
13914 } 13924 }
13915 } 13925 }
13916 replacement = fromLatin1( out ); 13926 replacement = fromAscii( out );
13917 } 13927 }
13918 result += replacement; 13928 result += replacement;
13919 } 13929 }
13920 *this = result; 13930 *this = result;
13921 13931
13922 va_end( ap ); 13932 va_end( ap );
13923 return *this; 13933 return *this;
13924} 13934}
13925#endif 13935#endif
13926 13936
13927/*! 13937/*!
13928 Fills the string with \a len characters of value \a c, and returns 13938 Fills the string with \a len characters of value \a c, and returns
13929 a reference to the string. 13939 a reference to the string.
13930 13940
13931 If \a len is negative (the default), the current string length is 13941 If \a len is negative (the default), the current string length is
13932 used. 13942 used.
13933 13943
13934 \code 13944 \code
13935 QString str; 13945 QString str;
13936 str.fill( 'g', 5 ); // string == "ggggg" 13946 str.fill( 'g', 5 ); // string == "ggggg"
13937 \endcode 13947 \endcode
13938*/ 13948*/
13939 13949
13940QString& QString::fill( QChar c, int len ) 13950QString& QString::fill( QChar c, int len )
@@ -14103,50 +14113,52 @@ static int bm_find( const QString &str, int index, const QString &pattern, uint
14103 \overload 14113 \overload
14104 14114
14105 Finds the first occurrence of the string \a str, starting at 14115 Finds the first occurrence of the string \a str, starting at
14106 position \a index. If \a index is -1, the search starts at the 14116 position \a index. If \a index is -1, the search starts at the
14107 last character, if it is -2, at the next to last character and so 14117 last character, if it is -2, at the next to last character and so
14108 on. (See findRev() for searching backwards.) 14118 on. (See findRev() for searching backwards.)
14109 14119
14110 If \a cs is TRUE, the search is case sensitive; otherwise the 14120 If \a cs is TRUE, the search is case sensitive; otherwise the
14111 search is case insensitive. 14121 search is case insensitive.
14112 14122
14113 Returns the position of \a str or -1 if \a str could not be found. 14123 Returns the position of \a str or -1 if \a str could not be found.
14114*/ 14124*/
14115 14125
14116int QString::find( const QString& str, int index, bool cs ) const 14126int QString::find( const QString& str, int index, bool cs ) const
14117{ 14127{
14118 const uint l = length(); 14128 const uint l = length();
14119 const uint sl = str.length(); 14129 const uint sl = str.length();
14120 if ( index < 0 ) 14130 if ( index < 0 )
14121 index += l; 14131 index += l;
14122 if ( sl + index > l ) 14132 if ( sl + index > l )
14123 return -1; 14133 return -1;
14124 if ( !sl ) 14134 if ( !sl )
14125 return index; 14135 return index;
14126 14136
14137#ifndef MACOSX_101
14127 if ( sl == 1 ) 14138 if ( sl == 1 )
14128 return find( *str.unicode(), index, cs ); 14139 return find( *str.unicode(), index, cs );
14140#endif
14129 14141
14130 // we use the Boyer-Moore algorithm in cases where the overhead 14142 // we use the Boyer-Moore algorithm in cases where the overhead
14131 // for the hash table should pay off, otherwise we use a simple 14143 // for the hash table should pay off, otherwise we use a simple
14132 // hash function 14144 // hash function
14133 if ( l > 500 && sl > 5 ) { 14145 if ( l > 500 && sl > 5 ) {
14134 uint skiptable[0x100]; 14146 uint skiptable[0x100];
14135 bm_init_skiptable( str, skiptable, cs ); 14147 bm_init_skiptable( str, skiptable, cs );
14136 return bm_find( *this, index, str, skiptable, cs ); 14148 return bm_find( *this, index, str, skiptable, cs );
14137 } 14149 }
14138 14150
14139 /* 14151 /*
14140 We use some hashing for efficiency's sake. Instead of 14152 We use some hashing for efficiency's sake. Instead of
14141 comparing strings, we compare the hash value of str with that of 14153 comparing strings, we compare the hash value of str with that of
14142 a part of this QString. Only if that matches, we call ucstrncmp 14154 a part of this QString. Only if that matches, we call ucstrncmp
14143 or ucstrnicmp. 14155 or ucstrnicmp.
14144 */ 14156 */
14145 const QChar* needle = str.unicode(); 14157 const QChar* needle = str.unicode();
14146 const QChar* haystack = unicode() + index; 14158 const QChar* haystack = unicode() + index;
14147 const QChar* end = unicode() + (l-sl); 14159 const QChar* end = unicode() + (l-sl);
14148 const uint sl_minus_1 = sl-1; 14160 const uint sl_minus_1 = sl-1;
14149 uint hashNeedle = 0, hashHaystack = 0, i; 14161 uint hashNeedle = 0, hashHaystack = 0, i;
14150 14162
14151 if ( cs ) { 14163 if ( cs ) {
14152 for ( i = 0; i < sl; ++i ) { 14164 for ( i = 0; i < sl; ++i ) {
@@ -14200,102 +14212,108 @@ int QString::find( const QString& str, int index, bool cs ) const
14200 Equivalent to find(QString(\a str), \a index). 14212 Equivalent to find(QString(\a str), \a index).
14201*/ 14213*/
14202 14214
14203/*! 14215/*!
14204 \overload 14216 \overload
14205 14217
14206 Finds the first occurrence of the character \a c, starting at 14218 Finds the first occurrence of the character \a c, starting at
14207 position \a index and searching backwards. If the index is -1, the 14219 position \a index and searching backwards. If the index is -1, the
14208 search starts at the last character, if it is -2, at the next to 14220 search starts at the last character, if it is -2, at the next to
14209 last character and so on. 14221 last character and so on.
14210 14222
14211 Returns the position of \a c or -1 if \a c could not be found. 14223 Returns the position of \a c or -1 if \a c could not be found.
14212 14224
14213 If \a cs is TRUE, the search is case sensitive; otherwise the 14225 If \a cs is TRUE, the search is case sensitive; otherwise the
14214 search is case insensitive. 14226 search is case insensitive.
14215 14227
14216 \code 14228 \code
14217 QString string( "bananas" ); 14229 QString string( "bananas" );
14218 int i = string.findRev( 'a' ); // i == 5 14230 int i = string.findRev( 'a' ); // i == 5
14219 \endcode 14231 \endcode
14220*/ 14232*/
14221 14233
14222int QString::findRev( QChar c, int index, bool cs ) const 14234int QString::findRev( QChar c, int index, bool cs ) const
14223{ 14235{
14236#ifdef MACOSX_101
14237 return findRev( QString( c ), index, cs );
14238#else
14224 const uint l = length(); 14239 const uint l = length();
14225 if ( index < 0 ) 14240 if ( index < 0 )
14226 index += l; 14241 index += l;
14227 if ( (uint)index >= l ) 14242 if ( (uint)index >= l )
14228 return -1; 14243 return -1;
14229 const QChar *end = unicode(); 14244 const QChar *end = unicode();
14230 register const QChar *uc = end + index; 14245 register const QChar *uc = end + index;
14231 if ( cs ) { 14246 if ( cs ) {
14232 while ( uc >= end && *uc != c ) 14247 while ( uc >= end && *uc != c )
14233 uc--; 14248 uc--;
14234 } else { 14249 } else {
14235 c = ::lower( c ); 14250 c = ::lower( c );
14236 while ( uc >= end && ::lower( *uc ) != c ) 14251 while ( uc >= end && ::lower( *uc ) != c )
14237 uc--; 14252 uc--;
14238 } 14253 }
14239 return uc - end; 14254 return uc - end;
14255#endif
14240} 14256}
14241 14257
14242/*! 14258/*!
14243 \overload 14259 \overload
14244 14260
14245 Finds the first occurrence of the string \a str, starting at 14261 Finds the first occurrence of the string \a str, starting at
14246 position \a index and searching backwards. If the index is -1, the 14262 position \a index and searching backwards. If the index is -1, the
14247 search starts at the last character, if it is -2, at the next to 14263 search starts at the last character, if it is -2, at the next to
14248 last character and so on. 14264 last character and so on.
14249 14265
14250 Returns the position of \a str or -1 if \a str could not be found. 14266 Returns the position of \a str or -1 if \a str could not be found.
14251 14267
14252 If \a cs is TRUE, the search is case sensitive; otherwise the 14268 If \a cs is TRUE, the search is case sensitive; otherwise the
14253 search is case insensitive. 14269 search is case insensitive.
14254 14270
14255 \code 14271 \code
14256 QString string("bananas"); 14272 QString string("bananas");
14257 int i = string.findRev( "ana" ); // i == 3 14273 int i = string.findRev( "ana" ); // i == 3
14258 \endcode 14274 \endcode
14259*/ 14275*/
14260 14276
14261int QString::findRev( const QString& str, int index, bool cs ) const 14277int QString::findRev( const QString& str, int index, bool cs ) const
14262{ 14278{
14263 /* 14279 /*
14264 See QString::find() for explanations. 14280 See QString::find() for explanations.
14265 */ 14281 */
14266 const uint l = length(); 14282 const uint l = length();
14267 if ( index < 0 ) 14283 if ( index < 0 )
14268 index += l; 14284 index += l;
14269 const uint sl = str.length(); 14285 const uint sl = str.length();
14270 int delta = l-sl; 14286 int delta = l-sl;
14271 if ( index < 0 || index > (int)l || delta < 0 ) 14287 if ( index < 0 || index > (int)l || delta < 0 )
14272 return -1; 14288 return -1;
14273 if ( index > delta ) 14289 if ( index > delta )
14274 index = delta; 14290 index = delta;
14275 14291
14292#ifndef MACOSX_101
14276 if ( sl == 1 ) 14293 if ( sl == 1 )
14277 return findRev( *str.unicode(), index, cs ); 14294 return findRev( *str.unicode(), index, cs );
14295#endif
14278 14296
14279 const QChar* needle = str.unicode(); 14297 const QChar* needle = str.unicode();
14280 const QChar* haystack = unicode() + index; 14298 const QChar* haystack = unicode() + index;
14281 const QChar* end = unicode(); 14299 const QChar* end = unicode();
14282 const uint sl_minus_1 = sl-1; 14300 const uint sl_minus_1 = sl-1;
14283 const QChar* n = needle+sl_minus_1; 14301 const QChar* n = needle+sl_minus_1;
14284 const QChar* h = haystack+sl_minus_1; 14302 const QChar* h = haystack+sl_minus_1;
14285 uint hashNeedle = 0, hashHaystack = 0, i; 14303 uint hashNeedle = 0, hashHaystack = 0, i;
14286 14304
14287 if ( cs ) { 14305 if ( cs ) {
14288 for ( i = 0; i < sl; ++i ) { 14306 for ( i = 0; i < sl; ++i ) {
14289 hashNeedle = ((hashNeedle<<1) + (n-i)->unicode() ); 14307 hashNeedle = ((hashNeedle<<1) + (n-i)->unicode() );
14290 hashHaystack = ((hashHaystack<<1) + (h-i)->unicode() ); 14308 hashHaystack = ((hashHaystack<<1) + (h-i)->unicode() );
14291 } 14309 }
14292 hashHaystack -= haystack->unicode(); 14310 hashHaystack -= haystack->unicode();
14293 14311
14294 while ( haystack >= end ) { 14312 while ( haystack >= end ) {
14295 hashHaystack += haystack->unicode(); 14313 hashHaystack += haystack->unicode();
14296 if ( hashHaystack == hashNeedle 14314 if ( hashHaystack == hashNeedle
14297 && ucstrncmp( needle, haystack, sl ) == 0 ) 14315 && ucstrncmp( needle, haystack, sl ) == 0 )
14298 return haystack-unicode(); 14316 return haystack-unicode();
14299 --haystack; 14317 --haystack;
14300 REHASH( (haystack+sl)->unicode() ); 14318 REHASH( (haystack+sl)->unicode() );
14301 } 14319 }
@@ -14958,89 +14976,99 @@ QString QString::rightJustify( uint width, QChar fill, bool truncate ) const
14958 if ( len ) 14976 if ( len )
14959 memcpy( uc, unicode(), sizeof(QChar)*len ); 14977 memcpy( uc, unicode(), sizeof(QChar)*len );
14960 } else { 14978 } else {
14961 if ( truncate ) 14979 if ( truncate )
14962 result = left( width ); 14980 result = left( width );
14963 else 14981 else
14964 result = *this; 14982 result = *this;
14965 } 14983 }
14966 return result; 14984 return result;
14967} 14985}
14968 14986
14969/*! 14987/*!
14970 Returns a lowercase copy of the string. 14988 Returns a lowercase copy of the string.
14971 14989
14972 \code 14990 \code
14973 QString string( "TROlltECH" ); 14991 QString string( "TROlltECH" );
14974 str = string.lower(); // str == "trolltech" 14992 str = string.lower(); // str == "trolltech"
14975 \endcode 14993 \endcode
14976 14994
14977 \sa upper() 14995 \sa upper()
14978*/ 14996*/
14979 14997
14980QString QString::lower() const 14998QString QString::lower() const
14981{ 14999{
14982 QString s(*this); 15000 int l = length();
14983 int l=length(); 15001 register QChar *p = d->unicode;
14984 if ( l ) { 15002 while ( l ) {
14985 s.real_detach(); // could do this only when we find a change 15003 if ( *p != ::lower(*p) ) {
14986 register QChar *p=s.d->unicode; 15004 QString s( *this );
14987 if ( p ) { 15005 s.real_detach();
14988 while ( l-- ) { 15006 p = s.d->unicode + ( p - d->unicode );
15007 while ( l ) {
14989 *p = ::lower( *p ); 15008 *p = ::lower( *p );
15009 l--;
14990 p++; 15010 p++;
14991 } 15011 }
15012 return s;
14992 } 15013 }
15014 l--;
15015 p++;
14993 } 15016 }
14994 return s; 15017 return *this;
14995} 15018}
14996 15019
14997/*! 15020/*!
14998 Returns an uppercase copy of the string. 15021 Returns an uppercase copy of the string.
14999 15022
15000 \code 15023 \code
15001 QString string( "TeXt" ); 15024 QString string( "TeXt" );
15002 str = string.upper(); // t == "TEXT" 15025 str = string.upper(); // t == "TEXT"
15003 \endcode 15026 \endcode
15004 15027
15005 \sa lower() 15028 \sa lower()
15006*/ 15029*/
15007 15030
15008QString QString::upper() const 15031QString QString::upper() const
15009{ 15032{
15010 QString s(*this); 15033 int l = length();
15011 int l=length(); 15034 register QChar *p = d->unicode;
15012 if ( l ) { 15035 while ( l ) {
15013 s.real_detach(); // could do this only when we find a change 15036 if ( *p != ::upper(*p) ) {
15014 register QChar *p=s.d->unicode; 15037 QString s( *this );
15015 if ( p ) { 15038 s.real_detach();
15016 while ( l-- ) { 15039 p = s.d->unicode + ( p - d->unicode );
15040 while ( l ) {
15017 *p = ::upper( *p ); 15041 *p = ::upper( *p );
15042 l--;
15018 p++; 15043 p++;
15019 } 15044 }
15045 return s;
15020 } 15046 }
15047 l--;
15048 p++;
15021 } 15049 }
15022 return s; 15050 return *this;
15023} 15051}
15024 15052
15025 15053
15026/*! 15054/*!
15027 Returns a string that has whitespace removed from the start and 15055 Returns a string that has whitespace removed from the start and
15028 the end. 15056 the end.
15029 15057
15030 Whitespace means any character for which QChar::isSpace() returns 15058 Whitespace means any character for which QChar::isSpace() returns
15031 TRUE. This includes Unicode characters with decimal values 9 15059 TRUE. This includes Unicode characters with decimal values 9
15032 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may 15060 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may
15033 also include other Unicode characters. 15061 also include other Unicode characters.
15034 15062
15035 \code 15063 \code
15036 QString string = " white space "; 15064 QString string = " white space ";
15037 QString s = string.stripWhiteSpace(); // s == "white space" 15065 QString s = string.stripWhiteSpace(); // s == "white space"
15038 \endcode 15066 \endcode
15039 15067
15040 \sa simplifyWhiteSpace() 15068 \sa simplifyWhiteSpace()
15041*/ 15069*/
15042 15070
15043QString QString::stripWhiteSpace() const 15071QString QString::stripWhiteSpace() const
15044{ 15072{
15045 if ( isEmpty() ) // nothing to do 15073 if ( isEmpty() ) // nothing to do
15046 return *this; 15074 return *this;
@@ -15116,50 +15144,50 @@ QString QString::simplifyWhiteSpace() const
15116 Inserts \a s into the string at position \a index. 15144 Inserts \a s into the string at position \a index.
15117 15145
15118 If \a index is beyond the end of the string, the string is 15146 If \a index is beyond the end of the string, the string is
15119 extended with spaces to length \a index and \a s is then appended 15147 extended with spaces to length \a index and \a s is then appended
15120 and returns a reference to the string. 15148 and returns a reference to the string.
15121 15149
15122 \code 15150 \code
15123 QString string( "I like fish" ); 15151 QString string( "I like fish" );
15124 str = string.insert( 2, "don't " ); 15152 str = string.insert( 2, "don't " );
15125 // str == "I don't like fish" 15153 // str == "I don't like fish"
15126 \endcode 15154 \endcode
15127 15155
15128 \sa remove(), replace() 15156 \sa remove(), replace()
15129*/ 15157*/
15130 15158
15131QString &QString::insert( uint index, const QString &s ) 15159QString &QString::insert( uint index, const QString &s )
15132{ 15160{
15133 // the sub function takes care of &s == this case. 15161 // the sub function takes care of &s == this case.
15134 return insert( index, s.unicode(), s.length() ); 15162 return insert( index, s.unicode(), s.length() );
15135} 15163}
15136 15164
15137/*! 15165/*!
15138 \overload 15166 \overload
15139 15167
15140 Inserts the character in \a s into the string at position \a index 15168 Inserts the first \a len characters in \a s into the string at
15141 \a len number of times and returns a reference to the string. 15169 position \a index and returns a reference to the string.
15142*/ 15170*/
15143 15171
15144QString &QString::insert( uint index, const QChar* s, uint len ) 15172QString &QString::insert( uint index, const QChar* s, uint len )
15145{ 15173{
15146 if ( len == 0 ) 15174 if ( len == 0 )
15147 return *this; 15175 return *this;
15148 uint olen = length(); 15176 uint olen = length();
15149 int nlen = olen + len; 15177 int nlen = olen + len;
15150 15178
15151 if ( s >= d->unicode && (uint)(s - d->unicode) < d->maxl ) { 15179 if ( s >= d->unicode && (uint)(s - d->unicode) < d->maxl ) {
15152 // Part of me - take a copy. 15180 // Part of me - take a copy.
15153 QChar *tmp = QT_ALLOC_QCHAR_VEC( len ); 15181 QChar *tmp = QT_ALLOC_QCHAR_VEC( len );
15154 memcpy(tmp,s,len*sizeof(QChar)); 15182 memcpy(tmp,s,len*sizeof(QChar));
15155 insert(index,tmp,len); 15183 insert(index,tmp,len);
15156 QT_DELETE_QCHAR_VEC( tmp ); 15184 QT_DELETE_QCHAR_VEC( tmp );
15157 return *this; 15185 return *this;
15158 } 15186 }
15159 15187
15160 if ( index >= olen ) { // insert after end of string 15188 if ( index >= olen ) { // insert after end of string
15161 setLength( len + index ); 15189 setLength( len + index );
15162 int n = index - olen; 15190 int n = index - olen;
15163 QChar* uc = d->unicode+olen; 15191 QChar* uc = d->unicode+olen;
15164 while (n--) 15192 while (n--)
15165 *uc++ = ' '; 15193 *uc++ = ' ';
@@ -15230,48 +15258,58 @@ QString &QString::insert( uint index, QChar c ) // insert char
15230 15258
15231/*! 15259/*!
15232 \fn QString& QString::prepend( QChar ch ) 15260 \fn QString& QString::prepend( QChar ch )
15233 15261
15234 \overload 15262 \overload
15235 15263
15236 Inserts \a ch at the beginning of the string and returns a 15264 Inserts \a ch at the beginning of the string and returns a
15237 reference to the string. 15265 reference to the string.
15238 15266
15239 Equivalent to insert(0, \a ch). 15267 Equivalent to insert(0, \a ch).
15240 15268
15241 \sa insert() 15269 \sa insert()
15242*/ 15270*/
15243 15271
15244/*! \fn QString& QString::prepend( const QByteArray &s ) 15272/*! \fn QString& QString::prepend( const QByteArray &s )
15245 \overload 15273 \overload
15246 15274
15247 Inserts \a s at the beginning of the string and returns a reference to the string. 15275 Inserts \a s at the beginning of the string and returns a reference to the string.
15248 15276
15249 Equivalent to insert(0, \a s). 15277 Equivalent to insert(0, \a s).
15250 15278
15251 \sa insert() 15279 \sa insert()
15252 */ 15280 */
15253 15281
15282/*! \fn QString& QString::prepend( const std::string &s )
15283 \overload
15284
15285 Inserts \a s at the beginning of the string and returns a reference to the string.
15286
15287 Equivalent to insert(0, \a s).
15288
15289 \sa insert()
15290 */
15291
15254/*! 15292/*!
15255 \overload 15293 \overload
15256 15294
15257 Inserts \a s at the beginning of the string and returns a reference to the string. 15295 Inserts \a s at the beginning of the string and returns a reference to the string.
15258 15296
15259 Equivalent to insert(0, \a s). 15297 Equivalent to insert(0, \a s).
15260 15298
15261 \sa insert() 15299 \sa insert()
15262 */ 15300 */
15263QString &QString::prepend( const char *s ) 15301QString &QString::prepend( const char *s )
15264{ 15302{
15265 return insert( 0, QString(s) ); 15303 return insert( 0, QString(s) );
15266} 15304}
15267 15305
15268/*! 15306/*!
15269 Removes \a len characters from the string starting at position \a 15307 Removes \a len characters from the string starting at position \a
15270 index, and returns a reference to the string. 15308 index, and returns a reference to the string.
15271 15309
15272 If \a index is beyond the length of the string, nothing happens. 15310 If \a index is beyond the length of the string, nothing happens.
15273 If \a index is within the string, but \a index + \a len is beyond 15311 If \a index is within the string, but \a index + \a len is beyond
15274 the end of the string, the string is truncated at position \a 15312 the end of the string, the string is truncated at position \a
15275 index. 15313 index.
15276 15314
15277 \code 15315 \code
@@ -15827,303 +15865,311 @@ int QString::contains( const QRegExp &rx ) const
15827#endif //QT_NO_REGEXP 15865#endif //QT_NO_REGEXP
15828 15866
15829static bool ok_in_base( QChar c, int base ) 15867static bool ok_in_base( QChar c, int base )
15830{ 15868{
15831 if ( base <= 10 ) 15869 if ( base <= 10 )
15832 return c.isDigit() && c.digitValue() < base; 15870 return c.isDigit() && c.digitValue() < base;
15833 else 15871 else
15834 return c.isDigit() || (c >= 'a' && c < char('a'+base-10)) 15872 return c.isDigit() || (c >= 'a' && c < char('a'+base-10))
15835 || (c >= 'A' && c < char('A'+base-10)); 15873 || (c >= 'A' && c < char('A'+base-10));
15836} 15874}
15837 15875
15838/*! 15876/*!
15839 Returns the string converted to a \c long value to the base \a 15877 Returns the string converted to a \c long value to the base \a
15840 base, which is 10 by default and must be between 2 and 36. 15878 base, which is 10 by default and must be between 2 and 36.
15841 15879
15842 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 15880 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
15843 FALSE; otherwise \a *ok is set to TRUE. 15881 FALSE; otherwise \a *ok is set to TRUE.
15844 15882
15845 \sa number() 15883 \sa number()
15846*/ 15884*/
15847 15885
15848long QString::toLong( bool *ok, int base ) const 15886long QString::toLong( bool *ok, int base ) const
15849{ 15887{
15850 const QChar *p = unicode(); 15888 const QChar *p = unicode();
15851 long val = 0; 15889 ulong val = 0;
15852 int l = length(); 15890 int l = length();
15853 const long max_mult = INT_MAX / base; 15891 const ulong max_mult = LONG_MAX / base;
15854 bool is_ok = FALSE; 15892 bool is_ok = FALSE;
15855 int neg = 0; 15893 int neg = 0;
15856 if ( !p ) 15894 if ( !p )
15857 goto bye; 15895 goto bye;
15858 while ( l && p->isSpace() ) // skip leading space 15896 while ( l && p->isSpace() ) // skip leading space
15859 l--,p++; 15897 l--,p++;
15860 if ( !l ) 15898 if ( !l )
15861 goto bye; 15899 goto bye;
15862 if ( *p == '-' ) { 15900 if ( *p == '-' ) {
15863 l--; 15901 l--;
15864 p++; 15902 p++;
15865 neg = 1; 15903 neg = 1;
15866 } else if ( *p == '+' ) { 15904 } else if ( *p == '+' ) {
15867 l--; 15905 l--;
15868 p++; 15906 p++;
15869 } 15907 }
15870 15908
15871 // NOTE: toULong() code is similar 15909 // NOTE: toULong() code is similar
15872 if ( !l || !ok_in_base(*p,base) ) 15910 if ( !l || !ok_in_base(*p,base) )
15873 goto bye; 15911 goto bye;
15874 while ( l && ok_in_base(*p,base) ) { 15912 while ( l && ok_in_base(*p,base) ) {
15875 l--; 15913 l--;
15876 int dv; 15914 int dv;
15877 if ( p->isDigit() ) { 15915 if ( p->isDigit() ) {
15878 dv = p->digitValue(); 15916 dv = p->digitValue();
15879 } else { 15917 } else {
15880 if ( *p >= 'a' && *p <= 'z' ) 15918 if ( *p >= 'a' && *p <= 'z' )
15881 dv = *p - 'a' + 10; 15919 dv = *p - 'a' + 10;
15882 else 15920 else
15883 dv = *p - 'A' + 10; 15921 dv = *p - 'A' + 10;
15884 } 15922 }
15885 if ( val > max_mult || 15923 if ( val > max_mult ||
15886 (val == max_mult && dv > (INT_MAX % base) + neg) ) 15924 (val == max_mult && dv > (LONG_MAX % base) + neg) )
15887 goto bye; 15925 goto bye;
15888 val = base * val + dv; 15926 val = base * val + dv;
15889 p++; 15927 p++;
15890 } 15928 }
15891 if ( neg )
15892 val = -val;
15893 while ( l && p->isSpace() ) // skip trailing space 15929 while ( l && p->isSpace() ) // skip trailing space
15894 l--,p++; 15930 l--, p++;
15895 if ( !l ) 15931 if ( !l )
15896 is_ok = TRUE; 15932 is_ok = TRUE;
15897bye: 15933bye:
15898 if ( ok ) 15934 if ( ok )
15899 *ok = is_ok; 15935 *ok = is_ok;
15900 return is_ok ? val : 0; 15936 return is_ok ? ( neg ? -( (long) val ) : (long) val ) : 0L;
15901} 15937}
15902 15938
15903/*! 15939/*!
15904 Returns the string converted to an \c {unsigned long} value to the 15940 Returns the string converted to an \c {unsigned long} value to the
15905 base \a base, which is 10 by default and must be between 2 and 36. 15941 base \a base, which is 10 by default and must be between 2 and 36.
15906 15942
15907 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 15943 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
15908 FALSE; otherwise \a *ok is set to TRUE. 15944 FALSE; otherwise \a *ok is set to TRUE.
15909 15945
15910 \sa number() 15946 \sa number()
15911*/ 15947*/
15912 15948
15913ulong QString::toULong( bool *ok, int base ) const 15949ulong QString::toULong( bool *ok, int base ) const
15914{ 15950{
15915 const QChar *p = unicode(); 15951 const QChar *p = unicode();
15916 ulong val = 0; 15952 ulong val = 0;
15917 int l = length(); 15953 int l = length();
15918 const ulong max_mult = UINT_MAX / base; 15954 const ulong max_mult = ULONG_MAX / base;
15919 bool is_ok = FALSE; 15955 bool is_ok = FALSE;
15920 if ( !p ) 15956 if ( !p )
15921 goto bye; 15957 goto bye;
15922 while ( l && p->isSpace() ) // skip leading space 15958 while ( l && p->isSpace() ) // skip leading space
15923 l--,p++; 15959 l--,p++;
15924 if ( !l ) 15960 if ( !l )
15925 goto bye; 15961 goto bye;
15926 if ( *p == '+' ) 15962 if ( *p == '+' )
15927 l--,p++; 15963 l--,p++;
15928 15964
15929 // NOTE: toLong() code is similar 15965 // NOTE: toLong() code is similar
15930 if ( !l || !ok_in_base(*p,base) ) 15966 if ( !l || !ok_in_base(*p,base) )
15931 goto bye; 15967 goto bye;
15932 while ( l && ok_in_base(*p,base) ) { 15968 while ( l && ok_in_base(*p,base) ) {
15933 l--; 15969 l--;
15934 uint dv; 15970 uint dv;
15935 if ( p->isDigit() ) { 15971 if ( p->isDigit() ) {
15936 dv = p->digitValue(); 15972 dv = p->digitValue();
15937 } else { 15973 } else {
15938 if ( *p >= 'a' && *p <= 'z' ) 15974 if ( *p >= 'a' && *p <= 'z' )
15939 dv = *p - 'a' + 10; 15975 dv = *p - 'a' + 10;
15940 else 15976 else
15941 dv = *p - 'A' + 10; 15977 dv = *p - 'A' + 10;
15942 } 15978 }
15943 if ( val > max_mult || (val == max_mult && dv > UINT_MAX % base) ) 15979 if ( val > max_mult || (val == max_mult && dv > ULONG_MAX % base) )
15944 goto bye; 15980 goto bye;
15945 val = base * val + dv; 15981 val = base * val + dv;
15946 p++; 15982 p++;
15947 } 15983 }
15948 15984
15949 while ( l && p->isSpace() ) // skip trailing space 15985 while ( l && p->isSpace() ) // skip trailing space
15950 l--,p++; 15986 l--,p++;
15951 if ( !l ) 15987 if ( !l )
15952 is_ok = TRUE; 15988 is_ok = TRUE;
15953bye: 15989bye:
15954 if ( ok ) 15990 if ( ok )
15955 *ok = is_ok; 15991 *ok = is_ok;
15956 return is_ok ? val : 0; 15992 return is_ok ? val : 0;
15957} 15993}
15958 15994
15959/*! 15995/*!
15960 Returns the string converted to a \c short value to the base \a 15996 Returns the string converted to a \c short value to the base \a
15961 base, which is 10 by default and must be between 2 and 36. 15997 base, which is 10 by default and must be between 2 and 36.
15962 15998
15963 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 15999 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
15964 FALSE; otherwise \a *ok is set to TRUE. 16000 FALSE; otherwise \a *ok is set to TRUE.
15965*/ 16001*/
15966 16002
15967short QString::toShort( bool *ok, int base ) const 16003short QString::toShort( bool *ok, int base ) const
15968{ 16004{
15969 long v = toLong( ok, base ); 16005 long v = toLong( ok, base );
15970 if ( ok && *ok && (v < -32768 || v > 32767) ) { 16006 if ( ok && *ok && (v < SHRT_MIN || v > SHRT_MAX) ) {
15971 *ok = FALSE; 16007 *ok = FALSE;
15972 v = 0; 16008 v = 0;
15973 } 16009 }
15974 return (short)v; 16010 return (short)v;
15975} 16011}
15976 16012
15977/*! 16013/*!
15978 Returns the string converted to an \c {unsigned short} value to 16014 Returns the string converted to an \c {unsigned short} value to
15979 the base \a base, which is 10 by default and must be between 2 and 16015 the base \a base, which is 10 by default and must be between 2 and
15980 36. 16016 36.
15981 16017
15982 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 16018 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
15983 FALSE; otherwise \a *ok is set to TRUE. 16019 FALSE; otherwise \a *ok is set to TRUE.
15984*/ 16020*/
15985 16021
15986ushort QString::toUShort( bool *ok, int base ) const 16022ushort QString::toUShort( bool *ok, int base ) const
15987{ 16023{
15988 ulong v = toULong( ok, base ); 16024 ulong v = toULong( ok, base );
15989 if ( ok && *ok && (v > 65535) ) { 16025 if ( ok && *ok && (v > USHRT_MAX) ) {
15990 *ok = FALSE; 16026 *ok = FALSE;
15991 v = 0; 16027 v = 0;
15992 } 16028 }
15993 return (ushort)v; 16029 return (ushort)v;
15994} 16030}
15995 16031
15996 16032
15997/*! 16033/*!
15998 Returns the string converted to an \c int value to the base \a 16034 Returns the string converted to an \c int value to the base \a
15999 base, which is 10 by default and must be between 2 and 36. 16035 base, which is 10 by default and must be between 2 and 36.
16000 16036
16001 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 16037 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
16002 FALSE; otherwise \a *ok is set to TRUE. 16038 FALSE; otherwise \a *ok is set to TRUE.
16003 16039
16004 \code 16040 \code
16005 QString str( "FF" ); 16041 QString str( "FF" );
16006 bool ok; 16042 bool ok;
16007 int hex = str.toInt( &ok, 16 ); // hex == 255, ok == TRUE 16043 int hex = str.toInt( &ok, 16 ); // hex == 255, ok == TRUE
16008 int dec = str.toInt( &ok, 10 ); // dec == 0, ok == FALSE 16044 int dec = str.toInt( &ok, 10 ); // dec == 0, ok == FALSE
16009 \endcode 16045 \endcode
16010 16046
16011 \sa number() 16047 \sa number()
16012*/ 16048*/
16013 16049
16014int QString::toInt( bool *ok, int base ) const 16050int QString::toInt( bool *ok, int base ) const
16015{ 16051{
16016 return (int)toLong( ok, base ); 16052 long v = toLong( ok, base );
16053 if ( ok && *ok && (v < INT_MIN || v > INT_MAX) ) {
16054 *ok = FALSE;
16055 v = 0;
16056 }
16057 return (int)v;
16017} 16058}
16018 16059
16019/*! 16060/*!
16020 Returns the string converted to an \c{unsigned int} value to the 16061 Returns the string converted to an \c{unsigned int} value to the
16021 base \a base, which is 10 by default and must be between 2 and 36. 16062 base \a base, which is 10 by default and must be between 2 and 36.
16022 16063
16023 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 16064 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
16024 FALSE; otherwise \a *ok is set to TRUE. 16065 FALSE; otherwise \a *ok is set to TRUE.
16025 16066
16026 \sa number() 16067 \sa number()
16027*/ 16068*/
16028 16069
16029uint QString::toUInt( bool *ok, int base ) const 16070uint QString::toUInt( bool *ok, int base ) const
16030{ 16071{
16031 return (uint)toULong( ok, base ); 16072 ulong v = toULong( ok, base );
16073 if ( ok && *ok && (v > UINT_MAX) ) {
16074 *ok = FALSE;
16075 v = 0;
16076 }
16077 return (uint)v;
16032} 16078}
16033 16079
16034/*! 16080/*!
16035 Returns the string converted to a \c double value. 16081 Returns the string converted to a \c double value.
16036 16082
16037 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 16083 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
16038 FALSE; otherwise \a *ok is set to TRUE. 16084 FALSE; otherwise \a *ok is set to TRUE.
16039 16085
16040 \code 16086 \code
16041 QString string( "1234.56" ); 16087 QString string( "1234.56" );
16042 double a = string.toDouble(); // a == 1234.56 16088 double a = string.toDouble(); // a == 1234.56
16043 \endcode 16089 \endcode
16044 16090
16045 \sa number() 16091 \sa number()
16046*/ 16092*/
16047 16093
16048double QString::toDouble( bool *ok ) const 16094double QString::toDouble( bool *ok ) const
16049{ 16095{
16050 char *end; 16096 char *end;
16051 16097
16052 const char *a = latin1(); 16098 const char *a = latin1();
16053 double val = strtod( a ? a : "", &end ); 16099 double val = strtod( a ? a : "", &end );
16054 if ( ok ) 16100 if ( ok )
16055 *ok = ( a && *a && (end == 0 || (end - a) == (int)length()) ); 16101 *ok = ( a && *a && (end == 0 || *end == '\0') );
16056 return val; 16102 return val;
16057} 16103}
16058 16104
16059/*! 16105/*!
16060 Returns the string converted to a \c float value. 16106 Returns the string converted to a \c float value.
16061 16107
16062 If \a ok is not 0: if a conversion error occurs, \a *ok is set to 16108 If \a ok is not 0: if a conversion error occurs, \a *ok is set to
16063 FALSE; otherwise \a *ok is set to TRUE. 16109 FALSE; otherwise \a *ok is set to TRUE.
16064 16110
16065 \sa number() 16111 \sa number()
16066*/ 16112*/
16067 16113
16068float QString::toFloat( bool *ok ) const 16114float QString::toFloat( bool *ok ) const
16069{ 16115{
16070 return (float)toDouble( ok ); 16116 return (float)toDouble( ok );
16071} 16117}
16072 16118
16073 16119
16074/*! 16120/*!
16075 Sets the string to the printed value of \a n in base \a base and 16121 Sets the string to the printed value of \a n in base \a base and
16076 returns a reference to the string. 16122 returns a reference to the string.
16077 16123
16078 The base is 10 by default and must be between 2 and 36. 16124 The base is 10 by default and must be between 2 and 36.
16079 16125
16080 \code 16126 \code
16081 QString string; 16127 QString string;
16082 string = string.setNum( 1234 ); // string == "1234" 16128 string = string.setNum( 1234 ); // string == "1234"
16083 \endcode 16129 \endcode
16084*/ 16130*/
16085 16131
16086QString &QString::setNum( long n, int base ) 16132QString &QString::setNum( long n, int base )
16087{ 16133{
16088#if defined(QT_CHECK_RANGE) 16134#if defined(QT_CHECK_RANGE)
16089 if ( base < 2 || base > 36 ) { 16135 if ( base < 2 || base > 36 ) {
16090 qWarning( "QString::setNum: Invalid base %d", base ); 16136 qWarning( "QString::setNum: Invalid base %d", base );
16091 base = 10; 16137 base = 10;
16092 } 16138 }
16093#endif 16139#endif
16094 char charbuf[65*sizeof(QChar)]; 16140 char charbuf[65*sizeof(QChar)];
16095 QChar *buf = (QChar*)charbuf; 16141 QChar *buf = (QChar*)charbuf;
16096 QChar *p = &buf[64]; 16142 QChar *p = &buf[64];
16097 int len = 0; 16143 int len = 0;
16098 bool neg; 16144 bool neg;
16099 if ( n < 0 ) { 16145 if ( n < 0 ) {
16100 neg = TRUE; 16146 neg = TRUE;
16101 if ( n == INT_MIN ) { 16147 if ( n == LONG_MIN ) {
16102 // Cannot always negate this special case 16148 // Cannot always negate this special case
16103 QString s1, s2; 16149 QString s1, s2;
16104 s1.setNum(n/base); 16150 s1.setNum(n/base, base );
16105 s2.setNum((-(n+base))%base); 16151 s2.setNum((-(n+base))%base, base );
16106 *this = s1 + s2; 16152 *this = s1 + s2;
16107 return *this; 16153 return *this;
16108 } 16154 }
16109 n = -n; 16155 n = -n;
16110 } else { 16156 } else {
16111 neg = FALSE; 16157 neg = FALSE;
16112 } 16158 }
16113 do { 16159 do {
16114 *--p = "0123456789abcdefghijklmnopqrstuvwxyz"[((int)(n%base))]; 16160 *--p = "0123456789abcdefghijklmnopqrstuvwxyz"[((int)(n%base))];
16115 n /= base; 16161 n /= base;
16116 ++len; 16162 ++len;
16117 } while ( n ); 16163 } while ( n );
16118 if ( neg ) { 16164 if ( neg ) {
16119 *--p = '-'; 16165 *--p = '-';
16120 ++len; 16166 ++len;
16121 } 16167 }
16122 return setUnicode( p, len ); 16168 return setUnicode( p, len );
16123} 16169}
16124 16170
16125/*! 16171/*!
16126 \overload 16172 \overload
16127 16173
16128 Sets the string to the printed value of \a n in base \a base and 16174 Sets the string to the printed value of \a n in base \a base and
16129 returns a reference to the string. 16175 returns a reference to the string.
@@ -16440,408 +16486,488 @@ void QString::setExpand( uint index, QChar c )
16440 the result. 16486 the result.
16441 16487
16442 Equivalent to operator+=(). 16488 Equivalent to operator+=().
16443*/ 16489*/
16444 16490
16445/*! 16491/*!
16446 \fn QString& QString::append( QChar ch ) 16492 \fn QString& QString::append( QChar ch )
16447 16493
16448 \overload 16494 \overload
16449 16495
16450 Appends character \a ch to the string and returns a reference to 16496 Appends character \a ch to the string and returns a reference to
16451 the result. 16497 the result.
16452 16498
16453 Equivalent to operator+=(). 16499 Equivalent to operator+=().
16454*/ 16500*/
16455 16501
16456/*! \fn QString& QString::append( const QByteArray &str ) 16502/*! \fn QString& QString::append( const QByteArray &str )
16457 \overload 16503 \overload
16458 16504
16459 Appends \a str to the string and returns a reference to the result. 16505 Appends \a str to the string and returns a reference to the result.
16460 16506
16461 Equivalent to operator+=(). 16507 Equivalent to operator+=().
16462 */ 16508 */
16463 16509
16510/*! \fn QString& QString::append( const std::string &str )
16511 \overload
16512
16513 Appends \a str to the string and returns a reference to the result.
16514
16515 Equivalent to operator+=().
16516 */
16517
16518
16464/*! \fn QString& QString::append( const char *str ) 16519/*! \fn QString& QString::append( const char *str )
16465 \overload 16520 \overload
16466 16521
16467 Appends \a str to the string and returns a reference to the result. 16522 Appends \a str to the string and returns a reference to the result.
16468 16523
16469 Equivalent to operator+=(). 16524 Equivalent to operator+=().
16470 */ 16525 */
16471 16526
16472/*! 16527/*!
16473 Appends \a str to the string and returns a reference to the string. 16528 Appends \a str to the string and returns a reference to the string.
16474*/ 16529*/
16475QString& QString::operator+=( const QString &str ) 16530QString& QString::operator+=( const QString &str )
16476{ 16531{
16477 uint len1 = length(); 16532 uint len1 = length();
16478 uint len2 = str.length(); 16533 uint len2 = str.length();
16479 if ( len2 ) { 16534 if ( len2 ) {
16480 setLength(len1+len2); 16535 setLength(len1+len2);
16481 memcpy( d->unicode+len1, str.unicode(), sizeof(QChar)*len2 ); 16536 memcpy( d->unicode+len1, str.unicode(), sizeof(QChar)*len2 );
16482 } else if ( isNull() && !str.isNull() ) { // ## just for 1.x compat: 16537 } else if ( isNull() && !str.isNull() ) { // ## just for 1.x compat:
16483 *this = fromLatin1( "" ); 16538 *this = fromLatin1( "" );
16484 } 16539 }
16485 return *this; 16540 return *this;
16486} 16541}
16487 16542
16488/*! 16543/*!
16489 \overload 16544 \overload
16490 16545
16491 Appends \a str to the string and returns a reference to the string. 16546 Appends \a str to the string and returns a reference to the string.
16492*/ 16547*/
16548#ifndef QT_NO_CAST_ASCII
16493QString& QString::operator+=( const char *str ) 16549QString& QString::operator+=( const char *str )
16494{ 16550{
16495 if ( str ) { 16551 if ( str ) {
16552#ifndef QT_NO_TEXTCODEC
16553 if ( QTextCodec::codecForCStrings() )
16554 return operator+=( fromAscii( str ) );
16555#endif
16556
16496 uint len1 = length(); 16557 uint len1 = length();
16497 uint len2 = strlen( str ); 16558 uint len2 = strlen( str );
16498 if ( len2 ) { 16559 if ( len2 ) {
16499 setLength(len1+len2); 16560 setLength(len1+len2);
16500 uint i = 0; 16561 uint i = 0;
16501 while( i < len2 ) { 16562 while( i < len2 ) {
16502 d->unicode[len1+i] = str[i]; 16563 d->unicode[len1+i] = str[i];
16503 i++; 16564 i++;
16504 } 16565 }
16505 } else if ( isNull() ) { // ## just for 1.x compat: 16566 } else if ( isNull() ) { // ## just for 1.x compat:
16506 *this = fromLatin1( "" ); 16567 *this = fromLatin1( "" );
16507 } 16568 }
16508 } 16569 }
16509 return *this; 16570 return *this;
16510} 16571}
16572#endif
16511 16573
16512/*! \overload 16574/*! \overload
16513 16575
16514 Appends \a c to the string and returns a reference to the string. 16576 Appends \a c to the string and returns a reference to the string.
16515*/ 16577*/
16516 16578
16517QString &QString::operator+=( QChar c ) 16579QString &QString::operator+=( QChar c )
16518{ 16580{
16519 setLength(length()+1); 16581 setLength(length()+1);
16520 d->unicode[length()-1] = c; 16582 d->unicode[length()-1] = c;
16521 return *this; 16583 return *this;
16522} 16584}
16523 16585
16524/*! 16586/*!
16525 \overload 16587 \overload
16526 16588
16527 Appends \a c to the string and returns a reference to the string. 16589 Appends \a c to the string and returns a reference to the string.
16528*/ 16590*/
16529 16591
16530QString &QString::operator+=( char c ) 16592QString &QString::operator+=( char c )
16531{ 16593{
16594#ifndef QT_NO_TEXTCODEC
16595 if ( QTextCodec::codecForCStrings() )
16596 return operator+=( fromAscii( &c, 1 ) );
16597#endif
16532 setLength(length()+1); 16598 setLength(length()+1);
16533 d->unicode[length()-1] = c; 16599 d->unicode[length()-1] = c;
16534 return *this; 16600 return *this;
16535} 16601}
16536 16602
16537/*! 16603/*!
16538 \fn QString &QString::operator+=( const QByteArray &str ) 16604 \fn QString &QString::operator+=( const QByteArray &str )
16539 \overload 16605 \overload
16540 16606
16541 Appends \a str to the string and returns a reference to the string. 16607 Appends \a str to the string and returns a reference to the string.
16542*/ 16608*/
16543 16609
16610/*!
16611 \fn QString &QString::operator+=( const std::string &str )
16612 \overload
16613
16614 Appends \a str to the string and returns a reference to the string.
16615*/
16616
16544 16617
16545 16618
16546/*! 16619/*!
16547 \fn char QChar::latin1() const 16620 \fn char QChar::latin1() const
16548 16621
16549 Returns a latin-1 copy of this character, if this character is in 16622 Returns the Latin-1 value of this character, or 0 if it
16550 the latin-1 character set. If not, this function returns 0. 16623 cannot be represented in Latin-1.
16551*/ 16624*/
16552 16625
16553 16626
16554/*! 16627/*!
16555 Returns a Latin-1 representation of the string. Note that the 16628 Returns a Latin-1 representation of the string. The
16556 returned value is undefined if the string contains non-Latin-1 16629 returned value is undefined if the string contains non-Latin-1
16557 characters. If you want to convert strings into formats other than 16630 characters. If you want to convert strings into formats other than
16558 Unicode, see the QTextCodec classes. 16631 Unicode, see the QTextCodec classes.
16559 16632
16560 This function is mainly useful for boot-strapping legacy code to 16633 This function is mainly useful for boot-strapping legacy code to
16561 use Unicode. 16634 use Unicode.
16562 16635
16563 The result remains valid so long as one unmodified copy of the 16636 The result remains valid so long as one unmodified copy of the
16564 source string exists. 16637 source string exists.
16565 16638
16566 \sa utf8(), local8Bit() 16639 \sa fromLatin1(), ascii(), utf8(), local8Bit()
16567*/ 16640*/
16568const char* QString::latin1() const 16641const char* QString::latin1() const
16569{ 16642{
16570 if ( !d->ascii ) { 16643 if ( !d->ascii || !d->islatin1 ) {
16571 Q2HELPER(stat_get_ascii++) 16644 d->ascii = unicodeToLatin1( d->unicode, d->len );
16572 Q2HELPER(stat_get_ascii_size+=d->len) 16645 d->islatin1 = TRUE;
16573 d->ascii = unicodeToAscii( d->unicode, d->len );
16574 } 16646 }
16575 return d->ascii; 16647 return d->ascii;
16576} 16648}
16577 16649
16578/*! 16650/*!
16579 \fn const char* QString::ascii() const 16651 Returns an 8-bit ASCII representation of the string.
16580 \obsolete
16581 16652
16582 This function simply calls latin1() and returns the result. 16653 If a codec has been set using QTextCodec::codecForCStrings(),
16654 it is used to convert Unicode to 8-bit char. Otherwise, this function
16655 does the same as latin1().
16656
16657 \sa fromAscii(), latin1(), utf8(), local8Bit()
16583*/ 16658*/
16659const char* QString::ascii() const
16660{
16661#ifndef QT_NO_TEXTCODEC
16662 if ( QTextCodec::codecForCStrings() ) {
16663 if ( !d->ascii || d->islatin1 ) {
16664 QCString s = QTextCodec::codecForCStrings()->fromUnicode( *this );
16665 s.detach();
16666 d->ascii = s.data();
16667 d->islatin1 = FALSE;
16668 s.resetRawData( s.data(), s.size() ); // we have stolen the data
16669 }
16670 return d->ascii;
16671 }
16672#endif // QT_NO_TEXTCODEC
16673 return latin1();
16674}
16584 16675
16585/*! 16676/*!
16586 Returns the string encoded in UTF8 format. 16677 Returns the string encoded in UTF-8 format.
16587 16678
16588 See QTextCodec for more diverse coding/decoding of Unicode strings. 16679 See QTextCodec for more diverse coding/decoding of Unicode strings.
16589 16680
16590 \sa QString::fromUtf8(), local8Bit(), latin1() 16681 \sa fromUtf8(), ascii(), latin1(), local8Bit()
16591*/ 16682*/
16592QCString QString::utf8() const 16683QCString QString::utf8() const
16593{ 16684{
16594 int l = length(); 16685 int l = length();
16595 int rlen = l*3+1; 16686 int rlen = l*3+1;
16596 QCString rstr(rlen); 16687 QCString rstr(rlen);
16597 uchar* cursor = (uchar*)rstr.data(); 16688 uchar* cursor = (uchar*)rstr.data();
16598 const QChar *ch = d->unicode; 16689 const QChar *ch = d->unicode;
16599 for (int i=0; i<l; i++) { 16690 for (int i=0; i<l; i++) {
16600 ushort u = ch->unicode(); 16691 ushort u = ch->unicode();
16601 if ( u < 0x80 ) { 16692 if ( u < 0x80 ) {
16602 *cursor++ = (uchar)u; 16693 *cursor++ = (uchar)u;
16603 } else { 16694 } else {
16604 if ( u < 0x0800 ) { 16695 if ( u < 0x0800 ) {
16605 *cursor++ = 0xc0 | ((uchar) (u >> 6)); 16696 *cursor++ = 0xc0 | ((uchar) (u >> 6));
16606 } else { 16697 } else {
16607 *cursor++ = 0xe0 | ((uchar) (u >> 12)); 16698 *cursor++ = 0xe0 | ((uchar) (u >> 12));
16608 *cursor++ = 0x80 | ( ((uchar) (u >> 6)) & 0x3f); 16699 *cursor++ = 0x80 | ( ((uchar) (u >> 6)) & 0x3f);
16609 } 16700 }
16610 *cursor++ = 0x80 | ((uchar) (u&0x3f)); 16701 *cursor++ = 0x80 | ((uchar) (u&0x3f));
16611 } 16702 }
16612 ch++; 16703 ch++;
16613 } 16704 }
16614 rstr.truncate( cursor - (uchar*)rstr.data() ); 16705 rstr.truncate( cursor - (uchar*)rstr.data() );
16615 return rstr; 16706 return rstr;
16616} 16707}
16617 16708
16618/*! 16709/*!
16619 Returns the Unicode string decoded from the first \a len 16710 Returns the Unicode string decoded from the first \a len
16620 characters of \a utf8, ignoring the rest of \a utf8. If \a len is 16711 characters of \a utf8, ignoring the rest of \a utf8. If \a len is
16621 -1 then the length of \a utf8 is used. If \a len is bigger than 16712 -1 then the length of \a utf8 is used. If \a len is bigger than
16622 the length of \a utf8 then it will use the length of \a utf8. 16713 the length of \a utf8 then it will use the length of \a utf8.
16623 16714
16624 \code 16715 \code
16625 QString str = QString::fromUtf8( "123456789", 5 ); 16716 QString str = QString::fromUtf8( "123456789", 5 );
16626 // str == "12345" 16717 // str == "12345"
16627 \endcode 16718 \endcode
16628 16719
16629 See QTextCodec for more diverse coding/decoding of Unicode strings. 16720 See QTextCodec for more diverse coding/decoding of Unicode strings.
16630*/ 16721*/
16631QString QString::fromUtf8( const char* utf8, int len ) 16722QString QString::fromUtf8( const char* utf8, int len )
16632{ 16723{
16633 if ( !utf8 ) 16724 if ( !utf8 )
16634 return QString::null; 16725 return QString::null;
16635 16726
16636 if ( len < 0 ) len = qstrlen( utf8 ); 16727 if ( len < 0 )
16728 len = strlen( utf8 );
16637 QString result; 16729 QString result;
16638 result.setLength( len ); // worst case 16730 result.setLength( len ); // worst case
16639 QChar *qch = (QChar *)result.unicode(); 16731 QChar *qch = (QChar *)result.unicode();
16640 ushort uc = 0; 16732 ushort uc = 0;
16641 int need = 0; 16733 int need = 0;
16642 for (int i=0; i<len; i++) { 16734 for (int i=0; i<len; i++) {
16643 uchar ch = utf8[i]; 16735 uchar ch = utf8[i];
16644 if (need) { 16736 if (need) {
16645 if ( (ch&0xc0) == 0x80 ) { 16737 if ( (ch&0xc0) == 0x80 ) {
16646 uc = (uc << 6) | (ch & 0x3f); 16738 uc = (uc << 6) | (ch & 0x3f);
16647 need--; 16739 need--;
16648 if ( !need ) { 16740 if ( !need ) {
16649 *qch = uc; 16741 *qch = uc;
16650 qch++; 16742 qch++;
16651 } 16743 }
16652 } else { 16744 } else {
16653 // error 16745 // error
16654 *qch = QChar::replacement; 16746 *qch = QChar::replacement;
16655 qch++; 16747 qch++;
16656 need = 0; 16748 need = 0;
16657 } 16749 }
16658 } else { 16750 } else {
16659 if ( ch < 128 ) { 16751 if ( ch < 128 ) {
16660 *qch = ch; 16752 *qch = ch;
16661 qch++; 16753 qch++;
16662 } else if ( (ch&0xe0) == 0xc0 ) { 16754 } else if ( (ch&0xe0) == 0xc0 ) {
16663 uc = ch &0x1f; 16755 uc = ch &0x1f;
16664 need = 1; 16756 need = 1;
16665 } else if ( (ch&0xf0) == 0xe0 ) { 16757 } else if ( (ch&0xf0) == 0xe0 ) {
16666 uc = ch &0x0f; 16758 uc = ch &0x0f;
16667 need = 2; 16759 need = 2;
16668 } 16760 }
16669 } 16761 }
16670 } 16762 }
16671 result.truncate( qch - result.unicode() ); 16763 result.truncate( qch - result.unicode() );
16672 return result; 16764 return result;
16673} 16765}
16674 16766
16675/*! 16767/*!
16676 Returns the Unicode string decoded from the first \a len 16768 Returns the Unicode string decoded from the first \a len
16677 characters of \a chars, ignoring the rest of \a chars. If \a len 16769 characters of \a ascii, ignoring the rest of \a ascii. If \a len
16678 is -1 then the length of \a chars is used. If \a len is bigger 16770 is -1 then the length of \a ascii is used. If \a len is bigger
16679 than the length of \a chars then it will use the length of \a 16771 than the length of \a ascii then it will use the length of \a
16680 chars. 16772 ascii.
16773
16774 If a codec has been set using QTextCodec::codecForCStrings(),
16775 it is used to convert Unicode to 8-bit char. Otherwise, this function
16776 does the same as fromLatin1().
16681 16777
16682 This is the same as the QString(const char*) constructor, but you 16778 This is the same as the QString(const char*) constructor, but you
16683 can make that constructor invisible if you compile with the define 16779 can make that constructor invisible if you compile with the define
16684 \c QT_NO_CAST_ASCII, in which case you can explicitly create a 16780 \c QT_NO_CAST_ASCII, in which case you can explicitly create a
16685 QString from Latin-1 text using this function. 16781 QString from 8-bit ASCII text using this function.
16686 16782
16687 \code 16783 \code
16688 QString str = QString::fromLatin1( "123456789", 5 ); 16784 QString str = QString::fromAscii( "123456789", 5 );
16689 // str == "12345" 16785 // str == "12345"
16690 \endcode 16786 \endcode
16787 */
16788QString QString::fromAscii( const char* ascii, int len )
16789{
16790#ifndef QT_NO_TEXTCODEC
16791 if ( QTextCodec::codecForCStrings() ) {
16792 if ( !ascii )
16793 return QString::null;
16794 if ( len < 0 )
16795 len = strlen( ascii );
16796 if ( len == 0 || *ascii == '\0' )
16797 return QString::fromLatin1( "" );
16798 return QTextCodec::codecForCStrings()->toUnicode( ascii, len );
16799 }
16800#endif
16801 return fromLatin1( ascii, len );
16802}
16803
16804
16805/*!
16806 Returns the Unicode string decoded from the first \a len
16807 characters of \a chars, ignoring the rest of \a chars. If \a len
16808 is -1 then the length of \a chars is used. If \a len is bigger
16809 than the length of \a chars then it will use the length of \a
16810 chars.
16811
16812 \sa fromAscii()
16691*/ 16813*/
16692QString QString::fromLatin1( const char* chars, int len ) 16814QString QString::fromLatin1( const char* chars, int len )
16693{ 16815{
16694 uint l; 16816 uint l;
16695 QChar *uc; 16817 QChar *uc;
16696 if ( len < 0 ) 16818 if ( len < 0 )
16697 len = -1; 16819 len = -1;
16698 uc = internalAsciiToUnicode( chars, &l, len ); 16820 uc = internalLatin1ToUnicode( chars, &l, len );
16699 return QString( new QStringData(uc, l, l), TRUE ); 16821 return QString( new QStringData(uc, l, l), TRUE );
16700} 16822}
16701 16823
16702/*! 16824/*!
16703 \fn const QChar* QString::unicode() const 16825 \fn const QChar* QString::unicode() const
16704 16826
16705 Returns the Unicode representation of the string. The result 16827 Returns the Unicode representation of the string. The result
16706 remains valid until the string is modified. 16828 remains valid until the string is modified.
16707*/ 16829*/
16708 16830
16709/*! 16831/*!
16710 Returns the string encoded in a locale-specific format. On X11, 16832 Returns the string encoded in a locale-specific format. On X11,
16711 this is the QTextCodec::codecForLocale(). On Windows, it is a 16833 this is the QTextCodec::codecForLocale(). On Windows, it is a
16712 system-defined encoding. On Mac OS X, this always uses utf8 as the 16834 system-defined encoding. On Mac OS X, this always uses UTF-8 as
16713 encoding. 16835 the encoding.
16714 16836
16715 See QTextCodec for more diverse coding/decoding of Unicode 16837 See QTextCodec for more diverse coding/decoding of Unicode
16716 strings. 16838 strings.
16717 16839
16718 \sa QString::fromLocal8Bit(), latin1(), utf8() 16840 \sa fromLocal8Bit(), ascii(), latin1(), utf8()
16719*/ 16841*/
16720 16842
16721
16722QCString QString::local8Bit() const 16843QCString QString::local8Bit() const
16723{ 16844{
16724#ifdef QT_NO_TEXTCODEC 16845#ifdef QT_NO_TEXTCODEC
16725 return latin1(); 16846 return latin1();
16726#else 16847#else
16727#ifdef Q_WS_X11 16848#ifdef Q_WS_X11
16728 QTextCodec* codec = QTextCodec::codecForLocale(); 16849 QTextCodec* codec = QTextCodec::codecForLocale();
16729 return codec 16850 return codec
16730 ? codec->fromUnicode(*this) 16851 ? codec->fromUnicode(*this)
16731 : QCString(latin1()); 16852 : QCString(latin1());
16732#endif 16853#endif
16733#if defined( Q_WS_MACX ) 16854#if defined( Q_WS_MACX )
16734 return utf8(); 16855 return utf8();
16735#endif 16856#endif
16736#if defined( Q_WS_MAC9 ) 16857#if defined( Q_WS_MAC9 )
16737 return QCString(latin1()); //I'm evil.. 16858 return QCString(latin1()); //I'm evil..
16738#endif 16859#endif
16739#ifdef Q_WS_WIN 16860#ifdef Q_WS_WIN
16740 return qt_winQString2MB( *this ); 16861 return qt_winQString2MB( *this );
16741#endif 16862#endif
16742#ifdef Q_WS_QWS 16863#ifdef Q_WS_QWS
16743 return utf8(); // ##### if there is ANY 8 bit format supported? 16864 return utf8(); // ### if there is any 8 bit format supported?
16744#endif 16865#endif
16745#endif 16866#endif
16746} 16867}
16747 16868
16748/*! 16869/*!
16749 Returns the Unicode string decoded from the first \a len 16870 Returns the Unicode string decoded from the first \a len
16750 characters of \a local8Bit, ignoring the rest of \a local8Bit. If 16871 characters of \a local8Bit, ignoring the rest of \a local8Bit. If
16751 \a len is -1 then the length of \a local8Bit is used. If \a len is 16872 \a len is -1 then the length of \a local8Bit is used. If \a len is
16752 bigger than the length of \a local8Bit then it will use the length 16873 bigger than the length of \a local8Bit then it will use the length
16753 of \a local8Bit. 16874 of \a local8Bit.
16754 16875
16755 \code 16876 \code
16756 QString str = QString::fromLocal8Bit( "123456789", 5 ); 16877 QString str = QString::fromLocal8Bit( "123456789", 5 );
16757 // str == "12345" 16878 // str == "12345"
16758 \endcode 16879 \endcode
16759 16880
16760 \a local8Bit is assumed to be encoded in a locale-specific format. 16881 \a local8Bit is assumed to be encoded in a locale-specific format.
16761 16882
16762 See QTextCodec for more diverse coding/decoding of Unicode strings. 16883 See QTextCodec for more diverse coding/decoding of Unicode strings.
16763*/ 16884*/
16764QString QString::fromLocal8Bit( const char* local8Bit, int len ) 16885QString QString::fromLocal8Bit( const char* local8Bit, int len )
16765{ 16886{
16766#ifdef QT_NO_TEXTCODEC 16887#ifdef QT_NO_TEXTCODEC
16767 return fromLatin1( local8Bit, len ); 16888 return fromLatin1( local8Bit, len );
16768#else 16889#else
16769 16890
16770 if ( !local8Bit ) 16891 if ( !local8Bit )
16771 return QString::null; 16892 return QString::null;
16772#ifdef Q_WS_X11 16893#ifdef Q_WS_X11
16773 QTextCodec* codec = QTextCodec::codecForLocale(); 16894 QTextCodec* codec = QTextCodec::codecForLocale();
16774 if ( len < 0 ) len = qstrlen(local8Bit); 16895 if ( len < 0 )
16896 len = strlen( local8Bit );
16775 return codec 16897 return codec
16776 ? codec->toUnicode( local8Bit, len ) 16898 ? codec->toUnicode( local8Bit, len )
16777 : fromLatin1( local8Bit, len ); 16899 : fromLatin1( local8Bit, len );
16778#endif 16900#endif
16779#if defined( Q_WS_MAC ) 16901#if defined( Q_WS_MAC )
16780 return fromUtf8(local8Bit,len); 16902 return fromUtf8(local8Bit,len);
16781#endif 16903#endif
16782// Should this be OS_WIN32? 16904// Should this be OS_WIN32?
16783#ifdef Q_WS_WIN 16905#ifdef Q_WS_WIN
16784 if ( len >= 0 ) { 16906 if ( len >= 0 ) {
16785 QCString s(local8Bit,len+1); 16907 QCString s(local8Bit,len+1);
16786 return qt_winMB2QString(s); 16908 return qt_winMB2QString(s);
16787 } 16909 }
16788 return qt_winMB2QString( local8Bit ); 16910 return qt_winMB2QString( local8Bit );
16789#endif 16911#endif
16790#ifdef Q_WS_QWS 16912#ifdef Q_WS_QWS
16791 return fromUtf8(local8Bit,len); 16913 return fromUtf8(local8Bit,len);
16792#endif 16914#endif
16793#endif // QT_NO_TEXTCODEC 16915#endif // QT_NO_TEXTCODEC
16794} 16916}
16795 16917
16796/*! 16918/*!
16797 \fn QString::operator const char *() const 16919 \fn QString::operator const char *() const
16798 16920
16799 Returns latin1(). Be sure to see the warnings documented in the 16921 Returns latin1(). Be sure to see the warnings documented in the
16800 latin1() function. Note that for new code which you wish to be 16922 latin1() function. Note that for new code which you wish to be
16801 strictly Unicode-clean, you can define the macro \c 16923 strictly Unicode-clean, you can define the macro \c
16802 QT_NO_ASCII_CAST when compiling your code to hide this function so 16924 QT_NO_ASCII_CAST when compiling your code to hide this function so
16803 that automatic casts are not done. This has the added advantage 16925 that automatic casts are not done. This has the added advantage
16804 that you catch the programming error described in operator!(). 16926 that you catch the programming error described in operator!().
16805*/ 16927*/
16806 16928
16929/*!
16930 \fn QString::operator std::string() const
16931
16932 Returns ascii().
16933*/
16934
16807 16935
16808/*! 16936/*!
16809 Returns the QString as a zero terminated array of unsigned shorts 16937 Returns the QString as a zero terminated array of unsigned shorts
16810 if the string is not null; otherwise returns zero. 16938 if the string is not null; otherwise returns zero.
16811 16939
16812 The result remains valid so long as one unmodified 16940 The result remains valid so long as one unmodified
16813 copy of the source string exists. 16941 copy of the source string exists.
16814*/ 16942*/
16815const unsigned short *QString::ucs2() const 16943const unsigned short *QString::ucs2() const
16816{ 16944{
16817 if ( ! d->unicode ) 16945 if ( ! d->unicode )
16818 return 0; 16946 return 0;
16819 unsigned int len = d->len; 16947 unsigned int len = d->len;
16820 if ( d->maxl < len + 1 ) { 16948 if ( d->maxl < len + 1 ) {
16821 // detach, grow or shrink 16949 // detach, grow or shrink
16822 Q2HELPER(stat_copy_on_write++)
16823 Q2HELPER(stat_copy_on_write_size += len)
16824 uint newMax = computeNewMax( len + 1 ); 16950 uint newMax = computeNewMax( len + 1 );
16825 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); 16951 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax );
16826 if ( nd ) { 16952 if ( nd ) {
16827 if ( d->unicode ) 16953 if ( d->unicode )
16828 memcpy( nd, d->unicode, sizeof(QChar)*len ); 16954 memcpy( nd, d->unicode, sizeof(QChar)*len );
16829 ((QString *)this)->deref(); 16955 ((QString *)this)->deref();
16830 ((QString *)this)->d = new QStringData( nd, len, newMax ); 16956 ((QString *)this)->d = new QStringData( nd, len, newMax );
16831 } 16957 }
16832 } 16958 }
16833 d->unicode[len] = 0; 16959 d->unicode[len] = 0;
16834 return (unsigned short *) d->unicode; 16960 return (unsigned short *) d->unicode;
16835} 16961}
16836 16962
16837/*! 16963/*!
16838 Constructs a string that is a deep copy of \a str, interpreted as a 16964 Constructs a string that is a deep copy of \a str, interpreted as a
16839 UCS2 encoded, zero terminated, Unicode string. 16965 UCS2 encoded, zero terminated, Unicode string.
16840 16966
16841 If \a str is 0, then a null string is created. 16967 If \a str is 0, then a null string is created.
16842 16968
16843 \sa isNull() 16969 \sa isNull()
16844*/ 16970*/
16845QString QString::fromUcs2( const unsigned short *str ) 16971QString QString::fromUcs2( const unsigned short *str )
16846{ 16972{
16847 if ( !str ) { 16973 if ( !str ) {
@@ -16962,126 +17088,146 @@ void QString::subat( uint i )
16962 } 17088 }
16963} 17089}
16964 17090
16965 17091
16966/*! 17092/*!
16967 Resizes the string to \a len characters and copies \a unicode into 17093 Resizes the string to \a len characters and copies \a unicode into
16968 the string. If \a unicode is 0, nothing is copied, but the 17094 the string. If \a unicode is 0, nothing is copied, but the
16969 string is still resized to \a len. If \a len is zero, then the 17095 string is still resized to \a len. If \a len is zero, then the
16970 string becomes a \link isNull() null\endlink string. 17096 string becomes a \link isNull() null\endlink string.
16971 17097
16972 \sa setLatin1(), isNull() 17098 \sa setLatin1(), isNull()
16973*/ 17099*/
16974 17100
16975QString& QString::setUnicode( const QChar *unicode, uint len ) 17101QString& QString::setUnicode( const QChar *unicode, uint len )
16976{ 17102{
16977 if ( len == 0 ) { // set to null string 17103 if ( len == 0 ) { // set to null string
16978 if ( d != shared_null ) { // beware of nullstring being set to nullstring 17104 if ( d != shared_null ) { // beware of nullstring being set to nullstring
16979 deref(); 17105 deref();
16980 d = shared_null ? shared_null : makeSharedNull(); 17106 d = shared_null ? shared_null : makeSharedNull();
16981 d->ref(); 17107 d->ref();
16982 } 17108 }
16983 } else if ( d->count != 1 || len > d->maxl || 17109 } else if ( d->count != 1 || len > d->maxl ||
16984 ( len * 4 < d->maxl && d->maxl > 4 ) ) { 17110 ( len * 4 < d->maxl && d->maxl > 4 ) ) {
16985 // detach, grown or shrink 17111 // detach, grown or shrink
16986 Q2HELPER(stat_copy_on_write++)
16987 Q2HELPER(stat_copy_on_write_size+=d->len)
16988 uint newMax = computeNewMax( len ); 17112 uint newMax = computeNewMax( len );
16989 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); 17113 QChar* nd = QT_ALLOC_QCHAR_VEC( newMax );
16990 if ( unicode ) 17114 if ( unicode )
16991 memcpy( nd, unicode, sizeof(QChar)*len ); 17115 memcpy( nd, unicode, sizeof(QChar)*len );
16992 deref(); 17116 deref();
16993 d = new QStringData( nd, len, newMax ); 17117 d = new QStringData( nd, len, newMax );
16994 } else { 17118 } else {
16995 d->len = len; 17119 d->len = len;
16996 d->setDirty(); 17120 d->setDirty();
16997 if ( unicode ) 17121 if ( unicode )
16998 memcpy( d->unicode, unicode, sizeof(QChar)*len ); 17122 memcpy( d->unicode, unicode, sizeof(QChar)*len );
16999 } 17123 }
17000 return *this; 17124 return *this;
17001} 17125}
17002 17126
17003/*! 17127/*!
17004 Resizes the string to \a len characters and copies \a 17128 Resizes the string to \a len characters and copies \a
17005 unicode_as_ushorts into the string (on some X11 client platforms 17129 unicode_as_ushorts into the string (on some X11 client platforms
17006 this will involve a byte-swapping pass). 17130 this will involve a byte-swapping pass).
17007 17131
17008 If \a unicode_as_ushorts is 0, nothing is copied, but the string 17132 If \a unicode_as_ushorts is 0, nothing is copied, but the string
17009 is still resized to \a len. If \a len is zero, the string becomes 17133 is still resized to \a len. If \a len is zero, the string becomes
17010 a \link isNull() null\endlink string. 17134 a \link isNull() null\endlink string.
17011 17135
17012 \sa setLatin1(), isNull() 17136 \sa setLatin1(), isNull()
17013*/ 17137*/
17014QString& QString::setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ) 17138QString& QString::setUnicodeCodes( const ushort* unicode_as_ushorts, uint len )
17015{ 17139{
17016 return setUnicode((const QChar*)unicode_as_ushorts, len); 17140 return setUnicode((const QChar*)unicode_as_ushorts, len);
17017} 17141}
17018 17142
17019 17143
17020/*! 17144/*!
17145 Sets this string to \a str, interpreted as a classic 8-bit ASCII C
17146 string. If \a len is -1 (the default), then it is set to
17147 strlen(str).
17148
17149 If \a str is 0 a null string is created. If \a str is "", an empty
17150 string is created.
17151
17152 \sa isNull(), isEmpty()
17153*/
17154
17155QString &QString::setAscii( const char *str, int len )
17156{
17157#ifndef QT_NO_TEXTCODEC
17158 if ( QTextCodec::codecForCStrings() ) {
17159 *this = QString::fromAscii( str, len );
17160 return *this;
17161 }
17162#endif // QT_NO_TEXTCODEC
17163 return setLatin1( str, len );
17164}
17165
17166/*!
17021 Sets this string to \a str, interpreted as a classic Latin1 C 17167 Sets this string to \a str, interpreted as a classic Latin1 C
17022 string. If \a len is -1 (the default), then it is set to 17168 string. If \a len is -1 (the default), then it is set to
17023 strlen(str). 17169 strlen(str).
17024 17170
17025 If \a str is 0 a null string is created. If \a str is "", an empty 17171 If \a str is 0 a null string is created. If \a str is "", an empty
17026 string is created. 17172 string is created.
17027 17173
17028 \sa isNull(), isEmpty() 17174 \sa isNull(), isEmpty()
17029*/ 17175*/
17030 17176
17031QString &QString::setLatin1( const char *str, int len ) 17177QString &QString::setLatin1( const char *str, int len )
17032{ 17178{
17033 if ( str == 0 ) 17179 if ( str == 0 )
17034 return setUnicode(0,0); 17180 return setUnicode(0,0);
17035 if ( len < 0 ) 17181 if ( len < 0 )
17036 len = qstrlen(str); 17182 len = strlen( str );
17037 if ( len == 0 ) { // won't make a null string 17183 if ( len == 0 ) { // won't make a null string
17038 *this = QString::fromLatin1( "" ); 17184 *this = QString::fromLatin1( "" );
17039 } else { 17185 } else {
17040 setUnicode( 0, len ); // resize but not copy 17186 setUnicode( 0, len ); // resize but not copy
17041 QChar *p = d->unicode; 17187 QChar *p = d->unicode;
17042 while ( len-- ) 17188 while ( len-- )
17043 *p++ = *str++; 17189 *p++ = *str++;
17044 } 17190 }
17045 return *this; 17191 return *this;
17046} 17192}
17047 17193
17048/*! \internal 17194/*! \internal
17049 */ 17195 */
17050void QString::checkSimpleText() const 17196void QString::checkSimpleText() const
17051{ 17197{
17052 QChar *p = d->unicode; 17198 QChar *p = d->unicode;
17053 QChar *end = p + d->len; 17199 QChar *end = p + d->len;
17054 d->simpletext = 1;
17055 while( p < end ) { 17200 while( p < end ) {
17056 ushort uc = p->unicode(); 17201 ushort uc = p->unicode();
17057 // sort out regions of complex text formatting 17202 // sort out regions of complex text formatting
17058 if ( uc > 0x058f && ( uc < 0x1100 || uc > 0xfb0f ) ) { 17203 if ( uc > 0x058f && ( uc < 0x1100 || uc > 0xfb0f ) ) {
17059 d->simpletext = 0; 17204 d->issimpletext = FALSE;
17060 return; 17205 return;
17061 } 17206 }
17062 p++; 17207 p++;
17063 } 17208 }
17209 d->issimpletext = TRUE;
17064} 17210}
17065 17211
17066/*! \fn bool QString::simpleText() const 17212/*! \fn bool QString::simpleText() const
17067 \internal 17213 \internal
17068*/ 17214*/
17069 17215
17070/*! \internal 17216/*! \internal
17071 */ 17217 */
17072bool QString::isRightToLeft() const 17218bool QString::isRightToLeft() const
17073{ 17219{
17074 int len = length(); 17220 int len = length();
17075 QChar *p = d->unicode; 17221 QChar *p = d->unicode;
17076 while( len-- ) { 17222 while( len-- ) {
17077 switch( ::direction( *p ) ) 17223 switch( ::direction( *p ) )
17078 { 17224 {
17079 case QChar::DirL: 17225 case QChar::DirL:
17080 case QChar::DirLRO: 17226 case QChar::DirLRO:
17081 case QChar::DirLRE: 17227 case QChar::DirLRE:
17082 return FALSE; 17228 return FALSE;
17083 case QChar::DirR: 17229 case QChar::DirR:
17084 case QChar::DirAL: 17230 case QChar::DirAL:
17085 case QChar::DirRLO: 17231 case QChar::DirRLO:
17086 case QChar::DirRLE: 17232 case QChar::DirRLE:
17087 return TRUE; 17233 return TRUE;
diff --git a/qmake/tools/qtextstream.cpp b/qmake/tools/qtextstream.cpp
index 75c6531..ddca5bd 100644
--- a/qmake/tools/qtextstream.cpp
+++ b/qmake/tools/qtextstream.cpp
@@ -1068,49 +1068,49 @@ QTextStream &QTextStream::writeBlock( const char* p, uint len )
1068 for ( uint i = 0; i < len; i++ ) 1068 for ( uint i = 0; i < len; i++ )
1069 u[i] = p[i]; 1069 u[i] = p[i];
1070 dev->writeBlock( (char*)u, len * sizeof(QChar) ); 1070 dev->writeBlock( (char*)u, len * sizeof(QChar) );
1071 delete [] u; 1071 delete [] u;
1072 } else { 1072 } else {
1073 for ( uint i = 0; i < len; i++ ) 1073 for ( uint i = 0; i < len; i++ )
1074 ts_putc( (uchar)p[i] ); 1074 ts_putc( (uchar)p[i] );
1075 } 1075 }
1076 return *this; 1076 return *this;
1077} 1077}
1078 1078
1079QTextStream &QTextStream::writeBlock( const QChar* p, uint len ) 1079QTextStream &QTextStream::writeBlock( const QChar* p, uint len )
1080{ 1080{
1081#ifndef QT_NO_TEXTCODEC 1081#ifndef QT_NO_TEXTCODEC
1082 if ( mapper ) { 1082 if ( mapper ) {
1083 if ( !d->encoder ) 1083 if ( !d->encoder )
1084 d->encoder = mapper->makeEncoder(); 1084 d->encoder = mapper->makeEncoder();
1085 QConstString s( p, len ); 1085 QConstString s( p, len );
1086 int l = len; 1086 int l = len;
1087 QCString block = d->encoder->fromUnicode( s.string(), l ); 1087 QCString block = d->encoder->fromUnicode( s.string(), l );
1088 dev->writeBlock( block, l ); 1088 dev->writeBlock( block, l );
1089 } else 1089 } else
1090#endif 1090#endif
1091 if ( latin1 ) { 1091 if ( latin1 ) {
1092 char *str = QString::unicodeToAscii( p, len ); 1092 char *str = QString::unicodeToLatin1( p, len );
1093 dev->writeBlock( str, len ); 1093 dev->writeBlock( str, len );
1094 delete [] str; 1094 delete [] str;
1095 } else if ( internalOrder ) { 1095 } else if ( internalOrder ) {
1096 if ( doUnicodeHeader ) { 1096 if ( doUnicodeHeader ) {
1097 doUnicodeHeader = FALSE; 1097 doUnicodeHeader = FALSE;
1098 ts_putc( QChar::byteOrderMark ); 1098 ts_putc( QChar::byteOrderMark );
1099 } 1099 }
1100 dev->writeBlock( (char*)p, sizeof(QChar)*len ); 1100 dev->writeBlock( (char*)p, sizeof(QChar)*len );
1101 } else { 1101 } else {
1102 for (uint i=0; i<len; i++) 1102 for (uint i=0; i<len; i++)
1103 ts_putc( p[i] ); 1103 ts_putc( p[i] );
1104 } 1104 }
1105 return *this; 1105 return *this;
1106} 1106}
1107 1107
1108/*! 1108/*!
1109 Resets the text stream. 1109 Resets the text stream.
1110 1110
1111 \list 1111 \list
1112 \i All flags are set to 0. 1112 \i All flags are set to 0.
1113 \i The field width is set to 0. 1113 \i The field width is set to 0.
1114 \i The fill character is set to ' ' (Space). 1114 \i The fill character is set to ' ' (Space).
1115 \i The precision is set to 6. 1115 \i The precision is set to 6.
1116 \endlist 1116 \endlist
diff --git a/qmake/tools/qucom.cpp b/qmake/tools/qucom.cpp
index 6086a79..658da97 100644
--- a/qmake/tools/qucom.cpp
+++ b/qmake/tools/qucom.cpp
@@ -275,266 +275,149 @@ bool QUType_bool::convertTo( QUObject *, QUType * )
275int QUType_bool::serializeTo( QUObject *, QUBuffer * ) 275int QUType_bool::serializeTo( QUObject *, QUBuffer * )
276{ 276{
277 return 0; 277 return 0;
278} 278}
279 279
280int QUType_bool::serializeFrom( QUObject *, QUBuffer * ) 280int QUType_bool::serializeFrom( QUObject *, QUBuffer * )
281{ 281{
282 return 0; 282 return 0;
283} 283}
284 284
285// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5} 285// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
286const QUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 ); 286const QUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 );
287QUType_int static_QUType_int; 287QUType_int static_QUType_int;
288const QUuid *QUType_int::uuid() const { return &TID_QUType_int; } 288const QUuid *QUType_int::uuid() const { return &TID_QUType_int; }
289const char *QUType_int::desc() const { return "int"; } 289const char *QUType_int::desc() const { return "int"; }
290 290
291void QUType_int::set( QUObject *o, int v ) 291void QUType_int::set( QUObject *o, int v )
292{ 292{
293 o->payload.i = v; 293 o->payload.i = v;
294 o->type = this; 294 o->type = this;
295} 295}
296 296
297bool QUType_int::canConvertFrom( QUObject *o, QUType *t ) 297bool QUType_int::canConvertFrom( QUObject *o, QUType *t )
298{ 298{
299 if ( isEqual( t, &static_QUType_double ) || 299 if ( isEqual( t, &static_QUType_double ) )
300 isEqual( t, &static_QUType_float ) )
301 return TRUE; 300 return TRUE;
302 301
303 return t->canConvertTo( o, this ); 302 return t->canConvertTo( o, this );
304} 303}
305 304
306bool QUType_int::canConvertTo( QUObject * /*o*/, QUType *t ) 305bool QUType_int::canConvertTo( QUObject * /*o*/, QUType *t )
307{ 306{
308 return isEqual( t, &static_QUType_double ) || 307 return isEqual( t, &static_QUType_double );
309 isEqual( t, &static_QUType_float );
310} 308}
311 309
312bool QUType_int::convertFrom( QUObject *o, QUType *t ) 310bool QUType_int::convertFrom( QUObject *o, QUType *t )
313{ 311{
314 if ( isEqual( t, &static_QUType_double ) ) 312 if ( isEqual( t, &static_QUType_double ) )
315 o->payload.i = (long)o->payload.d; 313 o->payload.i = (long)o->payload.d;
316 else if ( isEqual( t, &static_QUType_float ) )
317 o->payload.i = (long)o->payload.f;
318 else 314 else
319 return t->convertTo( o, this ); 315 return t->convertTo( o, this );
320 316
321 o->type = this; 317 o->type = this;
322 return TRUE; 318 return TRUE;
323} 319}
324 320
325bool QUType_int::convertTo( QUObject *o, QUType *t ) 321bool QUType_int::convertTo( QUObject *o, QUType *t )
326{ 322{
327 if ( isEqual( t, &static_QUType_double ) ) { 323 if ( isEqual( t, &static_QUType_double ) ) {
328 o->payload.d = (double)o->payload.i; 324 o->payload.d = (double)o->payload.i;
329 o->type = &static_QUType_double; 325 o->type = &static_QUType_double;
330 } else if ( isEqual( t, &static_QUType_float ) ) {
331 o->payload.f = (float)o->payload.i;
332 o->type = &static_QUType_float;
333 } else 326 } else
334 return FALSE; 327 return FALSE;
335 return TRUE; 328 return TRUE;
336} 329}
337 330
338int QUType_int::serializeTo( QUObject *, QUBuffer * ) 331int QUType_int::serializeTo( QUObject *, QUBuffer * )
339{ 332{
340 return 0; 333 return 0;
341} 334}
342 335
343int QUType_int::serializeFrom( QUObject *, QUBuffer * ) 336int QUType_int::serializeFrom( QUObject *, QUBuffer * )
344{ 337{
345 return 0; 338 return 0;
346} 339}
347 340
348// {5938712A-C496-11D5-8CB2-00C0F03BC0F3}
349const QUuid TID_QUType_uint( 0x5938712a, 0xc496, 0x11d5, 0x8c, 0xb2, 0x00, 0xc0, 0xf0, 0x3b, 0xc0, 0xf3);
350QUType_uint static_QUType_uint;
351const QUuid *QUType_uint::uuid() const { return &TID_QUType_uint; }
352const char *QUType_uint::desc() const { return "uint"; }
353
354void QUType_uint::set( QUObject *o, uint v )
355{
356 o->payload.ui = v;
357 o->type = this;
358}
359
360bool QUType_uint::canConvertFrom( QUObject *o, QUType *t )
361{
362 return t->canConvertTo( o, this );
363}
364
365bool QUType_uint::canConvertTo( QUObject * /*o*/, QUType * /*t*/ )
366{
367 return FALSE;
368}
369
370bool QUType_uint::convertFrom( QUObject *o, QUType *t )
371{
372 return t->convertTo( o, this );
373}
374
375bool QUType_uint::convertTo( QUObject * /*o*/, QUType * /*t*/ )
376{
377 return FALSE;
378}
379
380int QUType_uint::serializeTo( QUObject *, QUBuffer * )
381{
382 return 0;
383}
384
385int QUType_uint::serializeFrom( QUObject *, QUBuffer * )
386{
387 return 0;
388}
389
390// {2D0974E5-0BA6-4ec2-8837-C198972CB48C} 341// {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
391const QUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c ); 342const QUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c );
392QUType_double static_QUType_double; 343QUType_double static_QUType_double;
393const QUuid *QUType_double::uuid() const { return &TID_QUType_double; } 344const QUuid *QUType_double::uuid() const { return &TID_QUType_double; }
394const char *QUType_double::desc() const {return "double"; } 345const char *QUType_double::desc() const {return "double"; }
395 346
396void QUType_double::set( QUObject *o, double v ) 347void QUType_double::set( QUObject *o, double v )
397{ 348{
398 o->payload.d = v; 349 o->payload.d = v;
399 o->type = this; 350 o->type = this;
400} 351}
401 352
402bool QUType_double::canConvertFrom( QUObject *o, QUType *t ) 353bool QUType_double::canConvertFrom( QUObject *o, QUType *t )
403{ 354{
404 if ( isEqual( t, &static_QUType_int ) || 355 if ( isEqual( t, &static_QUType_int ) )
405 isEqual( t, &static_QUType_float) )
406 return TRUE; 356 return TRUE;
407 357
408 return t->canConvertTo( o, this ); 358 return t->canConvertTo( o, this );
409} 359}
410 360
411bool QUType_double::canConvertTo( QUObject * /*o*/, QUType *t ) 361bool QUType_double::canConvertTo( QUObject * /*o*/, QUType *t )
412{ 362{
413 return isEqual( t, &static_QUType_int ) || 363 return isEqual( t, &static_QUType_int );
414 isEqual( t, &static_QUType_float );
415} 364}
416 365
417bool QUType_double::convertFrom( QUObject *o, QUType *t ) 366bool QUType_double::convertFrom( QUObject *o, QUType *t )
418{ 367{
419 if ( isEqual( t, &static_QUType_int ) ) 368 if ( isEqual( t, &static_QUType_int ) )
420 o->payload.d = (double)o->payload.i; 369 o->payload.d = (double)o->payload.i;
421 else if ( isEqual( t, &static_QUType_float ) ) 370 else
422 o->payload.d = (double)o->payload.f;
423 else
424 return t->convertTo( o, this ); 371 return t->convertTo( o, this );
425 372
426 o->type = this; 373 o->type = this;
427 return TRUE; 374 return TRUE;
428} 375}
429 376
430bool QUType_double::convertTo( QUObject *o, QUType *t ) 377bool QUType_double::convertTo( QUObject *o, QUType *t )
431{ 378{
432 if ( isEqual( t, &static_QUType_int ) ) { 379 if ( isEqual( t, &static_QUType_int ) ) {
433 o->payload.i = (int) o->payload.d; 380 o->payload.i = (int) o->payload.d;
434 o->type = &static_QUType_int; 381 o->type = &static_QUType_int;
435 } else if ( isEqual( t, &static_QUType_double ) ) { 382 } else if ( isEqual( t, &static_QUType_double ) ) {
436 o->payload.d = (double) o->payload.f; 383 o->payload.d = (double) o->payload.f;
437 o->type = &static_QUType_double; 384 o->type = &static_QUType_double;
438 } else 385 } else
439 return FALSE; 386 return FALSE;
440 return TRUE; 387 return TRUE;
441} 388}
442 389
443int QUType_double::serializeTo( QUObject *, QUBuffer * ) 390int QUType_double::serializeTo( QUObject *, QUBuffer * )
444{ 391{
445 return 0; 392 return 0;
446} 393}
447 394
448int QUType_double::serializeFrom( QUObject *, QUBuffer * ) 395int QUType_double::serializeFrom( QUObject *, QUBuffer * )
449{ 396{
450 return 0; 397 return 0;
451} 398}
452 399
453
454// {544C5175-6993-4486-B04D-CEC4D21BF4B9 }
455const QUuid TID_QUType_float( 0x544c5175, 0x6993, 0x4486, 0xb0, 0x4d, 0xce, 0xc4, 0xd2, 0x1b, 0xf4, 0xb9 );
456QUType_float static_QUType_float;
457const QUuid *QUType_float::uuid() const { return &TID_QUType_float; }
458const char *QUType_float::desc() const {return "float"; }
459
460void QUType_float::set( QUObject *o, float v )
461{
462 o->payload.f = v;
463 o->type = this;
464}
465
466bool QUType_float::canConvertFrom( QUObject *o, QUType *t )
467{
468 if ( isEqual( t, &static_QUType_int ) ||
469 isEqual( t, &static_QUType_double ) )
470 return TRUE;
471
472 return t->canConvertTo( o, this );
473}
474
475bool QUType_float::canConvertTo( QUObject * /*o*/, QUType *t )
476{
477 return isEqual( t, &static_QUType_int ) ||
478 isEqual( t, &static_QUType_double );
479}
480
481bool QUType_float::convertFrom( QUObject *o, QUType *t )
482{
483 if ( isEqual( t, &static_QUType_int ) )
484 o->payload.f = (float)o->payload.i;
485 else if ( isEqual( t, &static_QUType_double ) )
486 o->payload.f = (float)o->payload.d;
487 else
488 return t->convertTo( o, this );
489
490 o->type = this;
491 return TRUE;
492}
493
494bool QUType_float::convertTo( QUObject *o, QUType *t )
495{
496 if ( isEqual( t, &static_QUType_int ) ) {
497 o->payload.i = (int) o->payload.f;
498 o->type = &static_QUType_int;
499 } else if ( isEqual( t, &static_QUType_double ) ) {
500 o->payload.d = (double) o->payload.f;
501 o->type = &static_QUType_double;
502 } else
503 return FALSE;
504 return TRUE;
505}
506
507int QUType_float::serializeTo( QUObject *, QUBuffer * )
508{
509 return 0;
510}
511
512int QUType_float::serializeFrom( QUObject *, QUBuffer * )
513{
514 return 0;
515}
516
517// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9} 400// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
518const QUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 ); 401const QUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 );
519QUType_charstar static_QUType_charstar; 402QUType_charstar static_QUType_charstar;
520const QUuid *QUType_charstar::uuid() const { return &TID_QUType_charstar; } 403const QUuid *QUType_charstar::uuid() const { return &TID_QUType_charstar; }
521const char *QUType_charstar::desc() const { return "char*"; } 404const char *QUType_charstar::desc() const { return "char*"; }
522 405
523void QUType_charstar::set( QUObject *o, const char* v, bool take ) 406void QUType_charstar::set( QUObject *o, const char* v, bool take )
524{ 407{
525 if ( take ) { 408 if ( take ) {
526 if ( v ) { 409 if ( v ) {
527 o->payload.charstar.ptr = new char[ strlen(v) + 1 ]; 410 o->payload.charstar.ptr = new char[ strlen(v) + 1 ];
528 strcpy( o->payload.charstar.ptr, v ); 411 strcpy( o->payload.charstar.ptr, v );
529 } else { 412 } else {
530 o->payload.charstar.ptr = 0; 413 o->payload.charstar.ptr = 0;
531 } 414 }
532 o->payload.charstar.owner = TRUE; 415 o->payload.charstar.owner = TRUE;
533 } else { 416 } else {
534 o->payload.charstar.ptr = (char*) v; 417 o->payload.charstar.ptr = (char*) v;
535 o->payload.charstar.owner = FALSE; 418 o->payload.charstar.owner = FALSE;
536 } 419 }
537 o->type = this; 420 o->type = this;
538} 421}
539 422
540bool QUType_charstar::canConvertFrom( QUObject *o, QUType *t ) 423bool QUType_charstar::canConvertFrom( QUObject *o, QUType *t )
@@ -572,97 +455,90 @@ int QUType_charstar::serializeTo( QUObject *, QUBuffer * )
572int QUType_charstar::serializeFrom( QUObject *, QUBuffer * ) 455int QUType_charstar::serializeFrom( QUObject *, QUBuffer * )
573{ 456{
574 return 0; 457 return 0;
575} 458}
576 459
577 460
578// Qt specific types 461// Qt specific types
579 462
580// {44C2A547-01E7-4e56-8559-35AF9D2F42B7} 463// {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
581const QUuid TID_QUType_QString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 ); 464const QUuid TID_QUType_QString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 );
582QUType_QString static_QUType_QString; 465QUType_QString static_QUType_QString;
583const QUuid *QUType_QString::uuid() const { return &TID_QUType_QString; } 466const QUuid *QUType_QString::uuid() const { return &TID_QUType_QString; }
584const char *QUType_QString::desc() const { return "QString"; } 467const char *QUType_QString::desc() const { return "QString"; }
585 468
586void QUType_QString::set( QUObject *o, const QString& v ) 469void QUType_QString::set( QUObject *o, const QString& v )
587{ 470{
588 o->payload.ptr = new QString( v ); 471 o->payload.ptr = new QString( v );
589 o->type = this; 472 o->type = this;
590} 473}
591 474
592bool QUType_QString::canConvertFrom( QUObject *o, QUType *t ) 475bool QUType_QString::canConvertFrom( QUObject *o, QUType *t )
593{ 476{
594 if ( isEqual( t, &static_QUType_charstar ) || 477 if ( isEqual( t, &static_QUType_charstar ) ||
595 isEqual( t, &static_QUType_double ) || 478 isEqual( t, &static_QUType_double ) ||
596 isEqual( t, &static_QUType_float ) ||
597 isEqual( t, &static_QUType_int ) ) 479 isEqual( t, &static_QUType_int ) )
598 return TRUE; 480 return TRUE;
599 481
600 return t->canConvertTo( o, this ); 482 return t->canConvertTo( o, this );
601} 483}
602 484
603bool QUType_QString::canConvertTo( QUObject * /*o*/, QUType *t ) 485bool QUType_QString::canConvertTo( QUObject * /*o*/, QUType *t )
604{ 486{
605 return isEqual( t, &static_QUType_charstar ) || 487 return isEqual( t, &static_QUType_charstar ) ||
606 isEqual( t, &static_QUType_int ) || 488 isEqual( t, &static_QUType_int ) ||
607 isEqual( t, &static_QUType_double ) || 489 isEqual( t, &static_QUType_double );
608 isEqual( t, &static_QUType_float );
609} 490}
610 491
611bool QUType_QString::convertFrom( QUObject *o, QUType *t ) 492bool QUType_QString::convertFrom( QUObject *o, QUType *t )
612{ 493{
613 QString *str = 0; 494 QString *str = 0;
614 if ( isEqual( t, &static_QUType_charstar ) ) 495 if ( isEqual( t, &static_QUType_charstar ) )
615 str = new QString( o->payload.charstar.ptr ); 496 str = new QString( o->payload.charstar.ptr );
616 else if ( isEqual( t, &static_QUType_double ) ) 497 else if ( isEqual( t, &static_QUType_double ) )
617 str = new QString( QString::number( o->payload.d ) ); 498 str = new QString( QString::number( o->payload.d ) );
618 else if ( isEqual( t, &static_QUType_float ) )
619 str = new QString( QString::number( o->payload.f ) );
620 else if ( isEqual( t, &static_QUType_int ) ) 499 else if ( isEqual( t, &static_QUType_int ) )
621 str = new QString( QString::number( o->payload.i ) ); 500 str = new QString( QString::number( o->payload.i ) );
622 else 501 else
623 return t->convertTo( o, this ); 502 return t->convertTo( o, this );
624 503
625 o->type->clear( o ); 504 o->type->clear( o );
626 o->payload.ptr = str; 505 o->payload.ptr = str;
627 o->type = this; 506 o->type = this;
628 return TRUE; 507 return TRUE;
629} 508}
630 509
631bool QUType_QString::convertTo( QUObject *o, QUType *t ) 510bool QUType_QString::convertTo( QUObject *o, QUType *t )
632{ 511{
633 QString *str = (QString *)o->payload.ptr; 512 QString *str = (QString *)o->payload.ptr;
634 if ( isEqual( t, &static_QUType_charstar ) ) { 513 if ( isEqual( t, &static_QUType_charstar ) ) {
635 o->payload.charstar.ptr = qstrdup( str->local8Bit().data() ); 514 o->payload.charstar.ptr = qstrdup( str->local8Bit().data() );
636 o->payload.charstar.owner = TRUE; 515 o->payload.charstar.owner = TRUE;
637 o->type = &static_QUType_charstar; 516 o->type = &static_QUType_charstar;
638 } else if ( isEqual( t, &static_QUType_int ) ) { 517 } else if ( isEqual( t, &static_QUType_int ) ) {
639 o->payload.l = str->toLong(); 518 o->payload.l = str->toLong();
640 o->type = &static_QUType_int; 519 o->type = &static_QUType_int;
641 } else if ( isEqual( t, &static_QUType_double ) ) { 520 } else if ( isEqual( t, &static_QUType_double ) ) {
642 o->payload.d = str->toDouble(); 521 o->payload.d = str->toDouble();
643 o->type = &static_QUType_double; 522 o->type = &static_QUType_double;
644 } else if ( isEqual( t, &static_QUType_float ) ) {
645 o->payload.d = str->toFloat();
646 o->type = &static_QUType_float;
647 } else { 523 } else {
648 return FALSE; 524 return FALSE;
649 } 525 }
650 delete str; 526 delete str;
651 return TRUE; 527 return TRUE;
652} 528}
653 529
654int QUType_QString::serializeTo( QUObject *, QUBuffer * ) 530int QUType_QString::serializeTo( QUObject *, QUBuffer * )
655{ 531{
656 return 0; 532 return 0;
657} 533}
658 534
659int QUType_QString::serializeFrom( QUObject *, QUBuffer * ) 535int QUType_QString::serializeFrom( QUObject *, QUBuffer * )
660{ 536{
661 return 0; 537 return 0;
662} 538}
663 539
664void QUType_QString::clear( QUObject *o ) 540void QUType_QString::clear( QUObject *o )
665{ 541{
666 delete (QString*)o->payload.ptr; 542 delete (QString*)o->payload.ptr;
667 o->payload.ptr = 0; 543 o->payload.ptr = 0;
668} 544}
diff --git a/qmake/tools/qwaitcondition_unix.cpp b/qmake/tools/qwaitcondition_unix.cpp
index 99c1014..6684617 100644
--- a/qmake/tools/qwaitcondition_unix.cpp
+++ b/qmake/tools/qwaitcondition_unix.cpp
@@ -103,49 +103,49 @@ struct QWaitConditionPrivate {
103 avoided by, for example, doing something like this: 103 avoided by, for example, doing something like this:
104 104
105 \code 105 \code
106 QMutex mymutex; 106 QMutex mymutex;
107 QWaitCondition key_pressed; 107 QWaitCondition key_pressed;
108 int mycount=0; 108 int mycount=0;
109 109
110 // Worker thread code 110 // Worker thread code
111 for (;;) { 111 for (;;) {
112 key_pressed.wait(); // This is a QWaitCondition global variable 112 key_pressed.wait(); // This is a QWaitCondition global variable
113 mymutex.lock(); 113 mymutex.lock();
114 mycount++; 114 mycount++;
115 mymutex.unlock(); 115 mymutex.unlock();
116 do_something(); 116 do_something();
117 mymutex.lock(); 117 mymutex.lock();
118 mycount--; 118 mycount--;
119 mymutex.unlock(); 119 mymutex.unlock();
120 } 120 }
121 121
122 // Key reading thread code 122 // Key reading thread code
123 for (;;) { 123 for (;;) {
124 getchar(); 124 getchar();
125 mymutex.lock(); 125 mymutex.lock();
126 // Sleep until there are no busy worker threads 126 // Sleep until there are no busy worker threads
127 while( count > 0 ) { 127 while( mycount > 0 ) {
128 mymutex.unlock(); 128 mymutex.unlock();
129 sleep( 1 ); 129 sleep( 1 );
130 mymutex.lock(); 130 mymutex.lock();
131 } 131 }
132 mymutex.unlock(); 132 mymutex.unlock();
133 key_pressed.wakeAll(); 133 key_pressed.wakeAll();
134 } 134 }
135 \endcode 135 \endcode
136 136
137 The mutexes are necessary because the results of two threads 137 The mutexes are necessary because the results of two threads
138 attempting to change the value of the same variable simultaneously 138 attempting to change the value of the same variable simultaneously
139 are unpredictable. 139 are unpredictable.
140*/ 140*/
141 141
142/*! 142/*!
143 Constructs a new event signalling, i.e. wait condition, object. 143 Constructs a new event signalling, i.e. wait condition, object.
144*/ 144*/
145QWaitCondition::QWaitCondition() 145QWaitCondition::QWaitCondition()
146{ 146{
147 d = new QWaitConditionPrivate; 147 d = new QWaitConditionPrivate;
148 148
149 int ret = pthread_cond_init(&d->cond, NULL); 149 int ret = pthread_cond_init(&d->cond, NULL);
150 150
151#ifdef QT_CHECK_RANGE 151#ifdef QT_CHECK_RANGE
@@ -203,108 +203,113 @@ void QWaitCondition::wakeAll()
203 int ret = pthread_cond_broadcast(&d->cond); 203 int ret = pthread_cond_broadcast(&d->cond);
204 204
205#ifdef QT_CHECK_RANGE 205#ifdef QT_CHECK_RANGE
206 if (ret) 206 if (ret)
207 qWarning("Wait condition wakeAll failure: %s", strerror(ret)); 207 qWarning("Wait condition wakeAll failure: %s", strerror(ret));
208#endif 208#endif
209} 209}
210 210
211/*! 211/*!
212 Wait on the thread event object. The thread calling this will 212 Wait on the thread event object. The thread calling this will
213 block until either of these conditions is met: 213 block until either of these conditions is met:
214 \list 214 \list
215 \i Another thread signals it using wakeOne() or wakeAll(). This 215 \i Another thread signals it using wakeOne() or wakeAll(). This
216 function will return TRUE in this case. 216 function will return TRUE in this case.
217 \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the 217 \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the
218 default), then the wait will never timeout (the event must be 218 default), then the wait will never timeout (the event must be
219 signalled). This function will return FALSE if the wait timed 219 signalled). This function will return FALSE if the wait timed
220 out. 220 out.
221 \endlist 221 \endlist
222 222
223 \sa wakeOne(), wakeAll() 223 \sa wakeOne(), wakeAll()
224*/ 224*/
225bool QWaitCondition::wait(unsigned long time) 225bool QWaitCondition::wait(unsigned long time)
226{ 226{
227 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 227 pthread_mutex_t mutex;
228 pthread_mutex_init( &mutex, 0 );
229 pthread_mutex_lock( &mutex );
228 230
229 int ret; 231 int ret;
230 if (time != ULONG_MAX) { 232 if (time != ULONG_MAX) {
231 struct timeval tv; 233 struct timeval tv;
232 gettimeofday(&tv, 0); 234 gettimeofday(&tv, 0);
233 235
234 timespec ti; 236 timespec ti;
235 ti.tv_nsec = (tv.tv_usec * 1000) + (time % 1000) * 1000; 237 ti.tv_nsec = ( tv.tv_usec + ( time % 1000 ) * 1000 ) * 1000;
236 ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 ); 238 ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 );
237 ti.tv_nsec %= 1000000000; 239 ti.tv_nsec %= 1000000000;
238 240
239 ret = pthread_cond_timedwait(&d->cond, &mutex, &ti); 241 ret = pthread_cond_timedwait(&d->cond, &mutex, &ti);
240 } else 242 } else
241 ret = pthread_cond_wait(&d->cond, &mutex); 243 ret = pthread_cond_wait(&d->cond, &mutex);
242 244
243#ifdef QT_CHECK_RANGE 245#ifdef QT_CHECK_RANGE
244 if (ret && ret != ETIMEDOUT) 246 if (ret && ret != ETIMEDOUT)
245 qWarning("Wait condition wait failure: %s",strerror(ret)); 247 qWarning("Wait condition wait failure: %s",strerror(ret));
246#endif 248#endif
247 249
250 pthread_mutex_unlock( &mutex );
251 pthread_mutex_destroy( &mutex );
252
248 return (ret == 0); 253 return (ret == 0);
249} 254}
250 255
251/*! 256/*!
252 \overload 257 \overload
253 258
254 Release the locked \a mutex and wait on the thread event object. 259 Release the locked \a mutex and wait on the thread event object.
255 The \a mutex must be initially locked by the calling thread. If \a 260 The \a mutex must be initially locked by the calling thread. If \a
256 mutex is not in a locked state, this function returns immediately. 261 mutex is not in a locked state, this function returns immediately.
257 If \a mutex is a recursive mutex, this function returns 262 If \a mutex is a recursive mutex, this function returns
258 immediately. The \a mutex will be unlocked, and the calling thread 263 immediately. The \a mutex will be unlocked, and the calling thread
259 will block until either of these conditions is met: 264 will block until either of these conditions is met:
260 \list 265 \list
261 \i Another thread signals it using wakeOne() or wakeAll(). This 266 \i Another thread signals it using wakeOne() or wakeAll(). This
262 function will return TRUE in this case. 267 function will return TRUE in this case.
263 \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the 268 \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the
264 default), then the wait will never timeout (the event must be 269 default), then the wait will never timeout (the event must be
265 signalled). This function will return FALSE if the wait timed 270 signalled). This function will return FALSE if the wait timed
266 out. 271 out.
267 \endlist 272 \endlist
268 273
269 The mutex will be returned to the same locked state. This function 274 The mutex will be returned to the same locked state. This function
270 is provided to allow the atomic transition from the locked state 275 is provided to allow the atomic transition from the locked state
271 to the wait state. 276 to the wait state.
272 277
273 \sa wakeOne(), wakeAll() 278 \sa wakeOne(), wakeAll()
274*/ 279*/
275bool QWaitCondition::wait(QMutex *mutex, unsigned long time) 280bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
276{ 281{
277 if (! mutex) 282 if (! mutex)
278 return FALSE; 283 return FALSE;
279 284
280 if (mutex->d->type() == Q_MUTEX_RECURSIVE) { 285 if (mutex->d->type() == Q_MUTEX_RECURSIVE) {
281#ifdef QT_CHECK_RANGE 286#ifdef QT_CHECK_RANGE
282 qWarning("Wait condition warning: using recursive mutexes with\n" 287 qWarning("Wait condition warning: using recursive mutexes with\n"
283 " wait conditions is undefined!"); 288 " wait conditions is undefined!");
284#endif 289#endif
285 return FALSE; 290 return FALSE;
286 } 291 }
287 292
288 int ret; 293 int ret;
289 if (time != ULONG_MAX) { 294 if (time != ULONG_MAX) {
290 struct timeval tv; 295 struct timeval tv;
291 gettimeofday(&tv, 0); 296 gettimeofday(&tv, 0);
292 297
293 timespec ti; 298 timespec ti;
294 ti.tv_nsec = (tv.tv_usec * 1000) + (time % 1000) * 1000; 299 ti.tv_nsec = ( tv.tv_usec + ( time % 1000 ) * 1000 ) * 1000;
295 ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 ); 300 ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 );
296 ti.tv_nsec %= 1000000000; 301 ti.tv_nsec %= 1000000000;
297 302
298 ret = pthread_cond_timedwait(&d->cond, &mutex->d->handle, &ti); 303 ret = pthread_cond_timedwait(&d->cond, &mutex->d->handle, &ti);
299 } else 304 } else
300 ret = pthread_cond_wait(&d->cond, &mutex->d->handle); 305 ret = pthread_cond_wait(&d->cond, &mutex->d->handle);
301 306
302#ifdef QT_CHECK_RANGE 307#ifdef QT_CHECK_RANGE
303 if (ret && ret != ETIMEDOUT) 308 if (ret && ret != ETIMEDOUT)
304 qWarning("Wait condition wait failure: %s",strerror(ret)); 309 qWarning("Wait condition wait failure: %s",strerror(ret));
305#endif 310#endif
306 311
307 return (ret == 0); 312 return (ret == 0);
308} 313}
309 314
310#endif // QT_THREAD_SUPPORT 315#endif // QT_THREAD_SUPPORT