1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: erscerr.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_rsc.hxx"
36 #include <tools/rcid.h>
37 #include <rschash.hxx>
45 /*************************************************************************
47 |* ERRTYPE::operator = ;
50 |* Ersterstellung MM 25.09.91
51 |* Letzte Aenderung MM 25.09.91
53 *************************************************************************/
54 ERRTYPE
& ERRTYPE::operator = ( const ERRTYPE
& rError
)
57 if( rError
.IsError() || !IsWarning() )
58 nError
= rError
.nError
;
63 /*************************************************************************
65 |* RscError::StdOut();
68 |* Ersterstellung MM 06.05.91
69 |* Letzte Aenderung MM 06.05.91
71 *************************************************************************/
72 void RscError::StdOut( const char * pStr
, const RscVerbosity _verbosityLevel
)
74 if ( m_verbosity
>= _verbosityLevel
)
83 /*************************************************************************
85 |* RscError::StdErr();
88 |* Ersterstellung PL 11/07/2001
89 |* Letzte Aenderung PL 11/07/2001
91 *************************************************************************/
92 void RscError::StdErr( const char * pStr
)
96 fprintf( stderr
, "%s", pStr
);
100 /*************************************************************************
102 |* RscError::LstOut();
105 |* Ersterstellung MM 06.05.91
106 |* Letzte Aenderung MM 06.05.91
108 *************************************************************************/
109 void RscError::LstOut( const char * pStr
){
110 if( fListing
&& pStr
)
111 fprintf( fListing
, "%s", pStr
);
114 /*************************************************************************
116 |* RscError::StdLstOut();
119 |* Ersterstellung MM 06.05.91
120 |* Letzte Aenderung MM 06.05.91
122 *************************************************************************/
123 void RscError::StdLstOut( const char * pStr
){
128 /*************************************************************************
130 |* RscError::StdLstErr();
133 |* Ersterstellung PL 11/07/2001
134 |* Letzte Aenderung PL 11/07/2001
136 *************************************************************************/
137 void RscError::StdLstErr( const char * pStr
){
142 /*************************************************************************
144 |* RscError::WriteError();
147 |* Ersterstellung MM 06.05.91
148 |* Letzte Aenderung MM 06.05.91
150 *************************************************************************/
151 void RscError::WriteError( const ERRTYPE
& rError
, const char * pMessage
)
158 StdLstErr( ByteString::CreateFromInt32( nErrors
).GetBuffer() );
160 StdLstErr( ByteString::CreateFromInt32( (nErrors
-1) ).GetBuffer() );
161 StdLstErr( " Error" );
162 StdLstErr( " found!!" );
166 case ERR_UNKNOWN_METHOD
:
167 StdLstErr( "The used type is not allowed." );
171 StdLstErr( "This file <" );
172 StdLstErr( pMessage
);
173 StdLstErr( "> cannot be opened." );
177 StdLstErr( "rename <" );
178 StdLstErr( pMessage
);
179 StdLstErr( "> s not possible." );
183 StdLstErr( "Wrong file <" );
184 StdLstErr( pMessage
);
185 StdLstErr( "> length." );
189 StdLstErr( "Wrong file type <" );
190 StdLstErr( pMessage
);
195 StdLstErr( "Character: '\\xxx'; The value xxx is greater than 255.");
199 StdLstErr( "Internal error, instance invalid.");
204 StdLstErr( "Input file was not specified.\n");
206 StdLstOut( "Copyright (C) 1990-92 STAR DIVISION GmbH\n" );
210 StdLstOut( "DataVersion: " );
211 sprintf( buf
, "%d.%d\n\n",
212 RSCVERSION_ID
/ 100, RSCVERSION_ID
% 100 );
216 StdLstOut( "Command line: rsc [Switches] <Source File(s)>\n" );
217 StdLstOut( "Command line: rsc @<Command File>\n" );
218 StdLstOut( "-h shows this help.\n" );
219 StdLstOut( "-p No Preprocessor.\n" );
220 StdLstOut( "-s Syntax analysis, creates .srs file\n");
221 StdLstOut( "-l Linker, links files created with rsc -s,\n" );
222 StdLstOut( " creates .rc file and .res file.\n" );
223 StdLstOut( "-r Prevents .res file.\n" );
224 StdLstOut( "-d Symbol definitions for the Preprocessor.\n" );
225 StdLstOut( "-i Include directives for the Preprocessor.\n" );
226 StdLstOut( "-presponse Use response file for Preprocessor.\n" );
227 StdLstOut( "-lg<language> Use a different language.\n" );
228 StdLstOut( "-pp=<filename> Use a different Preprocessor.\n" );
229 StdLstOut( "-rsc2=<filename> Specify the location for rsc2.\n" );
230 StdLstOut( "No longer existent: -rc<filename> Use a different system resource compiler.\n" );
231 StdLstOut( "-fs=<filename> Name of the .res file.\n" );
232 StdLstOut( "-lip=<path> additional search path for system dependant files\n" );
233 StdLstOut( "-fp=<filename> Renaming of the .srs file.\n" );
234 StdLstOut( "-fl=<filename> Listing file.\n" );
235 StdLstOut( "-fh=<filename> Header file.\n" );
236 StdLstOut( "-fc=<filename> Code file.\n" );
237 StdLstOut( "-ft=<filename> Touch a file when done in rsc2 (for dependencies)\n" );
238 StdLstOut( "-fr=<filename> Ressource constructor .cxx-file.\n" );
239 StdLstOut( "-fx=<filename> Name of .src-file.\n" );
240 StdLstOut( "-oil=<dir> Output directory for image list files\n" );
241 StdLstOut( "-r<ENV>=<path> replace <path> by <ENV> in image list files\n" );
242 StdLstOut( "-CHARSET_... Convert to this character set.\n" );
243 StdLstOut( "-BIGENDIAN Format of number values.\n" );
244 StdLstOut( "-LITTLEENDIAN Format of number values.\n" );
245 StdLstOut( "-SMART Generate smart names (cxx, hxx).\n" );
246 StdLstOut( "-SrsDefault Only write one language to srs file.\n" );
247 StdLstOut( "\nwhen creating multiple .res files in one pass, please give these\n" );
248 StdLstOut( "options in consecutive blocks:\n" );
249 StdLstOut( "-lg<language> -fs<filename> [-lip<path> [-lip<path>] ]\n" );
250 StdLstOut( "a new block begins when either -lg or -fs is used again.\n" );
254 StdLstErr( "Unknown switch <" );
255 StdLstErr( pMessage
);
260 StdLstErr( "Too many reference levels have been used (see Switch -RefDeep)." );
263 case ERR_CONT_INVALIDPOS
:
264 StdLstErr( "Internal error, Container class: invalid position." );
267 case ERR_CONT_INVALIDTYPE
:
268 StdLstErr( "Invalid type <" );
269 StdLstErr( pMessage
);
273 case ERR_ARRAY_INVALIDINDEX
:
274 StdLstErr( "Internal error, Array class: invalid index." );
277 case ERR_RSCINST_NOVARNAME
:
278 StdLstErr( "Internal error, invalid name of variable." );
282 StdLstErr( pMessage
);
286 StdLstErr( "Two global resources have the same identifier." );
290 StdLstErr( "Wrong type <" );
291 StdLstErr( pMessage
);
295 case ERR_NOVARIABLENAME
:
296 StdLstErr( "The variable <" );
297 StdLstErr( pMessage
);
298 StdLstErr( "> must not be used here." );
301 case ERR_RSCRANGE_OUTDEFSET
:
302 StdLstErr( "The used value is not in the expected domain." );
305 case ERR_USHORTRANGE
:
306 StdLstErr( "Value is <" );
307 StdLstErr( pMessage
);
308 StdLstErr( "> the allowed domain is from 0 up to 65535." );
312 StdLstErr( "Value is <" );
313 StdLstErr( pMessage
);
314 StdLstErr( "> the allowed domain is from 1 up to 32767." );
318 StdLstErr( "Default resource <" );
319 StdLstErr( pMessage
);
320 StdLstErr( "> not found." );
323 case ERR_REFNOTALLOWED
:
324 StdLstErr( "The use of a reference is not allowed." );
327 case ERR_COPYNOTALLOWED
:
328 StdLstErr( "The use of a default resource is not allowed." );
332 StdLstErr( "An identifier needs to be specified." );
335 case ERR_DOUBLEDEFINE
:
336 StdLstErr( "The symbol <" );
337 StdLstErr( pMessage
);
338 StdLstErr( "> is defined twice." );
341 case ERR_RSCINST_RESERVEDNAME
:
342 StdLstErr( "The symbol <" );
343 StdLstErr( pMessage
);
344 StdLstErr( "> is a reserved name." );
347 case ERR_ZERODIVISION
:
348 StdLstErr( "Attempt to divide by zero." );
352 StdLstErr( "Error in a #pragma statement." );
355 case ERR_DECLAREDEFINE
:
356 StdLstErr( "Error in the declaration part of the macro." );
360 StdLstErr( "type expected." );
364 StdLstErr( "The image(s) <" );
365 StdLstErr( pMessage
);
366 StdLstErr( "> could not be found." );
369 /****************** W A R N I N G S **************************************/
371 StdLstErr( "Sub resources should have an identifier < 256." );
375 StdLstErr( "Global resources should have an identifier >= 256." );
378 case WRN_SUBINMEMBER
:
379 StdLstErr( "Sub resources are ignored." );
383 StdLstErr( "Resources without name are ignored." );
386 case WRN_CONT_DOUBLEID
:
387 StdLstErr( "Two local resources have the same identifier." );
390 case WRN_STR_REFNOTFOUND
:
391 StdLstErr( "String reference <" );
392 StdLstErr( pMessage
);
393 StdLstErr( " > could not be resolved." );
396 case WRN_MGR_REFNOTFOUND
:
397 StdLstErr( "Reference <" );
398 StdLstErr( pMessage
);
399 StdLstErr( " > could not be resolved." );
404 StdLstErr( "\nMessage: " );
405 StdLstErr( pMessage
);
411 /*************************************************************************
416 |* Ersterstellung MM 06.05.91
417 |* Letzte Aenderung MM 06.05.91
419 *************************************************************************/
420 void RscError::ErrorFormat( const ERRTYPE
& rError
, RscTop
* pClass
,
427 pFI
->SetError( rError
);
429 StdErr( pFI
->GetLine() );
431 // Fehlerposition anzeigen
432 for( i
= 0; (i
+1) < pFI
->GetScanPos(); i
++ )
434 LstOut( " ^" ); //Zeilennummern beachten
439 sprintf( buf
, "%u", (unsigned int)rError
);
444 StdLstErr( pTC
->aFileTab
.Get( pFI
->GetFileIndex() )->aFileName
.GetBuffer() );
445 StdLstErr( "\", line " );
446 sprintf( buf
, "%u", (unsigned int)pFI
->GetLineNo() );
450 if( rError
.IsError() )
451 StdLstErr( ": Error" );
453 StdLstErr( ": Warning" );
455 if( pClass
|| aId
.IsId() )
457 StdLstErr( " in the object (" );
460 StdLstErr( "Type: " );
461 StdLstErr( pHS
->getString( pClass
->GetId() ).getStr() );
466 StdLstErr( aId
.GetName().GetBuffer() );
473 /*************************************************************************
478 |* Ersterstellung MM 06.05.91
479 |* Letzte Aenderung MM 06.05.91
481 *************************************************************************/
482 void RscError::Error( const ERRTYPE
& rError
, RscTop
* pClass
,
483 const RscId
& aId
, const char * pMessage
)
485 if( WRN_LOCALID
== rError
) // Keine Warning erzeugen
487 if( rError
.IsError() )
489 if( rError
.IsError() || rError
.IsWarning() ){
490 ErrorFormat( rError
, pClass
, aId
);
491 WriteError( rError
, pMessage
);
496 /*************************************************************************
498 |* RscError::FatalError();
501 |* Ersterstellung MM 06.05.91
502 |* Letzte Aenderung MM 06.05.91
504 *************************************************************************/
505 void RscError::FatalError( const ERRTYPE
& rError
, const RscId
&aId
,
506 const char * pMessage
)
508 if( ERR_USAGE
!= rError
){
510 ErrorFormat( rError
, NULL
, aId
);
511 WriteError( rError
, pMessage
);
512 StdLstErr( "\nTerminating compiler\n" );
515 WriteError( rError
, pMessage
);