Jawk 7.1.01
-
Home
- Project Documentation Project Reports 9
CPD Results
The following document contains the results of PMD's CPD[1] 7.17.0.
Duplications
| File | Line |
|---|---|
| io/jawk/jrt/HashAssocArray.java | 45[2] |
| io/jawk/jrt/SortedAssocArray.java | 61[3] |
}
/**
* Returns the value to which the specified key is mapped, normalizing the key
* first. If the key does not exist, a blank ({@link io.jawk.intermediate.UninitializedObject})
* is inserted and returned, as required by AWK semantics.
*
* @param key the key whose associated value is to be returned
* @return the value associated with the key, or a blank value if not found
*/
@Override
public Object get(Object key) {
key = AssocArray.normalizeKey(key);
Object result = super.get(key);
if (result != null) {
return result;
}
Long lKey = AssocArray.toLongKey(key);
if (lKey != null) {
result = super.get(lKey);
if (result != null) {
return result;
}
key = lKey;
}
result = UNTYPED;
super.put(key, result);
return result;
}
/**
* Associates the specified value with the specified key, normalizing the key
* to a {@code Long} when the key is a valid integer string.
*
* @param key the key
* @param value the value
* @return the previous value associated with the key, or {@code null}
*/
@Override
public Object put(Object key, Object value) {
key = AssocArray.normalizeKey(key);
Long lKey = AssocArray.toLongKey(key);
// null has no meaning in an AWK array: store the untyped marker so
// callers never have to special-case it
return super.put(lKey != null ? lKey : key, value == null ? UNTYPED : value);
}
/**
* Removes the mapping for the specified key, trying both the original and its
* {@code Long} equivalent.
*
* @param key the key whose mapping is to be removed
* @return the previous value associated with the key, or {@code null}
*/
@Override
public Object remove(Object key) {
key = AssocArray.normalizeKey(key);
Object result = super.remove(key);
if (result != null) {
return result;
}
Long lKey = AssocArray.toLongKey(key);
return lKey != null ? super.remove(lKey) : null;
}
/**
* Returns the specification version of the underlying {@link HashMap} class.
*
* @return the specification version string, or {@code null} if unavailable
*/
@Override
public String getMapVersion() {
return HashMap.class.getPackage().getSpecificationVersion();
|
|
| File | Line |
|---|---|
| io/jawk/SandboxedAwk.java | 121[4] |
| io/jawk/SandboxedAwk.java | 181[5] |
final class SandboxedCompiledAwkProgram extends AwkProgram {
private static final long serialVersionUID = 1L;
@Override
public void printToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void printfToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printfToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void system() {
deny("system() is disabled in sandbox mode");
}
@Override
public void useAsCommandInput(Address noRecordAddress) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void useAsFileInput(Address noRecordAddress) {
deny("Input redirection is disabled in sandbox mode");
}
@Override
public void assignARGC() {
deny("Assigning to ARGC is disabled in sandbox mode");
}
@Override
public void argcOffset(int offset) {
// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
// command-line argument count when ARGC is not materialized.
}
@Override
public void argvOffset(int offset) {
// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
// synthetic AssocArray when ARGV is not materialized.
}
private static void deny(String message) {
throw new AwkSandboxException(message);
}
}
|
|
| File | Line |
|---|---|
| io/jawk/intermediate/AwkTuples.java | 2804[6] |
| io/jawk/intermediate/AwkTuples.java | 2839[7] |
while (!worklist.isEmpty()) {
int index = worklist.removeFirst();
Tuple tuple = queue.get(index);
if (fallsThrough(tuple.getOpcode())) {
Tuple nextTuple = tuple.getNext();
if (nextTuple != null) {
int nextIndex = index + 1;
if (!reachable[nextIndex]) {
reachable[nextIndex] = true;
worklist.addLast(nextIndex);
}
}
}
for (Address address : tuple.getAddresses()) {
int targetIndex = address.index();
if (targetIndex < 0 || targetIndex >= size) {
throw new Error("address " + address + " doesn't resolve to an actual list element");
}
referencesFromReachable[targetIndex]++;
if (!reachable[targetIndex]) {
reachable[targetIndex] = true;
worklist.addLast(targetIndex);
}
}
}
|
|
| File | Line |
|---|---|
| io/jawk/SandboxedAwk.java | 124[8] |
| io/jawk/intermediate/SandboxedAwkTuples.java | 46[9] |
@Override
public void printToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void printfToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printfToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void system() {
deny("system() is disabled in sandbox mode");
}
@Override
public void useAsCommandInput(Address noRecordAddress) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void useAsFileInput(Address noRecordAddress) {
deny("Input redirection is disabled in sandbox mode");
}
@Override
public void assignARGC() {
deny("Assigning to ARGC is disabled in sandbox mode");
}
@Override
public void argcOffset(int offset) {
// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
// command-line argument count when ARGC is not materialized.
}
@Override
public void argvOffset(int offset) {
// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
// synthetic AssocArray when ARGV is not materialized.
}
|
|
| File | Line |
|---|---|
| io/jawk/SandboxedAwk.java | 184[10] |
| io/jawk/intermediate/SandboxedAwkTuples.java | 46[9] |
@Override
public void printToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void printfToFile(int numExprs, boolean append) {
deny("Output redirection is disabled in sandbox mode");
}
@Override
public void printfToPipe(int numExprs) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void system() {
deny("system() is disabled in sandbox mode");
}
@Override
public void useAsCommandInput(Address noRecordAddress) {
deny("Command execution through pipelines is disabled in sandbox mode");
}
@Override
public void useAsFileInput(Address noRecordAddress) {
deny("Input redirection is disabled in sandbox mode");
}
@Override
public void assignARGC() {
deny("Assigning to ARGC is disabled in sandbox mode");
}
@Override
public void argcOffset(int offset) {
// no-op: keep argcOffset at NULL_OFFSET; AVM.getARGC() returns the
// command-line argument count when ARGC is not materialized.
}
@Override
public void argvOffset(int offset) {
// no-op: keep argvOffset at NULL_OFFSET; AVM.getARGV() returns a
// synthetic AssocArray when ARGV is not materialized.
}
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 2468[11] |
| io/jawk/frontend/AwkParser.java | 2494[12] |
expectKeyword("print");
ParsedPrintStatement parsedPrintStatement = parsePrintStatement();
AST params = parsedPrintStatement.getFuncParams();
if (parsedPrintStatement.isParenthesized()
&& token == Token.QUESTION_MARK
&& params instanceof FunctionCallParamListAst
&& ((FunctionCallParamListAst) params).getAst2() == null) {
AST condExpr = ((FunctionCallParamListAst) params).getAst1();
lexer();
AST trueBlock = TERNARY_EXPRESSION(null, true, true, true);
lexer(Token.COLON);
AST falseBlock = TERNARY_EXPRESSION(null, true, true, true);
params = new FunctionCallParamListAst(
new TernaryExpressionAst(condExpr, trueBlock, falseBlock),
null);
}
return new PrintAst(
|
|
| File | Line |
|---|---|
| io/jawk/Awk.java | 1097[13] |
| io/jawk/backend/AVM.java | 4688[14] |
private static final class SingleRecordInputSource implements InputSource {
private final String record;
private boolean consumed;
private SingleRecordInputSource(String record) {
this.record = record;
}
@Override
public boolean nextRecord() {
if (consumed || record == null) {
return false;
}
consumed = true;
return true;
}
@Override
public String getRecordText() {
return consumed ? record : null;
}
@Override
public List<String> getFields() {
return null;
}
@Override
public boolean isFromFilenameList() {
return false;
}
}
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5538[15] |
| io/jawk/frontend/AwkParser.java | 5650[16] |
tuples.inc(idAst.offset, idAst.isGlobal);
} else if (getAst1() instanceof ArrayReferenceAst) {
ArrayReferenceAst arrAst = (ArrayReferenceAst) getAst1();
if (arrAst.getAst1() instanceof IDAst) {
IDAst idAst = (IDAst) arrAst.getAst1();
if (idAst.isScalar()) {
throw new SemanticException("Cannot use " + idAst + " as an array.");
}
idAst.setArray(true);
}
arrAst.populateTargetReferenceTuples(tuples);
tuples.incMapRef();
} else if (getAst1() instanceof DollarExpressionAst) {
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5538[15] |
| io/jawk/frontend/AwkParser.java | 5591[17] |
| io/jawk/frontend/AwkParser.java | 5650[16] |
| io/jawk/frontend/AwkParser.java | 5693[18] |
tuples.inc(idAst.offset, idAst.isGlobal);
} else if (getAst1() instanceof ArrayReferenceAst) {
ArrayReferenceAst arrAst = (ArrayReferenceAst) getAst1();
if (arrAst.getAst1() instanceof IDAst) {
IDAst idAst = (IDAst) arrAst.getAst1();
if (idAst.isScalar()) {
throw new SemanticException("Cannot use " + idAst + " as an array.");
}
idAst.setArray(true);
}
arrAst.populateTargetReferenceTuples(tuples);
tuples.incMapRef();
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 2714[19] |
| io/jawk/frontend/AwkParser.java | 2772[20] |
return 0;
}
AST argument = params.getAst1();
if (argument instanceof IDAst
&& !isJrtManagedSpecialName(((IDAst) argument).id)) {
IDAst idAst = (IDAst) argument;
tuples.pushIndirectArgument(idAst.offset, idAst.isGlobal);
} else if (argument instanceof ArrayReferenceAst) {
((ArrayReferenceAst) argument).populateTargetReferenceTuples(tuples);
tuples.pushIndirectArrayArgument();
} else {
argument.populateTuples(tuples);
}
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 4077[21] |
| io/jawk/frontend/AwkParser.java | 4270[22] |
| io/jawk/frontend/AwkParser.java | 4330[23] |
| io/jawk/frontend/AwkParser.java | 4373[24] |
private AssignmentExpressionAst(AST lhs, Token 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 |
|---|---|
| io/jawk/frontend/AwkParser.java | 3847[25] |
| io/jawk/frontend/AwkParser.java | 3899[26] |
super(block, expr);
addFlag(AstFlag.BREAKABLE);
addFlag(AstFlag.CONTINUEABLE);
}
@Override
public Address breakAddress() {
return breakAddress;
}
@Override
public Address continueAddress() {
return continueAddress;
}
@Override
public int populateTuples(AwkTuples tuples) {
pushSourceLineNumber(tuples);
breakAddress = tuples.createAddress("breakAddress");
continueAddress = tuples.createAddress("continueAddress");
|
|
| File | Line |
|---|---|
| io/jawk/backend/AVM.java | 1480[27] |
| io/jawk/backend/AVM.java | 1494[28] |
case INC_ARRAY_REF: {
// arg[0] = offset
// arg[1] = isGlobal
// stack[0] = array index
VariableTuple variableTuple = (VariableTuple) tuple;
boolean isGlobal = variableTuple.isGlobal();
Map<Object, Object> aa = ensureMapVariable(variableTuple.getVariableOffset(), isGlobal);
Object key = pop();
checkScalar(key);
Object o = aa.get(key);
aa.put(key, JRT.inc(blankToZero(o)));
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5524[29] |
| io/jawk/frontend/AwkParser.java | 5577[30] |
| io/jawk/frontend/AwkParser.java | 5673[31] |
private PreIncAst(AST symbolAst) {
super(symbolAst);
}
@Override
public int populateTuples(AwkTuples tuples) {
pushSourceLineNumber(tuples);
if (getAst1() instanceof IDAst && isJrtManagedSpecialName(((IDAst) getAst1()).id)) {
// the sequence already leaves the new value on the stack
populateSpecialIncDec(tuples, ((IDAst) getAst1()).id, true, false);
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 3796[32] |
| io/jawk/frontend/AwkParser.java | 3899[26] |
| io/jawk/frontend/AwkParser.java | 3970[33] |
super(expr, block);
addFlag(AstFlag.BREAKABLE);
addFlag(AstFlag.CONTINUEABLE);
}
@Override
public Address breakAddress() {
return breakAddress;
}
@Override
public Address continueAddress() {
return continueAddress;
}
@Override
public int populateTuples(AwkTuples tuples) {
pushSourceLineNumber(tuples);
breakAddress = tuples.createAddress("breakAddress");
|
|
| File | Line |
|---|---|
| io/jawk/backend/AVM.java | 3194[34] |
| io/jawk/backend/AVM.java | 3867[35] |
String orig = jrt.toAwkString(pop()); String repl = jrt.toAwkString(pop()); String ere = jrt.toAwkString(pop()); push(isGsub ? jrt.replaceAll(orig, repl, ere) : jrt.replaceFirst(orig, repl, ere)); |
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5302[36] |
| io/jawk/frontend/AwkParser.java | 5334[37] |
| io/jawk/frontend/AwkParser.java | 5361[38] |
addFlag(AstFlag.NON_STATEMENT);
}
@Override
public String toString() {
return super.toString() + " (" + value + ")";
}
@Override
public int populateTuples(AwkTuples tuples) {
pushSourceLineNumber(tuples);
tuples.push(value);
popSourceLineNumber(tuples);
return 1;
}
}
/**
* Can either assume the role of a double or an integer
* by aggressively normalizing the value to an int if possible.
*/
private final class DoubleAst extends ScalarExpressionAst {
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5642[39] |
| io/jawk/frontend/AwkParser.java | 5685[40] |
if (getAst1() instanceof ArrayReferenceAst) {
((ArrayReferenceAst) getAst1()).populateTargetValueTuples(tuples);
tuples.unaryPlus();
} else {
getAst1().populateTuples(tuples);
}
if (getAst1() instanceof IDAst) {
IDAst idAst = (IDAst) getAst1();
tuples.postInc(idAst.offset, idAst.isGlobal);
|
|
| File | Line |
|---|---|
| io/jawk/jrt/StreamInputSource.java | 349[41] |
| io/jawk/jrt/StreamInputSource.java | 368[42] |
hasFilenames = detectFilenames();
if (partitioningReader == null && !hasFilenames) {
partitioningReader = new PartitioningReader(
new InputStreamReader(defaultInput, StandardCharsets.UTF_8),
jrt.getRSString());
currentReaderIsDefaultInput = true;
jrt.setFILENAMEViaJrt(jrt.toInputScalar(""));
// gawk clears ERRNO whenever the main input advances
// successfully
jrt.setERRNO("");
return true;
}
|
|
| File | Line |
|---|---|
| io/jawk/backend/AVM.java | 1905[43] |
| io/jawk/backend/AVM.java | 1922[44] |
case IS_EMPTY_KEYLIST: {
// arg[0] = address
// stack[0] = Deque
Object o = pop();
if (o == null || !(o instanceof Deque)) {
throw new AwkRuntimeException(
position.lineNumber(),
"Cannot get a key list (via 'in') of a non associative array. arg = " + o.getClass() + ", " + o);
}
Deque<?> keylist = (Deque<?>) o;
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 3796[32] |
| io/jawk/frontend/AwkParser.java | 3847[25] |
| io/jawk/frontend/AwkParser.java | 3970[33] |
super(expr, block);
addFlag(AstFlag.BREAKABLE);
addFlag(AstFlag.CONTINUEABLE);
}
@Override
public Address breakAddress() {
return breakAddress;
}
@Override
public Address continueAddress() {
return continueAddress;
}
@Override
public int populateTuples(AwkTuples tuples) {
pushSourceLineNumber(tuples);
breakAddress = tuples.createAddress("breakAddress");
|
|
| File | Line |
|---|---|
| io/jawk/jrt/AwkPrintf.java | 470[45] |
| io/jawk/jrt/AwkPrintf.java | 508[46] |
if (i < length && format.charAt(i) == '*') {
i++;
int starArgEnd = starPositionEnd(format, i);
if (starArgEnd == i && i < length && isAsciiDigit(format.charAt(i))) {
// Digits after a star operand not terminated by '$' are
// fatal rather than literal, like gawk: "%*2d".
emitError(
segments,
literal,
|
|
| File | Line |
|---|---|
| io/jawk/backend/AVM.java | 2023[47] |
| io/jawk/backend/AVM.java | 2037[48] |
Integer retcode = jrt.jrtConsumeFileInputForGetline(s);
push(retcode);
if (retcode.intValue() == 1) {
push(jrt.toInputScalar(jrt.jrtGetInputString()));
position.next();
} else {
position.jump(tuple.getAddress());
}
break;
}
case USE_AS_COMMAND_INPUT: {
|
|
| File | Line |
|---|---|
| io/jawk/backend/AVM.java | 456[49] |
| io/jawk/backend/AVM.java | 533[50] |
installProgramMetadata(compiledProgram);
jrt.prepareForExecution(settings.getFieldSeparator(), settings.getDefaultRS());
if (!executionSpecialVariables.isEmpty()) {
jrt.applySpecialVariables(executionSpecialVariables);
}
rebindResolvedInputSource(resolvedSource);
executeTuples(compiledProgram.top());
}
/**
* Executes a compiled AWK program while persisting user-defined global
* variables across repeated executions on this AVM instance.
* <p>
* Before the new program starts, this method imports any user-defined
* globals currently materialized in the AVM and remaps them onto the
* incoming program's compiled global slots.
*
* @param program compiled program to execute
* @param inputSource input source providing records
* @throws ExitException when the program terminates via {@code exit}
* @throws IOException if execution fails
*/
public void executePersistingGlobals(AwkProgram program, InputSource inputSource)
|
|
awk
Links:
- [1] https://pmd.github.io/latest/pmd_userdocs_cpd.html
- [2] ./xref/io/jawk/jrt/HashAssocArray.html#L45
- [3] ./xref/io/jawk/jrt/SortedAssocArray.html#L61
- [4] ./xref/io/jawk/SandboxedAwk.html#L121
- [5] ./xref/io/jawk/SandboxedAwk.html#L181
- [6] ./xref/io/jawk/intermediate/AwkTuples.html#L2804
- [7] ./xref/io/jawk/intermediate/AwkTuples.html#L2839
- [8] ./xref/io/jawk/SandboxedAwk.html#L124
- [9] ./xref/io/jawk/intermediate/SandboxedAwkTuples.html#L46
- [10] ./xref/io/jawk/SandboxedAwk.html#L184
- [11] ./xref/io/jawk/frontend/AwkParser.html#L2468
- [12] ./xref/io/jawk/frontend/AwkParser.html#L2494
- [13] ./xref/io/jawk/Awk.html#L1097
- [14] ./xref/io/jawk/backend/AVM.html#L4688
- [15] ./xref/io/jawk/frontend/AwkParser.html#L5538
- [16] ./xref/io/jawk/frontend/AwkParser.html#L5650
- [17] ./xref/io/jawk/frontend/AwkParser.html#L5591
- [18] ./xref/io/jawk/frontend/AwkParser.html#L5693
- [19] ./xref/io/jawk/frontend/AwkParser.html#L2714
- [20] ./xref/io/jawk/frontend/AwkParser.html#L2772
- [21] ./xref/io/jawk/frontend/AwkParser.html#L4077
- [22] ./xref/io/jawk/frontend/AwkParser.html#L4270
- [23] ./xref/io/jawk/frontend/AwkParser.html#L4330
- [24] ./xref/io/jawk/frontend/AwkParser.html#L4373
- [25] ./xref/io/jawk/frontend/AwkParser.html#L3847
- [26] ./xref/io/jawk/frontend/AwkParser.html#L3899
- [27] ./xref/io/jawk/backend/AVM.html#L1480
- [28] ./xref/io/jawk/backend/AVM.html#L1494
- [29] ./xref/io/jawk/frontend/AwkParser.html#L5524
- [30] ./xref/io/jawk/frontend/AwkParser.html#L5577
- [31] ./xref/io/jawk/frontend/AwkParser.html#L5673
- [32] ./xref/io/jawk/frontend/AwkParser.html#L3796
- [33] ./xref/io/jawk/frontend/AwkParser.html#L3970
- [34] ./xref/io/jawk/backend/AVM.html#L3194
- [35] ./xref/io/jawk/backend/AVM.html#L3867
- [36] ./xref/io/jawk/frontend/AwkParser.html#L5302
- [37] ./xref/io/jawk/frontend/AwkParser.html#L5334
- [38] ./xref/io/jawk/frontend/AwkParser.html#L5361
- [39] ./xref/io/jawk/frontend/AwkParser.html#L5642
- [40] ./xref/io/jawk/frontend/AwkParser.html#L5685
- [41] ./xref/io/jawk/jrt/StreamInputSource.html#L349
- [42] ./xref/io/jawk/jrt/StreamInputSource.html#L368
- [43] ./xref/io/jawk/backend/AVM.html#L1905
- [44] ./xref/io/jawk/backend/AVM.html#L1922
- [45] ./xref/io/jawk/jrt/AwkPrintf.html#L470
- [46] ./xref/io/jawk/jrt/AwkPrintf.html#L508
- [47] ./xref/io/jawk/backend/AVM.html#L2023
- [48] ./xref/io/jawk/backend/AVM.html#L2037
- [49] ./xref/io/jawk/backend/AVM.html#L456
- [50] ./xref/io/jawk/backend/AVM.html#L533
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
