CPD Results

The following document contains the results of PMD's CPD 6.55.0.

Duplications

File Line
org/sentrysoftware/jawk/jrt/JRT.java 635
org/sentrysoftware/jawk/jrt/JRT.java 668
if (partitioningReader == null) {
					int argc = (int) toDouble(vm.getARGC()); // (vm.getVariable("argc_field", true));
					Object o = BLANK;
					while(arglist_idx <= argc) {
						o = arglist_aa.get(arglist_idx);
						++arglist_idx;
						if (!(o instanceof UninitializedObject || o.toString().isEmpty())) {
							break;
						}
					}
					if (!(o instanceof UninitializedObject || o.toString().isEmpty())) {
						String name_value_or_filename = toAwkString(o, vm.getCONVFMT().toString(), locale);
						if (name_value_or_filename.indexOf('=') == -1) {
							partitioningReader = new PartitioningReader(new FileReader(name_value_or_filename), vm.getRS().toString(), true);
							vm.setFILENAME(name_value_or_filename);
							vm.resetFNR();
						} else {
							setFilelistVariable(name_value_or_filename);
File Line
org/sentrysoftware/jawk/backend/AVM.java 321
org/sentrysoftware/jawk/backend/AVM.java 366
case AwkTuples._PRINT_TO_FILE_: {
						// arg[0] = # of items to print on the stack
						// arg[1] = true=append, false=overwrite
						// stack[0] = output filename
						// stack[1] = item 1
						// stack[2] = item 2
						// etc.
						long num_args = position.intArg(0);
						boolean append = position.boolArg(1);
						String key = JRT.toAwkString(pop(), getCONVFMT().toString(), locale);
						PrintStream ps = jrt.getOutputFiles().get(key);
						if (ps == null) {
							try {
								jrt.getOutputFiles().put(key, ps = new PrintStream(new FileOutputStream(key, append), true));	// true = autoflush
							} catch (IOException ioe) {
								throw new AwkRuntimeException(position.lineNumber(), "Cannot open " + key + " for writing: " + ioe);
							}
						}
File Line
org/sentrysoftware/jawk/backend/AVM.java 2255
org/sentrysoftware/jawk/jrt/JRT.java 731
private void setFilelistVariable(String name_value) {
		int eq_idx = name_value.indexOf('=');
		// variable name should be non-blank
		assert eq_idx >= 0;
		if (eq_idx == 0) {
			throw new IllegalArgumentException("Must have a non-blank variable name in a name=value variable assignment argument.");
		}
		String name = name_value.substring(0, eq_idx);
		String value = name_value.substring(eq_idx + 1);
		Object obj;
		try {
			obj = Integer.parseInt(value);
		} catch (NumberFormatException nfe) {
			try {
				obj = Double.parseDouble(value);
			} catch (NumberFormatException nfe2) {
				obj = value;
			}
		}
File Line
org/sentrysoftware/jawk/backend/AVM.java 808
org/sentrysoftware/jawk/backend/AVM.java 830
case AwkTuples._INC_ARRAY_REF_: {
						// arg[0] = offset
						// arg[1] = is_global
						// stack[0] = array index
						boolean is_global = position.boolArg(1);
						Object o1 = runtime_stack.getVariable(position.intArg(0), is_global);
						if (o1 == null || o1 instanceof UninitializedObject) {
							runtime_stack.setVariable(position.intArg(0), o1 = new AssocArray(sorted_array_keys), is_global);
						}
						AssocArray aa = (AssocArray) o1;
						Object key = pop();
						Object o = aa.get(key);
						assert o != null;
						double ans = JRT.toDouble(o) + 1;
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4316
org/sentrysoftware/jawk/frontend/AwkParser.java 4416
tuples.inc(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof ArrayReference_AST) {
				ArrayReference_AST arr_ast = (ArrayReference_AST) ast1;
				ID_AST id_ast = (ID_AST) arr_ast.ast1;
				assert id_ast != null;
				assert arr_ast.ast2 != null;
				int arr_ast2_result = arr_ast.ast2.populateTuples(tuples);
				assert arr_ast2_result == 1;
				tuples.incArrayRef(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof DollarExpression_AST) {
				DollarExpression_AST dollar_expr = (DollarExpression_AST) ast1;
				assert dollar_expr.ast1 != null;
				int ast1_result = dollar_expr.ast1.populateTuples(tuples);
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4366
org/sentrysoftware/jawk/frontend/AwkParser.java 4453
tuples.dec(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof ArrayReference_AST) {
				ArrayReference_AST arr_ast = (ArrayReference_AST) ast1;
				ID_AST id_ast = (ID_AST) arr_ast.ast1;
				assert id_ast != null;
				assert arr_ast.ast2 != null;
				int arr_ast2_result = arr_ast.ast2.populateTuples(tuples);
				assert arr_ast2_result == 1;
				tuples.decArrayRef(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof DollarExpression_AST) {
				DollarExpression_AST dollar_expr = (DollarExpression_AST) ast1;
				assert dollar_expr.ast1 != null;
				int ast1_result = dollar_expr.ast1.populateTuples(tuples);
File Line
org/sentrysoftware/jawk/backend/AVM.java 2276
org/sentrysoftware/jawk/backend/AVM.java 2298
if (function_names.contains(name)) {
			throw new IllegalArgumentException("Cannot assign a scalar to a function name (" + name + ").");
		}

		Integer offset_obj = global_variable_offsets.get(name);
		Boolean array_obj = global_variable_arrays.get(name);

		if (offset_obj != null) {
			assert array_obj != null;
			if (array_obj.booleanValue()) {
				throw new IllegalArgumentException("Cannot assign a scalar to a non-scalar variable (" + name + ").");
			} else {
				runtime_stack.setFilelistVariable(offset_obj.intValue(), obj);
			}
		}
		// otherwise, do nothing
	}
File Line
org/sentrysoftware/jawk/util/AwkParameters.java 307
org/sentrysoftware/jawk/util/AwkSettings.java 240
private static void addVariable(AwkSettings settings, String keyValue) {
		int equalsIdx = keyValue.indexOf('=');
		assert equalsIdx >= 0;
		String name = keyValue.substring(0, equalsIdx);
		String valueString = keyValue.substring(equalsIdx + 1);
		Object value;
		// deduce type
		try {
			value = Integer.parseInt(valueString);
		} catch (NumberFormatException nfe) {
			try {
				value = Double.parseDouble(valueString);
			} catch (NumberFormatException nfe2) {
				value = valueString;
			}
		}
File Line
org/sentrysoftware/jawk/ext/CoreExtension.java 626
org/sentrysoftware/jawk/ext/CoreExtension.java 644
for (int i = 1; i < args.length; i += 2) {
			if (args[i] instanceof AssocArray) {
				args[i] = newReference(args[i]);
			}
			if (args[i + 1] instanceof AssocArray) {
				args[i + 1] = newReference(args[i + 1]);
			}

			aa.put(args[i], args[i + 1]);
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4480
org/sentrysoftware/jawk/frontend/AwkParser.java 4611
private Print_AST(AST expr_list, int output_token, AST output_expr) {
			super(expr_list, output_expr);
			this.output_token = output_token;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			int param_count;
			if (ast1 == null) {
				param_count = 0;
			} else {
				param_count = ast1.populateTuples(tuples);
				assert param_count >= 0;
				if (param_count == 0) {
					throw new SemanticException("Cannot print the result. The expression doesn't return anything.");
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 3020
org/sentrysoftware/jawk/frontend/AwkParser.java 3168
private AssignmentExpression_AST(AST lhs, int op, String text, AST rhs) {
			super(lhs, rhs);
			this.op = op;
			this.text = text;
		}

		@Override
		public String toString() {
			return super.toString() + " (" + op + "/" + text + ")";
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
			assert ast2 != null;
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 3020
org/sentrysoftware/jawk/frontend/AwkParser.java 3168
org/sentrysoftware/jawk/frontend/AwkParser.java 3230
org/sentrysoftware/jawk/frontend/AwkParser.java 3278
private AssignmentExpression_AST(AST lhs, int op, String text, AST rhs) {
			super(lhs, rhs);
			this.op = op;
			this.text = text;
		}

		@Override
		public String toString() {
			return super.toString() + " (" + op + "/" + text + ")";
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
File Line
org/sentrysoftware/jawk/jrt/JRT.java 1260
org/sentrysoftware/jawk/jrt/JRT.java 1286
public static Integer replaceFirst(Object orig_value_obj, Object repl_obj, Object ere_obj, StringBuffer sb, String convfmt, Locale locale) {
		String orig_value = toAwkString(orig_value_obj, convfmt, locale);
		String repl = toAwkString(repl_obj, convfmt, locale);
		String ere = toAwkString(ere_obj, convfmt, locale);
		// remove special meaning for backslash and dollar signs
		repl = Matcher.quoteReplacement(repl);
		sb.setLength(0);
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 2767
org/sentrysoftware/jawk/frontend/AwkParser.java 2822
super(block, expr);
		}

		@Override
		public Address breakAddress() {
			assert break_address != null;
			return break_address;
		}

		@Override
		public Address continueAddress() {
			assert continue_address != null;
			return continue_address;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			break_address = tuples.createAddress("break_address");
			continue_address = tuples.createAddress("continue_address");
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4316
org/sentrysoftware/jawk/frontend/AwkParser.java 4366
org/sentrysoftware/jawk/frontend/AwkParser.java 4416
org/sentrysoftware/jawk/frontend/AwkParser.java 4453
tuples.inc(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof ArrayReference_AST) {
				ArrayReference_AST arr_ast = (ArrayReference_AST) ast1;
				ID_AST id_ast = (ID_AST) arr_ast.ast1;
				assert id_ast != null;
				assert arr_ast.ast2 != null;
				int arr_ast2_result = arr_ast.ast2.populateTuples(tuples);
				assert arr_ast2_result == 1;
				tuples.incArrayRef(id_ast.offset, id_ast.is_global);
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 5044
org/sentrysoftware/jawk/frontend/AwkParser.java 5084
}
			assert map != null;
			ID_AST id_ast = map.get(id);
			if (id_ast == null) {
				id_ast = new ID_AST(id, map == global_ids);
				id_ast.offset = map.size();
				assert id_ast.offset != AVM.NULL_OFFSET;
				map.put(id, id_ast);
			}
			return id_ast;
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4404
org/sentrysoftware/jawk/frontend/AwkParser.java 4441
private PostInc_AST(AST symbol_ast) {
			super(symbol_ast);
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);
			assert ast1 != null;
			int ast1_result = ast1.populateTuples(tuples);
			assert ast1_result == 1;
			if (ast1 instanceof ID_AST) {
				ID_AST id_ast = (ID_AST) ast1;
				tuples.postInc(id_ast.offset, id_ast.is_global);
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 2713
org/sentrysoftware/jawk/frontend/AwkParser.java 2822
super(expr, block);
		}

		@Override
		public Address breakAddress() {
			assert break_address != null;
			return break_address;
		}

		@Override
		public Address continueAddress() {
			assert continue_address != null;
			return continue_address;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			break_address = tuples.createAddress("break_address");
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 2713
org/sentrysoftware/jawk/frontend/AwkParser.java 2767
super(expr, block);
		}

		@Override
		public Address breakAddress() {
			assert break_address != null;
			return break_address;
		}

		@Override
		public Address continueAddress() {
			assert continue_address != null;
			return continue_address;
		}

		@Override
		public int populateTuples(AwkTuples tuples) {
			pushSourceLineNumber(tuples);

			break_address = tuples.createAddress("break_address");
File Line
org/sentrysoftware/jawk/frontend/AwkParser.java 4324
org/sentrysoftware/jawk/frontend/AwkParser.java 4374
tuples.incArrayRef(id_ast.offset, id_ast.is_global);
			} else if (ast1 instanceof DollarExpression_AST) {
				DollarExpression_AST dollar_expr = (DollarExpression_AST) ast1;
				assert dollar_expr.ast1 != null;
				int ast1_result = dollar_expr.ast1.populateTuples(tuples);
				assert ast1_result == 1;
				// OPTIMIATION: duplicate the x in $x here
				// so that it is not evaluated again
				tuples.dup();
				// stack contains eval of dollar arg
				//tuples.assignAsInputField();
				tuples.incDollarRef();
File Line
org/sentrysoftware/jawk/backend/AVM.java 1431
org/sentrysoftware/jawk/backend/AVM.java 1446
case AwkTuples._IS_EMPTY_KEYLIST_: {
						// arg[0] = address
						// stack[0] = KeyList
						Object o = pop();
						if (o == null || !(o instanceof KeyList)) {
							throw new AwkRuntimeException(position.lineNumber(), "Cannot get a keylist (via 'in') of a non associative array. arg = " + o.getClass() + ", " + o);
						}
						KeyList keylist = (KeyList) o;
No results.