1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <tools/rcid.h>
24 #include <rschash.hxx>
32 ERRTYPE
& ERRTYPE::operator = ( const ERRTYPE
& rError
)
35 if( rError
.IsError() || !IsWarning() )
36 nError
= rError
.nError
;
41 void RscError::StdOut( const char * pStr
, const RscVerbosity _verbosityLevel
)
43 if ( m_verbosity
>= _verbosityLevel
)
52 void RscError::StdErr( const char * pStr
)
55 fprintf( stderr
, "%s", pStr
);
58 void RscError::LstOut( const char * pStr
){
59 if( fListing
&& pStr
)
60 fprintf( fListing
, "%s", pStr
);
63 void RscError::StdLstOut( const char * pStr
){
68 void RscError::StdLstErr( const char * pStr
){
73 void RscError::WriteError( const ERRTYPE
& rError
, const char * pMessage
)
80 StdLstErr(OString::number(nErrors
).getStr());
82 StdLstErr(OString::number(nErrors
-1).getStr());
83 StdLstErr( " Error" );
84 StdLstErr( " found!!" );
88 case ERR_UNKNOWN_METHOD
:
89 StdLstErr( "The used type is not allowed." );
93 StdLstErr( "This file <" );
94 StdLstErr( pMessage
);
95 StdLstErr( "> cannot be opened." );
99 StdLstErr( "rename <" );
100 StdLstErr( pMessage
);
101 StdLstErr( "> s not possible." );
105 StdLstErr( "Wrong file <" );
106 StdLstErr( pMessage
);
107 StdLstErr( "> length." );
111 StdLstErr( "Wrong file type <" );
112 StdLstErr( pMessage
);
117 StdLstErr( "Character: '\\xxx'; The value xxx is greater than 255.");
121 StdLstErr( "Internal error, instance invalid.");
126 StdLstErr( "Input file was not specified.\n");
129 StdLstOut( "Copyright (C) 2000 - 2012 LibreOffice contributors.\n" );
133 StdLstOut( "DataVersion: " );
134 sprintf( buf
, "%d.%d\n\n",
135 RSCVERSION_ID
/ 100, RSCVERSION_ID
% 100 );
139 StdLstOut( "Command line: rsc [Switches] <Source File(s)>\n" );
140 StdLstOut( "Command line: rsc @<Command File>\n" );
141 StdLstOut( "-h shows this help.\n" );
142 StdLstOut( "-p No preprocessor.\n" );
143 StdLstOut( "-s Syntax analysis, creates .srs file\n");
144 StdLstOut( "-l Linker, links files created with rsc -s,\n" );
145 StdLstOut( " creates .rc file and .res file.\n" );
146 StdLstOut( "-r Prevents .res file.\n" );
147 StdLstOut( "-d Symbol definitions for the Preprocessor.\n" );
148 StdLstOut( "-i Include directives for the Preprocessor.\n" );
149 StdLstOut( "-presponse Use response file for Preprocessor.\n" );
150 StdLstOut( "-lg<language> Use a different language.\n" );
151 StdLstOut( "-fs=<filename> Name of the .res file.\n" );
152 StdLstOut( "-lip=<path> additional search path for system dependent files\n" );
153 StdLstOut( "-fp=<filename> Renaming of the .srs file.\n" );
154 StdLstOut( "-oil=<dir> Output directory for image list files\n" );
155 StdLstOut( "-sub<ENV>=<path> replace <path> by <ENV> in image list files\n" );
156 StdLstOut( "-BIGENDIAN Format of number values.\n" );
157 StdLstOut( "-LITTLEENDIAN Format of number values.\n" );
158 StdLstOut( "-SrsDefault Only write one language to srs file.\n" );
159 StdLstOut( "\nwhen creating multiple .res files in one pass, please give these\n" );
160 StdLstOut( "options in consecutive blocks:\n" );
161 StdLstOut( "-lg<language> -fs<filename> [-lip<path> [-lip<path>] ]\n" );
162 StdLstOut( "a new block begins when either -lg or -fs is used again.\n" );
166 StdLstErr( "Unknown switch <" );
167 StdLstErr( pMessage
);
172 StdLstErr( "Too many reference levels have been used (see Switch -RefDeep)." );
175 case ERR_CONT_INVALIDPOS
:
176 StdLstErr( "Internal error, Container class: invalid position." );
179 case ERR_CONT_INVALIDTYPE
:
180 StdLstErr( "Invalid type <" );
181 StdLstErr( pMessage
);
185 case ERR_ARRAY_INVALIDINDEX
:
186 StdLstErr( "Internal error, Array class: invalid index." );
189 case ERR_RSCINST_NOVARNAME
:
190 StdLstErr( "Internal error, invalid name of variable." );
194 StdLstErr( pMessage
);
198 StdLstErr( "Two global resources have the same identifier." );
202 StdLstErr( "Wrong type <" );
203 StdLstErr( pMessage
);
207 case ERR_NOVARIABLENAME
:
208 StdLstErr( "The variable <" );
209 StdLstErr( pMessage
);
210 StdLstErr( "> must not be used here." );
213 case ERR_RSCRANGE_OUTDEFSET
:
214 StdLstErr( "The used value is not in the expected domain." );
217 case ERR_USHORTRANGE
:
218 StdLstErr( "Value is <" );
219 StdLstErr( pMessage
);
220 StdLstErr( "> the allowed domain is from 0 up to 65535." );
224 StdLstErr( "Value is <" );
225 StdLstErr( pMessage
);
226 StdLstErr( "> the allowed domain is from 1 up to 32767." );
230 StdLstErr( "Default resource <" );
231 StdLstErr( pMessage
);
232 StdLstErr( "> not found." );
235 case ERR_REFNOTALLOWED
:
236 StdLstErr( "The use of a reference is not allowed." );
239 case ERR_COPYNOTALLOWED
:
240 StdLstErr( "The use of a default resource is not allowed." );
244 StdLstErr( "An identifier needs to be specified." );
247 case ERR_DOUBLEDEFINE
:
248 StdLstErr( "The symbol <" );
249 StdLstErr( pMessage
);
250 StdLstErr( "> is defined twice." );
253 case ERR_RSCINST_RESERVEDNAME
:
254 StdLstErr( "The symbol <" );
255 StdLstErr( pMessage
);
256 StdLstErr( "> is a reserved name." );
259 case ERR_ZERODIVISION
:
260 StdLstErr( "Attempt to divide by zero." );
264 StdLstErr( "Error in a #pragma statement." );
267 case ERR_DECLAREDEFINE
:
268 StdLstErr( "Error in the declaration part of the macro." );
272 StdLstErr( "type expected." );
276 StdLstErr( "The image(s) <" );
277 StdLstErr( pMessage
);
278 StdLstErr( "> could not be found." );
282 StdLstErr( "Sub resources should have an identifier < 256." );
286 StdLstErr( "Global resources should have an identifier >= 256." );
289 case WRN_SUBINMEMBER
:
290 StdLstErr( "Sub resources are ignored." );
294 StdLstErr( "Resources without name are ignored." );
297 case WRN_CONT_DOUBLEID
:
298 StdLstErr( "Two local resources have the same identifier." );
301 case WRN_STR_REFNOTFOUND
:
302 StdLstErr( "String reference <" );
303 StdLstErr( pMessage
);
304 StdLstErr( " > could not be resolved." );
307 case WRN_MGR_REFNOTFOUND
:
308 StdLstErr( "Reference <" );
309 StdLstErr( pMessage
);
310 StdLstErr( " > could not be resolved." );
315 StdLstErr( "\nMessage: " );
316 StdLstErr( pMessage
);
322 void RscError::ErrorFormat( const ERRTYPE
& rError
, RscTop
* pClass
,
329 pFI
->SetError( rError
);
331 StdErr( pFI
->GetLine() );
333 // Fehlerposition anzeigen
334 for( i
= 0; (i
+1) < pFI
->GetScanPos(); i
++ )
336 LstOut( " ^" ); //Zeilennummern beachten
341 sprintf( buf
, "%u", (unsigned int)rError
);
346 StdLstErr( pTC
->aFileTab
.Get( pFI
->GetFileIndex() )->aFileName
.getStr() );
347 StdLstErr( "\", line " );
348 sprintf( buf
, "%u", (unsigned int)pFI
->GetLineNo() );
352 if( rError
.IsError() )
353 StdLstErr( ": Error" );
355 StdLstErr( ": Warning" );
357 if( pClass
|| aId
.IsId() )
359 StdLstErr( " in the object (" );
362 StdLstErr( "Type: " );
363 StdLstErr( pHS
->getString( pClass
->GetId() ).getStr() );
368 StdLstErr( aId
.GetName().getStr() );
375 void RscError::Error( const ERRTYPE
& rError
, RscTop
* pClass
,
376 const RscId
& aId
, const char * pMessage
)
378 if( WRN_LOCALID
== rError
) // Keine Warning erzeugen
380 if( rError
.IsError() )
382 if( rError
.IsError() || rError
.IsWarning() ){
383 ErrorFormat( rError
, pClass
, aId
);
384 WriteError( rError
, pMessage
);
389 void RscError::FatalError( const ERRTYPE
& rError
, const RscId
&aId
,
390 const char * pMessage
)
392 if( ERR_USAGE
!= rError
){
394 ErrorFormat( rError
, NULL
, aId
);
395 WriteError( rError
, pMessage
);
396 StdLstErr( "\nTerminating compiler\n" );
399 WriteError( rError
, pMessage
);
404 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */