Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 134x 134x 134x 86x 86x 86x 570x 570x 570x 570x 570x 86x 134x 134x 40x 40x 40x 159x 159x 40x 134x 41x 41x 259x 259x 41x 41x 660x 660x 41x 41x 991x 991x 403x 403x 975x 588x 588x 991x 41x 41x 1x 1x 41x 41x 1638x 1638x 1638x 1637x 1637x 1637x 1637x 1638x 1638x 41x 41x 2116x 2116x 451x 451x 451x 451x 451x 1x 1x 1x 1x 2116x 1665x 1665x 2116x 41x 41x 41x 41x 69x 69x 69x 41x 41x 69x 69x 69x 69x 4x 4x 4x 4x 4x 4x 69x 65x 65x 69x 41x 41x 45x 45x 306x 43x 43x 43x 306x 45x 45x 41x 41x 333x 333x 333x 333x 333x 333x 333x 333x 333x 333x 333x 333x 260x 260x 260x 1x 1x 259x 259x 260x 260x 332x 332x 332x 332x 333x 322x 322x 26x 322x 296x 296x 333x 10x 10x 333x 41x 41x 41x 41x 678x 678x 678x 678x 678x 678x 678x 678x 2902x 204x 204x 204x 2902x 2698x 2698x 678x 678x 678x 41x 41x 40x 40x 640x 640x 40x 40x 41x 41x 1x 1x 41x 41x 228x 228x 228x 228x 228x 228x 228x 228x 228x 228x 5881x 5881x 5881x 4014x 4014x 7x 7x 7x 7x 7x 7x 3x 3x 3x 3x 7x 7x 3x 2x 2x 3x 7x 7x 1x 1x 1x 1x 1x 7x 7x 7x 4014x 4014x 4014x 4014x 4014x 28x 27x 27x 28x 4014x 4014x 225x 225x 225x 4014x 4014x 3x 3x 4014x 4014x 3751x 3751x 3751x 3751x 4014x 4014x 4014x 5881x 5881x 1867x 1867x 17x 17x 17x 17x 17x 17x 6x 6x 6x 6x 6x 17x 17x 10x 10x 10x 17x 17x 1x 1x 1x 1x 1x 1x 17x 17x 17x 1867x 1867x 1867x 1867x 1867x 185x 169x 169x 185x 1867x 1867x 20x 20x 1867x 1867x 1645x 1645x 1645x 1645x 1645x 1867x 1867x 1867x 5881x 5881x 5881x 5881x 23x 23x 5881x 228x 228x 228x 228x 3x 3x 225x 225x 228x 41x 41x 21x 21x 41x 41x 41x 41x 3034x 41217x 41217x 41217x 2655x 2655x 41217x 5x 5x 38557x 38557x 41217x 5725x 5725x 5725x 5725x 5725x 5725x 369x 369x 369x 369x 369x 369x 369x 369x 369x 369x 5725x 41217x 5x 3034x 41x 41x 27x 27x 2x 2x 25x 25x 25x 25x 25x 25x 3x 3x 3x 3x 27x 41x 41x 2700x 2700x 2700x 2700x 18x 18x 2682x 2682x 2682x 2682x 2700x 2700x 41x 41x 2367x 2367x 2367x 2367x 2367x 1x 1x 2366x 2366x 2367x 41x | // Copyright (c) ZeroC, Inc. import { StringUtil } from "./StringUtil.js"; import { PropertyNames } from "./PropertyNames.js"; import { getProcessLogger } from "./ProcessLogger.js"; import { InitializationException } from "./LocalExceptions.js"; import { PropertyException } from "./LocalExceptions.js"; const ParseStateKey = 0; const ParseStateValue = 1; // // Ice.Properties // export class Properties { constructor(args, defaults) { this._properties = new Map(); if (defaults !== undefined && defaults !== null) { // We can't just do a shallow copy of the map as the map values would otherwise be shared between the two // instances. for (const [key, property] of defaults._properties) { this._properties.set(key, { value: property.value, used: false, }); } } if (args !== undefined && args !== null) { const v = this.parseIceCommandLineOptions(args); args.length = 0; for (let i = 0; i < v.length; ++i) { args.push(v[i]); } } } getProperty(key) { return this.getPropertyWithDefault(key, ""); } getIceProperty(key) { return this.getPropertyWithDefault(key, Properties.getDefaultProperty(key)); } getPropertyWithDefault(key, value) { const pv = this._properties.get(key); if (pv !== undefined) { pv.used = true; return pv.value; } else { return value; } } getPropertyAsInt(key) { return this.getPropertyAsIntWithDefault(key, 0); } getIcePropertyAsInt(key) { const defaultValueString = Properties.getDefaultProperty(key); let defaultValue = 0; if (defaultValueString != "") { try { defaultValue = StringUtil.toInt32(defaultValueString); } catch (err) { throw new PropertyException( `property '${key}' has an invalid default integer value: '${defaultValueString}'`, { cause: err }, ); } } return this.getPropertyAsIntWithDefault(key, defaultValue); } getPropertyAsIntWithDefault(key, defaultValue) { const pv = this._properties.get(key); if (pv !== undefined) { pv.used = true; try { const value = StringUtil.toInt32(pv.value); return value; } catch (err) { throw new PropertyException(`property '${key}' has an invalid integer value: '${pv.value}'`, { cause: err, }); } } else { return defaultValue; } } getPropertyAsList(key) { return this.getPropertyAsListWithDefault(key, 0); } getIcePropertyAsList(key) { const defaultPropertyList = StringUtil.splitString(Properties.getDefaultProperty(key), ", \t\r\n"); return this.getPropertyAsListWithDefault(key, defaultPropertyList); } getPropertyAsListWithDefault(key, value) { if (value === undefined || value === null) { value = []; } const pv = this._properties.get(key); if (pv !== undefined) { pv.used = true; let result = StringUtil.splitString(pv.value, ", \t\r\n"); if (result === null) { getProcessLogger().warning( "mismatched quotes in property " + key + "'s value, returning default value", ); return value; } if (result.length === 0) { result = value; } return result; } else { return value; } } getPropertiesForPrefix(prefix = "") { const result = new Map(); for (const [key, property] of this._properties) { if (key.startsWith(prefix)) { property.used = true; result.set(key, property.value); } } return result; } setProperty(key = "", value = "") { // // Trim whitespace // if (key !== null) { key = key.trim(); } if (key === null || key.length === 0) { throw new InitializationException("Attempt to set property with empty key"); } // Check if the property is in an Ice property prefix. If so, check that it's a valid property. const propertyArray = Properties.findIcePropertyArray(key); if (propertyArray !== null) { const prop = Properties.findProperty(key.substring(propertyArray.name.length + 1), propertyArray); if (prop === null) { throw new PropertyException(`unknown Ice property: ${key}`); } // If the property is deprecated, log a warning if (prop.deprecated) { getProcessLogger().warning("setting deprecated property: " + key); } } // // Set or clear the property. // if (value !== null && value.length > 0) { const pv = this._properties.get(key); if (pv !== undefined) { pv.value = value; } else { this._properties.set(key, { value: value, used: false }); } } else { this._properties.delete(key); } } getCommandLineOptions() { const result = []; this._properties.forEach((property, key) => { result.push("--" + key + "=" + property.value); }); return result; } parseCommandLineOptions(pfx, options) { if (pfx.length > 0 && pfx.charAt(pfx.length - 1) != ".") { pfx += "."; } pfx = "--" + pfx; const result = []; options.forEach(opt => { if (opt.indexOf(pfx) === 0) { if (opt.indexOf("=") === -1) { opt += "=1"; } this.parseLine(opt.substring(2)); } else { result.push(opt); } }); return result; } parseIceCommandLineOptions(options) { let args = options.slice(); for (const prop of PropertyNames.validProps) { args = this.parseCommandLineOptions(prop.name, args); } return args; } parse(data) { data.match(/[^\r\n]+/g).forEach(line => this.parseLine(line)); } parseLine(line) { let key = ""; let value = ""; let state = ParseStateKey; let whitespace = ""; let escapedSpace = ""; let finished = false; for (let i = 0; i < line.length; ++i) { let c = line.charAt(i); switch (state) { case ParseStateKey: { switch (c) { case "\\": if (i < line.length - 1) { c = line.charAt(++i); switch (c) { case "\\": case "#": case "=": key += whitespace; whitespace = ""; key += c; break; case " ": if (key.length !== 0) { whitespace += c; } break; default: key += whitespace; whitespace = ""; key += "\\"; key += c; break; } } else { key += whitespace; key += c; } break; case " ": case "\t": case "\r": case "\n": if (key.length !== 0) { whitespace += c; } break; case "=": whitespace = ""; state = ParseStateValue; break; case "#": finished = true; break; default: key += whitespace; whitespace = ""; key += c; break; } break; } case ParseStateValue: { switch (c) { case "\\": if (i < line.length - 1) { c = line.charAt(++i); switch (c) { case "\\": case "#": case "=": value += value.length === 0 ? escapedSpace : whitespace; whitespace = ""; escapedSpace = ""; value += c; break; case " ": whitespace += c; escapedSpace += c; break; default: value += value.length === 0 ? escapedSpace : whitespace; whitespace = ""; escapedSpace = ""; value += "\\"; value += c; break; } } else { value += value.length === 0 ? escapedSpace : whitespace; value += c; } break; case " ": case "\t": case "\r": case "\n": if (value.length !== 0) { whitespace += c; } break; case "#": finished = true; break; default: value += value.length === 0 ? escapedSpace : whitespace; whitespace = ""; escapedSpace = ""; value += c; break; } break; } default: { console.assert(false); break; } } if (finished) { break; } } value += escapedSpace; if ((state === ParseStateKey && key.length !== 0) || (state == ParseStateValue && key.length === 0)) { getProcessLogger().warning('invalid config file entry: "' + line + '"'); return; } else if (key.length === 0) { return; } this.setProperty(key, value); } clone() { return new Properties(null, this); } getUnusedProperties() { const unused = []; this._properties.forEach((property, key) => { if (!property.used) { unused.push(key); } }); return unused; } static findProperty(key, propertyArray) { for (const prop of propertyArray.properties) { // If the key is an exact match, return the property unless it has a property class which is prefix only. // If the key is a regex match, return the property. A property cannot have a property class and use regex. if (key == prop.pattern) { if (prop.propertyArray !== null && prop.propertyArray.prefixOnly) { return null; } return prop; } else if (prop.usesRegex && key.match(prop.pattern)) { return prop; } // If the property has a property array, check if the key is a prefix of the property. if (prop.propertyArray) { // Check if the key is a prefix of the property. // The key must be: // - shorter than the property pattern // - the property pattern must start with the key // - the pattern character after the key must be a dot if (key.length > prop.pattern.length && key.startsWith(`${prop.pattern}.`)) { // Plus one to skip the dot. let substring = key.substring(prop.pattern.length + 1); // Check if the suffix is a valid property. If so, return it. If it's not, continue searching // the current property array. const subProp = Properties.findProperty(substring, prop.propertyArray); if (subProp !== null) { return subProp; } } } } return null; } static validatePropertiesWithPrefix(prefix, properties, propertyArray) { // Do not check for unknown properties if Ice prefix, ie Ice, Glacier2, etc if (PropertyNames.validProps.some(prop => prefix.startsWith(`${prop.name}.`))) { return; } const unknownProps = Array.from(properties.getPropertiesForPrefix(`${prefix}.`).keys()).filter( key => Properties.findProperty(key.substring(prefix.length + 1), propertyArray) === null, ); if (unknownProps.length > 0) { throw new PropertyException( `found unknown properties for ${propertyArray.name}: '${prefix}'\n ${unknownProps.join("\n ")}`, ); } } static findIcePropertyArray(key) { let dotPos = key.indexOf("."); // If the key doesn't contain a dot, it's not a valid Ice property. if (dotPos === -1) { return null; } const prefix = key.substring(0, dotPos); // Search for the property list that matches the prefix return PropertyNames.validProps.find(props => props.name === prefix) || null; } static getDefaultProperty(key) { const propertyArray = Properties.findIcePropertyArray(key); if (!propertyArray) { throw new PropertyException(`unknown Ice property: ${key}`); } const prop = Properties.findProperty(key.substring(propertyArray.name.length + 1), propertyArray); if (!prop) { throw new PropertyException(`unknown Ice property: ${key}`); } return prop.defaultValue; } } |