1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 *   Copyright (C) 1998-2011, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *
9 *******************************************************************************
10 *
11 * File error.c
12 *
13 * Modification History:
14 *
15 *   Date        Name        Description
16 *   05/28/99    stephen     Creation.
17 *******************************************************************************
18 */
19 
20 #include <stdarg.h>
21 #include <stdio.h>
22 #include "cstring.h"
23 #include "errmsg.h"
24 #include "toolutil.h"
25 
error(uint32_t linenumber,const char * msg,...)26 U_CFUNC void error(uint32_t linenumber, const char *msg, ...)
27 {
28     va_list va;
29 
30     va_start(va, msg);
31     fprintf(stderr, "%s:%u: ", gCurrentFileName, (int)linenumber);
32     vfprintf(stderr, msg, va);
33     fprintf(stderr, "\n");
34     va_end(va);
35 }
36 
37 static UBool gShowWarning = TRUE;
38 
setShowWarning(UBool val)39 U_CFUNC void setShowWarning(UBool val)
40 {
41     gShowWarning = val;
42 }
43 
getShowWarning()44 U_CFUNC UBool getShowWarning(){
45     return gShowWarning;
46 }
47 
48 static UBool gStrict =FALSE;
isStrict()49 U_CFUNC UBool isStrict(){
50     return gStrict;
51 }
setStrict(UBool val)52 U_CFUNC void setStrict(UBool val){
53     gStrict = val;
54 }
55 static UBool gVerbose =FALSE;
isVerbose()56 U_CFUNC UBool isVerbose(){
57     return gVerbose;
58 }
setVerbose(UBool val)59 U_CFUNC void setVerbose(UBool val){
60     gVerbose = val;
61 }
warning(uint32_t linenumber,const char * msg,...)62 U_CFUNC void warning(uint32_t linenumber, const char *msg, ...)
63 {
64     if (gShowWarning)
65     {
66         va_list va;
67 
68         va_start(va, msg);
69         fprintf(stderr, "%s:%u: warning: ", gCurrentFileName, (int)linenumber);
70         vfprintf(stderr, msg, va);
71         fprintf(stderr, "\n");
72         va_end(va);
73     }
74 }
75