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::valueOf(static_cast<sal_Int32
>(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");
128 StdLstOut( "Copyright (C) 2000 - 2012 LibreOffice contributors.\n" );
132 StdLstOut( "DataVersion: " );
133 sprintf( buf
, "%d.%d\n\n",
134 RSCVERSION_ID
/ 100, RSCVERSION_ID
% 100 );
138 StdLstOut( "Command line: rsc [Switches] <Source File(s)>\n" );
139 StdLstOut( "Command line: rsc @<Command File>\n" );
140 StdLstOut( "-h shows this help.\n" );
141 StdLstOut( "-p No preprocessor.\n" );
142 StdLstOut( "-s Syntax analysis, creates .srs file\n");
143 StdLstOut( "-l Linker, links files created with rsc -s,\n" );
144 StdLstOut( " creates .rc file and .res file.\n" );
145 StdLstOut( "-r Prevents .res file.\n" );
146 StdLstOut( "-d Symbol definitions for the Preprocessor.\n" );
147 StdLstOut( "-i Include directives for the Preprocessor.\n" );
148 StdLstOut( "-presponse Use response file for Preprocessor.\n" );
149 StdLstOut( "-lg<language> Use a different language.\n" );
150 StdLstOut( "-fs=<filename> Name of the .res file.\n" );
151 StdLstOut( "-lip=<path> additional search path for system dependant files\n" );
152 StdLstOut( "-fp=<filename> Renaming of the .srs file.\n" );
153 StdLstOut( "-oil=<dir> Output directory for image list files\n" );
154 StdLstOut( "-sub<ENV>=<path> replace <path> by <ENV> in image list files\n" );
155 StdLstOut( "-BIGENDIAN Format of number values.\n" );
156 StdLstOut( "-LITTLEENDIAN Format of number values.\n" );
157 StdLstOut( "-SrsDefault Only write one language to srs file.\n" );
158 StdLstOut( "\nwhen creating multiple .res files in one pass, please give these\n" );
159 StdLstOut( "options in consecutive blocks:\n" );
160 StdLstOut( "-lg<language> -fs<filename> [-lip<path> [-lip<path>] ]\n" );
161 StdLstOut( "a new block begins when either -lg or -fs is used again.\n" );
165 StdLstErr( "Unknown switch <" );
166 StdLstErr( pMessage
);
171 StdLstErr( "Too many reference levels have been used (see Switch -RefDeep)." );
174 case ERR_CONT_INVALIDPOS
:
175 StdLstErr( "Internal error, Container class: invalid position." );
178 case ERR_CONT_INVALIDTYPE
:
179 StdLstErr( "Invalid type <" );
180 StdLstErr( pMessage
);
184 case ERR_ARRAY_INVALIDINDEX
:
185 StdLstErr( "Internal error, Array class: invalid index." );
188 case ERR_RSCINST_NOVARNAME
:
189 StdLstErr( "Internal error, invalid name of variable." );
193 StdLstErr( pMessage
);
197 StdLstErr( "Two global resources have the same identifier." );
201 StdLstErr( "Wrong type <" );
202 StdLstErr( pMessage
);
206 case ERR_NOVARIABLENAME
:
207 StdLstErr( "The variable <" );
208 StdLstErr( pMessage
);
209 StdLstErr( "> must not be used here." );
212 case ERR_RSCRANGE_OUTDEFSET
:
213 StdLstErr( "The used value is not in the expected domain." );
216 case ERR_USHORTRANGE
:
217 StdLstErr( "Value is <" );
218 StdLstErr( pMessage
);
219 StdLstErr( "> the allowed domain is from 0 up to 65535." );
223 StdLstErr( "Value is <" );
224 StdLstErr( pMessage
);
225 StdLstErr( "> the allowed domain is from 1 up to 32767." );
229 StdLstErr( "Default resource <" );
230 StdLstErr( pMessage
);
231 StdLstErr( "> not found." );
234 case ERR_REFNOTALLOWED
:
235 StdLstErr( "The use of a reference is not allowed." );
238 case ERR_COPYNOTALLOWED
:
239 StdLstErr( "The use of a default resource is not allowed." );
243 StdLstErr( "An identifier needs to be specified." );
246 case ERR_DOUBLEDEFINE
:
247 StdLstErr( "The symbol <" );
248 StdLstErr( pMessage
);
249 StdLstErr( "> is defined twice." );
252 case ERR_RSCINST_RESERVEDNAME
:
253 StdLstErr( "The symbol <" );
254 StdLstErr( pMessage
);
255 StdLstErr( "> is a reserved name." );
258 case ERR_ZERODIVISION
:
259 StdLstErr( "Attempt to divide by zero." );
263 StdLstErr( "Error in a #pragma statement." );
266 case ERR_DECLAREDEFINE
:
267 StdLstErr( "Error in the declaration part of the macro." );
271 StdLstErr( "type expected." );
275 StdLstErr( "The image(s) <" );
276 StdLstErr( pMessage
);
277 StdLstErr( "> could not be found." );
281 StdLstErr( "Sub resources should have an identifier < 256." );
285 StdLstErr( "Global resources should have an identifier >= 256." );
288 case WRN_SUBINMEMBER
:
289 StdLstErr( "Sub resources are ignored." );
293 StdLstErr( "Resources without name are ignored." );
296 case WRN_CONT_DOUBLEID
:
297 StdLstErr( "Two local resources have the same identifier." );
300 case WRN_STR_REFNOTFOUND
:
301 StdLstErr( "String reference <" );
302 StdLstErr( pMessage
);
303 StdLstErr( " > could not be resolved." );
306 case WRN_MGR_REFNOTFOUND
:
307 StdLstErr( "Reference <" );
308 StdLstErr( pMessage
);
309 StdLstErr( " > could not be resolved." );
314 StdLstErr( "\nMessage: " );
315 StdLstErr( pMessage
);
321 void RscError::ErrorFormat( const ERRTYPE
& rError
, RscTop
* pClass
,
328 pFI
->SetError( rError
);
330 StdErr( pFI
->GetLine() );
332 // Fehlerposition anzeigen
333 for( i
= 0; (i
+1) < pFI
->GetScanPos(); i
++ )
335 LstOut( " ^" ); //Zeilennummern beachten
340 sprintf( buf
, "%u", (unsigned int)rError
);
345 StdLstErr( pTC
->aFileTab
.Get( pFI
->GetFileIndex() )->aFileName
.getStr() );
346 StdLstErr( "\", line " );
347 sprintf( buf
, "%u", (unsigned int)pFI
->GetLineNo() );
351 if( rError
.IsError() )
352 StdLstErr( ": Error" );
354 StdLstErr( ": Warning" );
356 if( pClass
|| aId
.IsId() )
358 StdLstErr( " in the object (" );
361 StdLstErr( "Type: " );
362 StdLstErr( pHS
->getString( pClass
->GetId() ).getStr() );
367 StdLstErr( aId
.GetName().getStr() );
374 void RscError::Error( const ERRTYPE
& rError
, RscTop
* pClass
,
375 const RscId
& aId
, const char * pMessage
)
377 if( WRN_LOCALID
== rError
) // Keine Warning erzeugen
379 if( rError
.IsError() )
381 if( rError
.IsError() || rError
.IsWarning() ){
382 ErrorFormat( rError
, pClass
, aId
);
383 WriteError( rError
, pMessage
);
388 void RscError::FatalError( const ERRTYPE
& rError
, const RscId
&aId
,
389 const char * pMessage
)
391 if( ERR_USAGE
!= rError
){
393 ErrorFormat( rError
, NULL
, aId
);
394 WriteError( rError
, pMessage
);
395 StdLstErr( "\nTerminating compiler\n" );
398 WriteError( rError
, pMessage
);
403 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */