Changeset 51770 in vbox for trunk/src/VBox/Runtime/common/string/uniread.cpp
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/bird/hardenedwindows (added) merged: 92692-94610
- Property svn:mergeinfo changed
-
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/bird/hardenedwindows/src/VBox (added) merged: 92692-94610
- Property svn:mergeinfo changed
-
trunk/src/VBox/Runtime/common/string/uniread.cpp
r48935 r51770 35 35 #include <string.h> 36 36 #include <stdlib.h> 37 #ifdef _MSC_VER 38 # include <direct.h> 39 #else 40 # include <unistd.h> 41 #endif 37 42 38 43 … … 40 45 * Global Variables * 41 46 *******************************************************************************/ 42 /** When set, no output is produced. Very useful when debugging ths code. */43 static bool g_fQuiet = false;44 47 /** The file we're currently parsing. */ 45 48 static const char *g_pszCurFile; 46 49 /** The current line number. */ 47 50 static unsigned g_iLine; 51 /** The current output file. */ 52 static FILE *g_pCurOutFile; 48 53 49 54 … … 884 889 //if (pInfo->???) 885 890 // AppendFlag(pszFlags, "RTUNI_BSPACE"); 891 #if 0 886 892 if (pInfo->fInvNFD_QC != 0 || pInfo->fInvNFC_QC != 0) 887 893 { … … 894 900 else if (pInfo->paDecompositionMapping && !*pInfo->pszDecompositionType) 895 901 fprintf(stderr, "uniread: U+%05X is not QC_NFX but has canonical mappings.\n", pInfo->CodePoint); 902 #endif 896 903 897 904 if (!*pszFlags) … … 906 913 907 914 /** 915 * Closes the primary output stream. 916 */ 917 static int Stream1Close(void) 918 { 919 if (g_pCurOutFile && g_pCurOutFile != stdout && g_pCurOutFile != stderr) 920 { 921 if (fclose(g_pCurOutFile) != 0) 922 { 923 fprintf(stderr, "Error closing output file.\n"); 924 return -1; 925 } 926 } 927 g_pCurOutFile = NULL; 928 return 0; 929 } 930 931 932 /** 933 * Initializes the 1st stream to output to a given file. 934 */ 935 static int Stream1Init(const char *pszName) 936 { 937 int rc = Stream1Close(); 938 if (!rc) 939 { 940 g_pCurOutFile = fopen(pszName, "w"); 941 if (!g_pCurOutFile) 942 { 943 fprintf(stderr, "Error opening output file '%s'.\n", pszName); 944 rc = -1; 945 } 946 } 947 return rc; 948 } 949 950 951 /** 908 952 * printf wrapper for the primary output stream. 909 953 * … … 917 961 va_list va; 918 962 va_start(va, pszFormat); 919 if (!g_fQuiet) 920 cch = vfprintf(stdout, pszFormat, va); 921 else 922 cch = (int)strlen(pszFormat); 963 cch = vfprintf(g_pCurOutFile, pszFormat, va); 923 964 va_end(va); 924 965 return cch; … … 974 1015 * Print the unidata.cpp file header and include list. 975 1016 */ 976 int PrintHeader(const char *argv0) 977 { 978 Stream1Printf("/** @file\n" 979 " *\n" 1017 int PrintHeader(const char *argv0, const char *pszBaseDir) 1018 { 1019 char szBuf[1024]; 1020 if (!pszBaseDir) 1021 { 1022 memset(szBuf, 0, sizeof(szBuf)); 1023 #ifdef _MSC_VER 1024 _getcwd(szBuf, sizeof(szBuf)); 1025 #else 1026 getcwd(szBuf, sizeof(szBuf)); 1027 #endif 1028 pszBaseDir = szBuf; 1029 } 1030 1031 Stream1Printf("/* $" "Id" "$ */\n" 1032 "/** @file\n" 980 1033 " * IPRT - Unicode Tables.\n" 981 1034 " *\n" 982 " * Automatically Generated by %s (" __DATE__ " " __TIME__ ")\n" 1035 " * Automatically Generated from %s\n" 1036 " * by %s (" __DATE__ " " __TIME__ ")\n" 983 1037 " */\n" 984 1038 "\n" 985 1039 "/*\n" 986 " * Copyright (C) 2006-201 0Oracle Corporation\n"1040 " * Copyright (C) 2006-2014 Oracle Corporation\n" 987 1041 " *\n" 988 1042 " * This file is part of VirtualBox Open Source Edition (OSE), as\n" … … 1006 1060 "#include <iprt/uni.h>\n" 1007 1061 "\n", 1008 argv0);1062 pszBaseDir, argv0); 1009 1063 return 0; 1010 1064 } … … 1020 1074 */ 1021 1075 Stream2Init(); 1022 Stream2Printf(" const RTUNIFLAGSRANGEg_aRTUniFlagsRanges[] =\n"1076 Stream2Printf("RT_DECL_DATA_CONST(const RTUNIFLAGSRANGE) g_aRTUniFlagsRanges[] =\n" 1023 1077 "{\n"); 1024 1078 RTUNICP i = 0; … … 1047 1101 if (iStart < 0) 1048 1102 { 1049 Stream1Printf("static const uint8_t g_afRTUniFlags0x%06x[] = 1103 Stream1Printf("static const uint8_t g_afRTUniFlags0x%06x[] =\n" 1050 1104 "{\n", i); 1051 1105 iStart = i; … … 1069 1123 { 1070 1124 Stream2Init(); 1071 Stream2Printf(" const RTUNICASERANGEg_aRTUniUpperRanges[] =\n"1125 Stream2Printf("RT_DECL_DATA_CONST(const RTUNICASERANGE) g_aRTUniUpperRanges[] =\n" 1072 1126 "{\n"); 1073 1127 RTUNICP i = 0; … … 1095 1149 if (iStart < 0) 1096 1150 { 1097 Stream1Printf("static const RTUNICP g_afRTUniUpper0x%06x[] = 1151 Stream1Printf("static const RTUNICP g_afRTUniUpper0x%06x[] =\n" 1098 1152 "{\n", i); 1099 1153 iStart = i; … … 1116 1170 { 1117 1171 Stream2Init(); 1118 Stream2Printf(" const RTUNICASERANGEg_aRTUniLowerRanges[] =\n"1172 Stream2Printf("RT_DECL_DATA_CONST(const RTUNICASERANGE) g_aRTUniLowerRanges[] =\n" 1119 1173 "{\n"); 1120 1174 RTUNICP i = 0; … … 1142 1196 if (iStart < 0) 1143 1197 { 1144 Stream1Printf("static const RTUNICP g_afRTUniLower0x%06x[] = 1198 Stream1Printf("static const RTUNICP g_afRTUniLower0x%06x[] =\n" 1145 1199 "{\n", i); 1146 1200 iStart = i; … … 1202 1256 pszBaseDir = argv[argi]; 1203 1257 } 1204 else if ( !strcmp(argv[argi], "-q")1205 || !strcmp(argv[argi], "--quiet"))1206 g_fQuiet = true;1207 1258 else 1208 1259 { … … 1232 1283 1233 1284 /* 1234 * Pr int stuff.1285 * Produce output files. 1235 1286 */ 1236 rc = PrintHeader(argv[0]); 1237 if (rc) 1238 return rc; 1239 rc = PrintFlags(); 1240 if (rc) 1241 return rc; 1242 rc = PrintUpper(); 1243 if (rc) 1244 return rc; 1245 rc = PrintLower(); 1246 if (rc) 1247 return rc; 1287 rc = Stream1Init("unidata-flags.cpp"); 1288 if (!rc) 1289 rc = PrintHeader(argv[0], pszBaseDir); 1290 if (!rc) 1291 rc = PrintFlags(); 1292 1293 rc = Stream1Init("unidata-upper.cpp"); 1294 if (!rc) 1295 rc = PrintHeader(argv[0], pszBaseDir); 1296 if (!rc) 1297 rc = PrintUpper(); 1298 1299 rc = Stream1Init("unidata-lower.cpp"); 1300 if (!rc) 1301 rc = PrintHeader(argv[0], pszBaseDir); 1302 if (!rc) 1303 rc = PrintLower(); 1304 if (!rc) 1305 rc = Stream1Close(); 1248 1306 1249 1307 /* done */ 1250 fflush(stdout);1251 1252 1308 return rc; 1253 1309 }
Note:
See TracChangeset
for help on using the changeset viewer.