bodensx / jnaerator

Automatically exported from code.google.com/p/jnaerator
0 stars 0 forks source link

Octal numbers are not parsed properly #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. On Ubuntu 10.04, try to JNAerate /usr/include/linux/if.h
2. It fails with the following error:

Exception for /usr/include/bits/sockaddr.h at line 
3265:java.util.concurrent.ExecutionException: java.lang.Exception: 
java.lang.IllegalArgumentException: Expected octal literal, got 02000000
java.util.concurrent.ExecutionException: java.lang.Exception: 
java.lang.IllegalArgumentException: Expected octal literal, got 02000000
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
    at java.util.concurrent.FutureTask.get(FutureTask.java:119)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parseSlices(JNAeratorParser.java:177)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parse(JNAeratorParser.java:213)
    at com.ochafik.lang.jnaerator.JNAerator.parseSources(JNAerator.java:1111)
    at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:816)
    at com.ochafik.lang.jnaerator.studio.JNAeratorStudio$14.run(JNAeratorStudio.java:603)
Caused by ... (snipped)

But "02000000" is a valid octal number.

This is with the jnaerator version from the Java webstart.

Looking at the latest SVN code for parseOctal() in 
com.ochafik.lang.jnaerator.parser.Expression:

                public static Constant parseOctal(String string, boolean negate) {
                        string = string.trim().toLowerCase();
                        if (!string.startsWith("\\"))
                                throw new IllegalArgumentException("Expected octal literal, got " + string);

                        return parseDecimal(string.substring(2), 8, IntForm.Octal, negate);
                }

Octal numbers do not start with "\\", and only a single digit - the leading "0" 
- needs to be stripped when calling parseDecimal().

Original issue reported on code.google.com by damjan....@gmail.com on 30 Nov 2010 at 11:15

GoogleCodeExporter commented 8 years ago
Hello Damjan,

Thanks a lot for your report.
Silly me, I messed this syntax up with octal escapes in strings :-S.

It's on the top of my list, stay tuned !
Cheers
--
Olivier

Original comment by olivier.chafik@gmail.com on 30 Nov 2010 at 3:57

GoogleCodeExporter commented 8 years ago
Fixed by http://code.google.com/p/nativelibs4java/source/detail?r=1407, will 
upload a new snapshot in a few days (in the meanwhile, you can build from 
sources using these instructions : 
http://code.google.com/p/jnaerator/wiki/CompilingJNAerator).

Thanks again,
Cheers
--
Olivier

Original comment by olivier.chafik@gmail.com on 30 Nov 2010 at 5:11