• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdbool.h>
22 #include <stdio.h>
23 #include "cstring.h"
24 #include "errmsg.h"
25 #include "toolutil.h"
26 
error(uint32_t linenumber,const char * msg,...)27 U_CFUNC void error(uint32_t linenumber, const char *msg, ...)
28 {
29     va_list va;
30 
31     va_start(va, msg);
32     fprintf(stderr, "%s:%u: ", gCurrentFileName, (int)linenumber);
33     vfprintf(stderr, msg, va);
34     fprintf(stderr, "\n");
35     va_end(va);
36 }
37 
38 static UBool gShowWarning = true;
39 
setShowWarning(UBool val)40 U_CFUNC void setShowWarning(UBool val)
41 {
42     gShowWarning = val;
43 }
44 
getShowWarning()45 U_CFUNC UBool getShowWarning(){
46     return gShowWarning;
47 }
48 
49 static UBool gStrict =false;
isStrict()50 U_CFUNC UBool isStrict(){
51     return gStrict;
52 }
setStrict(UBool val)53 U_CFUNC void setStrict(UBool val){
54     gStrict = val;
55 }
56 static UBool gVerbose =false;
isVerbose()57 U_CFUNC UBool isVerbose(){
58     return gVerbose;
59 }
setVerbose(UBool val)60 U_CFUNC void setVerbose(UBool val){
61     gVerbose = val;
62 }
warning(uint32_t linenumber,const char * msg,...)63 U_CFUNC void warning(uint32_t linenumber, const char *msg, ...)
64 {
65     if (gShowWarning)
66     {
67         va_list va;
68 
69         va_start(va, msg);
70         fprintf(stderr, "%s:%u: warning: ", gCurrentFileName, (int)linenumber);
71         vfprintf(stderr, msg, va);
72         fprintf(stderr, "\n");
73         va_end(va);
74     }
75 }
76