Skip to content

Commit 131115b

Browse files
committed
cleanup
1 parent bd745cc commit 131115b

File tree

5 files changed

+5
-137
lines changed

5 files changed

+5
-137
lines changed

src/main/java/org/perlonjava/operators/Pack.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ public static RuntimeScalar pack(RuntimeList args) {
5656

5757
// Track if 'U' was used in normal mode (not byte mode)
5858
boolean hasUnicodeInNormalMode = false;
59-
60-
// Stack to track byte order for nested groups
61-
java.util.Stack<Character> groupEndianStack = new java.util.Stack<>();
62-
groupEndianStack.push(' '); // Default: no specific endianness
63-
59+
6460
for (int i = 0; i < template.length(); i++) {
6561
char format = template.charAt(i);
6662
System.err.println("DEBUG: main loop i=" + i + ", format='" + format + "' (code " + (int)format + ")");
@@ -902,25 +898,4 @@ private static int countValuesNeeded(String template) {
902898
return count;
903899
}
904900

905-
private static char findLastNumericFormat(String template) {
906-
char lastNumeric = '\0';
907-
for (int i = 0; i < template.length(); i++) {
908-
char c = template.charAt(i);
909-
if (isNumericFormat(c) || c == 'Z') {
910-
lastNumeric = c;
911-
} else if (c == '(') {
912-
// Skip the group
913-
int closePos = findMatchingParen(template, i);
914-
if (closePos != -1) {
915-
// Check inside the group
916-
char groupNumeric = findLastNumericFormat(template.substring(i + 1, closePos));
917-
if (groupNumeric != '\0') {
918-
lastNumeric = groupNumeric;
919-
}
920-
i = closePos;
921-
}
922-
}
923-
}
924-
return lastNumeric;
925-
}
926901
}

src/main/java/org/perlonjava/operators/pack/NullPadHandler.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/org/perlonjava/operators/pack/PackFormatHandler.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/java/org/perlonjava/operators/pack/PackHelper.java

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,10 @@ public static void writeHexString(ByteArrayOutputStream output, String str, int
113113
* Check if the format is an integer format that should reject Inf/NaN values
114114
*/
115115
public static boolean isIntegerFormat(char format) {
116-
switch (format) {
117-
case 'c':
118-
case 'C':
119-
case 's':
120-
case 'S':
121-
case 'l':
122-
case 'L':
123-
case 'i':
124-
case 'I':
125-
case 'n':
126-
case 'N':
127-
case 'v':
128-
case 'V':
129-
case 'j':
130-
case 'J':
131-
case 'w':
132-
case 'W':
133-
case 'U':
134-
return true;
135-
default:
136-
return false;
137-
}
116+
return switch (format) {
117+
case 'c', 'C', 's', 'S', 'l', 'L', 'i', 'I', 'n', 'N', 'v', 'V', 'j', 'J', 'w', 'W', 'U' -> true;
118+
default -> false;
119+
};
138120
}
139121

140122
/**
@@ -155,27 +137,6 @@ public static void writeBER(ByteArrayOutputStream output, long value) {
155137
}
156138
}
157139

158-
/**
159-
* Validates the '/' format in pack/unpack templates.
160-
*/
161-
public static char validateSlashFormat(String template, int position) {
162-
if (position + 1 >= template.length()) {
163-
throw new PerlCompilerException("Code missing after '/'");
164-
}
165-
166-
char afterSlash = template.charAt(position + 1);
167-
168-
if (afterSlash == '*' || Character.isDigit(afterSlash)) {
169-
throw new PerlCompilerException("'/' does not take a repeat count");
170-
}
171-
172-
if (afterSlash != 'a' && afterSlash != 'A' && afterSlash != 'Z') {
173-
throw new PerlCompilerException("'/' must be followed by a string type");
174-
}
175-
176-
return afterSlash;
177-
}
178-
179140
/**
180141
* Writes a short integer to the output stream in little-endian order.
181142
*
@@ -330,13 +291,6 @@ public static void writeString(ByteArrayOutputStream output, String str, int cou
330291
}
331292
}
332293

333-
/**
334-
* Overloaded writeString for backward compatibility
335-
*/
336-
private static void writeString(ByteArrayOutputStream output, String str, int count, char format) {
337-
writeString(output, str, count, format, false);
338-
}
339-
340294
/**
341295
* Writes a bit string to the output stream based on the specified format and count.
342296
*

src/main/java/org/perlonjava/operators/pack/PackModifiers.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)