1 // Copyright (C) 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 25 U_CFUNC void error(uint32_t linenumber, const char *msg, ...) 26 { 27 va_list va; 28 29 va_start(va, msg); 30 fprintf(stderr, "%s:%u: ", gCurrentFileName, (int)linenumber); 31 vfprintf(stderr, msg, va); 32 fprintf(stderr, "\n"); 33 va_end(va); 34 } 35 36 static UBool gShowWarning = TRUE; 37 38 U_CFUNC void setShowWarning(UBool val) 39 { 40 gShowWarning = val; 41 } 42 43 U_CFUNC UBool getShowWarning(){ 44 return gShowWarning; 45 } 46 47 static UBool gStrict =FALSE; 48 U_CFUNC UBool isStrict(){ 49 return gStrict; 50 } 51 U_CFUNC void setStrict(UBool val){ 52 gStrict = val; 53 } 54 static UBool gVerbose =FALSE; 55 U_CFUNC UBool isVerbose(){ 56 return gVerbose; 57 } 58 U_CFUNC void setVerbose(UBool val){ 59 gVerbose = val; 60 } 61 U_CFUNC void warning(uint32_t linenumber, const char *msg, ...) 62 { 63 if (gShowWarning) 64 { 65 va_list va; 66 67 va_start(va, msg); 68 fprintf(stderr, "%s:%u: warning: ", gCurrentFileName, (int)linenumber); 69 vfprintf(stderr, msg, va); 70 fprintf(stderr, "\n"); 71 va_end(va); 72 } 73 } 74