diff options
author | rbuj <[email protected]> | 2019-08-29 23:42:40 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-09-02 20:19:42 +0200 |
commit | aa9854840929ef823aef40383606cfe10f40cfb7 (patch) | |
tree | cc3fb3f99dab26d186dd140a74e8eebb1d80cec3 /src | |
parent | 793ca81eb4d43c1eb347dfa4567618006521e278 (diff) | |
download | engrampa-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')
-rw-r--r-- | src/java-utils.c | 17 |
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); } |