summaryrefslogtreecommitdiff
path: root/src/java-utils.c
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-08-29 23:42:40 +0200
committerraveit65 <[email protected]>2019-09-02 20:19:42 +0200
commitaa9854840929ef823aef40383606cfe10f40cfb7 (patch)
treecc3fb3f99dab26d186dd140a74e8eebb1d80cec3 /src/java-utils.c
parent793ca81eb4d43c1eb347dfa4567618006521e278 (diff)
downloadengrampa-aa9854840929ef823aef40383606cfe10f40cfb7.tar.bz2
engrampa-aa9854840929ef823aef40383606cfe10f40cfb7.tar.xz
java-utils: Remove blank spaces before reading package name
Closes https://github.com/mate-desktop/engrampa/issues/291 Test: touch test.txt zip test.zip test.txt mv test.zip test.jar cat << EOF > HelloWorld.java package org.mate.tests; class HelloWorld { public static void main(String args[]) { System.out.println("Hello, World"); } } EOF engrampa -a test.jar HelloWorld.java jar tf test.jar Output: test.txt org/mate/tests/HelloWorld.java
Diffstat (limited to 'src/java-utils.c')
-rw-r--r--src/java-utils.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/java-utils.c b/src/java-utils.c
index 5b36a9c..ce77c8d 100644
--- a/src/java-utils.c
+++ b/src/java-utils.c
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <ctype.h>
#include <glib.h>
#include "java-utils.h"
@@ -424,13 +425,23 @@ get_package_name_from_java_file (char *fname)
int index = 0;
while (read (cfile->fd, &ch, 1) == 1) {
+ if ((ch != ' ') && (ch != '\t'))
+ break;
+ }
+ do {
if (ch == ';')
break;
- if (ch == '.')
+ if (ch == '.') {
buffer[index++] = '/';
- else
+ } else if (isalnum (ch) != 0) {
buffer[index++] = ch;
- }
+ } else if ((ch == '_') || (ch == '$')) {
+ buffer[index++] = ch;
+ } else {
+ index = 0;
+ break;
+ }
+ } while (read (cfile->fd, &ch, 1) == 1);
buffer[index] = 0;
package = g_strdup (buffer);
}