Jawk 7.3.00
-
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 | 2798[6] |
| io/jawk/intermediate/AwkTuples.java | 2833[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 | 2417[11] |
| io/jawk/frontend/AwkParser.java | 2441[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/jrt/JRT.java | 1854[13] |
| io/jawk/jrt/JRT.java | 1915[14] |
public static String prepareSubReplacement(String awkRepl, boolean posix) {
if (awkRepl == null) {
return "";
}
if (awkRepl.indexOf('\\') == -1 && awkRepl.indexOf('$') == -1 && awkRepl.indexOf('&') == -1) {
return awkRepl;
}
StringBuilder javaRepl = new StringBuilder();
int length = awkRepl.length();
for (int i = 0; i < length; i++) {
char c = awkRepl.charAt(i);
if (c != '\\') {
appendLiteral(javaRepl, c);
|
|
| File | Line |
|---|---|
| io/jawk/Awk.java | 1075[15] |
| io/jawk/backend/AVM.java | 4576[16] |
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 | 5454[17] |
| io/jawk/frontend/AwkParser.java | 5566[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();
} else if (getAst1() instanceof DollarExpressionAst) {
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 5454[17] |
| io/jawk/frontend/AwkParser.java | 5507[19] |
| io/jawk/frontend/AwkParser.java | 5566[18] |
| io/jawk/frontend/AwkParser.java | 5609[20] |
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 | 2657[21] |
| io/jawk/frontend/AwkParser.java | 2712[22] |
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 | 4007[23] |
| io/jawk/frontend/AwkParser.java | 4200[24] |
| io/jawk/frontend/AwkParser.java | 4260[25] |
| io/jawk/frontend/AwkParser.java | 4303[26] |
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 | 3777[27] |
| io/jawk/frontend/AwkParser.java | 3829[28] |
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 | 1463[29] |
| io/jawk/backend/AVM.java | 1477[30] |
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 | 5440[31] |
| io/jawk/frontend/AwkParser.java | 5493[32] |
| io/jawk/frontend/AwkParser.java | 5589[33] |
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/backend/AVM.java | 452[34] |
| io/jawk/backend/AVM.java | 525[35] |
installProgramMetadata(compiledProgram);
jrt.setPosix(compiledProgram.isPosix());
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) throws ExitException, IOException {
|
|
| File | Line |
|---|---|
| io/jawk/frontend/AwkParser.java | 3726[36] |
| io/jawk/frontend/AwkParser.java | 3829[28] |
| io/jawk/frontend/AwkParser.java | 3900[37] |
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 | 3127[38] |
| io/jawk/backend/AVM.java | 3792[39] |
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 | 5218[40] |
| io/jawk/frontend/AwkParser.java | 5250[41] |
| io/jawk/frontend/AwkParser.java | 5277[42] |
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 | 5558[43] |
| io/jawk/frontend/AwkParser.java | 5601[44] |
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 | 350[45] |
| io/jawk/jrt/StreamInputSource.java | 369[46] |
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 | 1882[47] |
| io/jawk/backend/AVM.java | 1899[48] |
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 | 3726[36] |
| io/jawk/frontend/AwkParser.java | 3777[27] |
| io/jawk/frontend/AwkParser.java | 3900[37] |
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 | 465[49] |
| io/jawk/jrt/AwkPrintf.java | 503[50] |
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 | 2002[51] |
| io/jawk/backend/AVM.java | 2016[52] |
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: {
|
|
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#L2798
- [7] ./xref/io/jawk/intermediate/AwkTuples.html#L2833
- [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#L2417
- [12] ./xref/io/jawk/frontend/AwkParser.html#L2441
- [13] ./xref/io/jawk/jrt/JRT.html#L1854
- [14] ./xref/io/jawk/jrt/JRT.html#L1915
- [15] ./xref/io/jawk/Awk.html#L1075
- [16] ./xref/io/jawk/backend/AVM.html#L4576
- [17] ./xref/io/jawk/frontend/AwkParser.html#L5454
- [18] ./xref/io/jawk/frontend/AwkParser.html#L5566
- [19] ./xref/io/jawk/frontend/AwkParser.html#L5507
- [20] ./xref/io/jawk/frontend/AwkParser.html#L5609
- [21] ./xref/io/jawk/frontend/AwkParser.html#L2657
- [22] ./xref/io/jawk/frontend/AwkParser.html#L2712
- [23] ./xref/io/jawk/frontend/AwkParser.html#L4007
- [24] ./xref/io/jawk/frontend/AwkParser.html#L4200
- [25] ./xref/io/jawk/frontend/AwkParser.html#L4260
- [26] ./xref/io/jawk/frontend/AwkParser.html#L4303
- [27] ./xref/io/jawk/frontend/AwkParser.html#L3777
- [28] ./xref/io/jawk/frontend/AwkParser.html#L3829
- [29] ./xref/io/jawk/backend/AVM.html#L1463
- [30] ./xref/io/jawk/backend/AVM.html#L1477
- [31] ./xref/io/jawk/frontend/AwkParser.html#L5440
- [32] ./xref/io/jawk/frontend/AwkParser.html#L5493
- [33] ./xref/io/jawk/frontend/AwkParser.html#L5589
- [34] ./xref/io/jawk/backend/AVM.html#L452
- [35] ./xref/io/jawk/backend/AVM.html#L525
- [36] ./xref/io/jawk/frontend/AwkParser.html#L3726
- [37] ./xref/io/jawk/frontend/AwkParser.html#L3900
- [38] ./xref/io/jawk/backend/AVM.html#L3127
- [39] ./xref/io/jawk/backend/AVM.html#L3792
- [40] ./xref/io/jawk/frontend/AwkParser.html#L5218
- [41] ./xref/io/jawk/frontend/AwkParser.html#L5250
- [42] ./xref/io/jawk/frontend/AwkParser.html#L5277
- [43] ./xref/io/jawk/frontend/AwkParser.html#L5558
- [44] ./xref/io/jawk/frontend/AwkParser.html#L5601
- [45] ./xref/io/jawk/jrt/StreamInputSource.html#L350
- [46] ./xref/io/jawk/jrt/StreamInputSource.html#L369
- [47] ./xref/io/jawk/backend/AVM.html#L1882
- [48] ./xref/io/jawk/backend/AVM.html#L1899
- [49] ./xref/io/jawk/jrt/AwkPrintf.html#L465
- [50] ./xref/io/jawk/jrt/AwkPrintf.html#L503
- [51] ./xref/io/jawk/backend/AVM.html#L2002
- [52] ./xref/io/jawk/backend/AVM.html#L2016
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
