1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
33 #include <tools/rcid.h>
34 #include <rschash.hxx>
42 /*************************************************************************
44 |* ERRTYPE::operator = ;
47 |* Ersterstellung MM 25.09.91
48 |* Letzte Aenderung MM 25.09.91
50 *************************************************************************/
51 ERRTYPE
& ERRTYPE::operator = ( const ERRTYPE
& rError
)
54 if( rError
.IsError() || !IsWarning() )
55 nError
= rError
.nError
;
60 /*************************************************************************
62 |* RscError::StdOut();
65 |* Ersterstellung MM 06.05.91
66 |* Letzte Aenderung MM 06.05.91
68 *************************************************************************/
69 void RscError::StdOut( const char * pStr
, const RscVerbosity _verbosityLevel
)
71 if ( m_verbosity
>= _verbosityLevel
)
80 /*************************************************************************
82 |* RscError::StdErr();
85 |* Ersterstellung PL 11/07/2001
86 |* Letzte Aenderung PL 11/07/2001
88 *************************************************************************/
89 void RscError::StdErr( const char * pStr
)
92 fprintf( stderr
, "%s", pStr
);
95 /*************************************************************************
97 |* RscError::LstOut();
100 |* Ersterstellung MM 06.05.91
101 |* Letzte Aenderung MM 06.05.91
103 *************************************************************************/
104 void RscError::LstOut( const char * pStr
){
105 if( fListing
&& pStr
)
106 fprintf( fListing
, "%s", pStr
);
109 /*************************************************************************
111 |* RscError::StdLstOut();
114 |* Ersterstellung MM 06.05.91
115 |* Letzte Aenderung MM 06.05.91
117 *************************************************************************/
118 void RscError::StdLstOut( const char * pStr
){
123 /*************************************************************************
125 |* RscError::StdLstErr();
128 |* Ersterstellung PL 11/07/2001
129 |* Letzte Aenderung PL 11/07/2001
131 *************************************************************************/
132 void RscError::StdLstErr( const char * pStr
){
137 /*************************************************************************
139 |* RscError::WriteError();
142 |* Ersterstellung MM 06.05.91
143 |* Letzte Aenderung MM 06.05.91
145 *************************************************************************/
146 void RscError::WriteError( const ERRTYPE
& rError
, const char * pMessage
)
153 StdLstErr( ByteString::CreateFromInt32( nErrors
).GetBuffer() );
155 StdLstErr( ByteString::CreateFromInt32( (nErrors
-1) ).GetBuffer() );
156 StdLstErr( " Error" );
157 StdLstErr( " found!!" );
161 case ERR_UNKNOWN_METHOD
:
162 StdLstErr( "The used type is not allowed." );
166 StdLstErr( "This file <" );
167 StdLstErr( pMessage
);
168 StdLstErr( "> cannot be opened." );
172 StdLstErr( "rename <" );
173 StdLstErr( pMessage
);
174 StdLstErr( "> s not possible." );
178 StdLstErr( "Wrong file <" );
179 StdLstErr( pMessage
);
180 StdLstErr( "> length." );
184 StdLstErr( "Wrong file type <" );
185 StdLstErr( pMessage
);
190 StdLstErr( "Character: '\\xxx'; The value xxx is greater than 255.");
194 StdLstErr( "Internal error, instance invalid.");
199 StdLstErr( "Input file was not specified.\n");
201 StdLstOut( "Copyright (C) 2000, 2010 Oracle and/or its affiliates.\n" );
205 StdLstOut( "DataVersion: " );
206 sprintf( buf
, "%d.%d\n\n",
207 RSCVERSION_ID
/ 100, RSCVERSION_ID
% 100 );
211 StdLstOut( "Command line: rsc [Switches] <Source File(s)>\n" );
212 StdLstOut( "Command line: rsc @<Command File>\n" );
213 StdLstOut( "-h shows this help.\n" );
214 StdLstOut( "-p No Preprocessor.\n" );
215 StdLstOut( "-s Syntax analysis, creates .srs file\n");
216 StdLstOut( "-l Linker, links files created with rsc -s,\n" );
217 StdLstOut( " creates .rc file and .res file.\n" );
218 StdLstOut( "-r Prevents .res file.\n" );
219 StdLstOut( "-d Symbol definitions for the Preprocessor.\n" );
220 StdLstOut( "-i Include directives for the Preprocessor.\n" );
221 StdLstOut( "-presponse Use response file for Preprocessor.\n" );
222 StdLstOut( "-lg<language> Use a different language.\n" );
223 StdLstOut( "-pp=<filename> Use a different Preprocessor.\n" );
224 StdLstOut( "-rsc2=<filename> Specify the location for rsc2.\n" );
225 StdLstOut( "No longer existent: -rc<filename> Use a different system resource compiler.\n" );
226 StdLstOut( "-fs=<filename> Name of the .res file.\n" );
227 StdLstOut( "-lip=<path> additional search path for system dependant files\n" );
228 StdLstOut( "-fp=<filename> Renaming of the .srs file.\n" );
229 StdLstOut( "-fl=<filename> Listing file.\n" );
230 StdLstOut( "-fh=<filename> Header file.\n" );
231 StdLstOut( "-fc=<filename> Code file.\n" );
232 StdLstOut( "-ft=<filename> Touch a file when done in rsc2 (for dependencies)\n" );
233 StdLstOut( "-fr=<filename> Ressource constructor .cxx-file.\n" );
234 StdLstOut( "-fx=<filename> Name of .src-file.\n" );
235 StdLstOut( "-oil=<dir> Output directory for image list files\n" );
236 StdLstOut( "-r<ENV>=<path> replace <path> by <ENV> in image list files\n" );
237 StdLstOut( "-CHARSET_... Convert to this character set.\n" );
238 StdLstOut( "-BIGENDIAN Format of number values.\n" );
239 StdLstOut( "-LITTLEENDIAN Format of number values.\n" );
240 StdLstOut( "-SMART Generate smart names (cxx, hxx).\n" );
241 StdLstOut( "-SrsDefault Only write one language to srs file.\n" );
242 StdLstOut( "\nwhen creating multiple .res files in one pass, please give these\n" );
243 StdLstOut( "options in consecutive blocks:\n" );
244 StdLstOut( "-lg<language> -fs<filename> [-lip<path> [-lip<path>] ]\n" );
245 StdLstOut( "a new block begins when either -lg or -fs is used again.\n" );
249 StdLstErr( "Unknown switch <" );
250 StdLstErr( pMessage
);
255 StdLstErr( "Too many reference levels have been used (see Switch -RefDeep)." );
258 case ERR_CONT_INVALIDPOS
:
259 StdLstErr( "Internal error, Container class: invalid position." );
262 case ERR_CONT_INVALIDTYPE
:
263 StdLstErr( "Invalid type <" );
264 StdLstErr( pMessage
);
268 case ERR_ARRAY_INVALIDINDEX
:
269 StdLstErr( "Internal error, Array class: invalid index." );
272 case ERR_RSCINST_NOVARNAME
:
273 StdLstErr( "Internal error, invalid name of variable." );
277 StdLstErr( pMessage
);
281 StdLstErr( "Two global resources have the same identifier." );
285 StdLstErr( "Wrong type <" );
286 StdLstErr( pMessage
);
290 case ERR_NOVARIABLENAME
:
291 StdLstErr( "The variable <" );
292 StdLstErr( pMessage
);
293 StdLstErr( "> must not be used here." );
296 case ERR_RSCRANGE_OUTDEFSET
:
297 StdLstErr( "The used value is not in the expected domain." );
300 case ERR_USHORTRANGE
:
301 StdLstErr( "Value is <" );
302 StdLstErr( pMessage
);
303 StdLstErr( "> the allowed domain is from 0 up to 65535." );
307 StdLstErr( "Value is <" );
308 StdLstErr( pMessage
);
309 StdLstErr( "> the allowed domain is from 1 up to 32767." );
313 StdLstErr( "Default resource <" );
314 StdLstErr( pMessage
);
315 StdLstErr( "> not found." );
318 case ERR_REFNOTALLOWED
:
319 StdLstErr( "The use of a reference is not allowed." );
322 case ERR_COPYNOTALLOWED
:
323 StdLstErr( "The use of a default resource is not allowed." );
327 StdLstErr( "An identifier needs to be specified." );
330 case ERR_DOUBLEDEFINE
:
331 StdLstErr( "The symbol <" );
332 StdLstErr( pMessage
);
333 StdLstErr( "> is defined twice." );
336 case ERR_RSCINST_RESERVEDNAME
:
337 StdLstErr( "The symbol <" );
338 StdLstErr( pMessage
);
339 StdLstErr( "> is a reserved name." );
342 case ERR_ZERODIVISION
:
343 StdLstErr( "Attempt to divide by zero." );
347 StdLstErr( "Error in a #pragma statement." );
350 case ERR_DECLAREDEFINE
:
351 StdLstErr( "Error in the declaration part of the macro." );
355 StdLstErr( "type expected." );
359 StdLstErr( "The image(s) <" );
360 StdLstErr( pMessage
);
361 StdLstErr( "> could not be found." );
364 /****************** W A R N I N G S **************************************/
366 StdLstErr( "Sub resources should have an identifier < 256." );
370 StdLstErr( "Global resources should have an identifier >= 256." );
373 case WRN_SUBINMEMBER
:
374 StdLstErr( "Sub resources are ignored." );
378 StdLstErr( "Resources without name are ignored." );
381 case WRN_CONT_DOUBLEID
:
382 StdLstErr( "Two local resources have the same identifier." );
385 case WRN_STR_REFNOTFOUND
:
386 StdLstErr( "String reference <" );
387 StdLstErr( pMessage
);
388 StdLstErr( " > could not be resolved." );
391 case WRN_MGR_REFNOTFOUND
:
392 StdLstErr( "Reference <" );
393 StdLstErr( pMessage
);
394 StdLstErr( " > could not be resolved." );
399 StdLstErr( "\nMessage: " );
400 StdLstErr( pMessage
);
406 /*************************************************************************
411 |* Ersterstellung MM 06.05.91
412 |* Letzte Aenderung MM 06.05.91
414 *************************************************************************/
415 void RscError::ErrorFormat( const ERRTYPE
& rError
, RscTop
* pClass
,
422 pFI
->SetError( rError
);
424 StdErr( pFI
->GetLine() );
426 // Fehlerposition anzeigen
427 for( i
= 0; (i
+1) < pFI
->GetScanPos(); i
++ )
429 LstOut( " ^" ); //Zeilennummern beachten
434 sprintf( buf
, "%u", (unsigned int)rError
);
439 StdLstErr( pTC
->aFileTab
.Get( pFI
->GetFileIndex() )->aFileName
.GetBuffer() );
440 StdLstErr( "\", line " );
441 sprintf( buf
, "%u", (unsigned int)pFI
->GetLineNo() );
445 if( rError
.IsError() )
446 StdLstErr( ": Error" );
448 StdLstErr( ": Warning" );
450 if( pClass
|| aId
.IsId() )
452 StdLstErr( " in the object (" );
455 StdLstErr( "Type: " );
456 StdLstErr( pHS
->getString( pClass
->GetId() ).getStr() );
461 StdLstErr( aId
.GetName().GetBuffer() );
468 /*************************************************************************
473 |* Ersterstellung MM 06.05.91
474 |* Letzte Aenderung MM 06.05.91
476 *************************************************************************/
477 void RscError::Error( const ERRTYPE
& rError
, RscTop
* pClass
,
478 const RscId
& aId
, const char * pMessage
)
480 if( WRN_LOCALID
== rError
) // Keine Warning erzeugen
482 if( rError
.IsError() )
484 if( rError
.IsError() || rError
.IsWarning() ){
485 ErrorFormat( rError
, pClass
, aId
);
486 WriteError( rError
, pMessage
);
491 /*************************************************************************
493 |* RscError::FatalError();
496 |* Ersterstellung MM 06.05.91
497 |* Letzte Aenderung MM 06.05.91
499 *************************************************************************/
500 void RscError::FatalError( const ERRTYPE
& rError
, const RscId
&aId
,
501 const char * pMessage
)
503 if( ERR_USAGE
!= rError
){
505 ErrorFormat( rError
, NULL
, aId
);
506 WriteError( rError
, pMessage
);
507 StdLstErr( "\nTerminating compiler\n" );
510 WriteError( rError
, pMessage
);