hoijui / Jawk

Java AWK interpreter/compiler
GNU General Public License v3.0
39 stars 23 forks source link

Bug: Comparison of zero to uninitialized variable returns true, and handling of long integers #13

Open bertysentry opened 6 years ago

bertysentry commented 6 years ago

The below script Awk prints "wrong":

// { a = 0 ; if (a == "") { print "wrong" } else { print "right" } }

Also, integer numbers greater than 2^31 are treated as Double, and output with a pseudo-scientific notation (3.45789E+9), which is not the behavior of the "official" awk.

bertysentry commented 6 years ago

I will shoot another PR for this. Thanks!

cdrasmussen commented 6 years ago

Hmm. Interesting. What do you regard as the official AWK?

+CDR

On Feb 2, 2018 6:43 PM, "Bertrand Martin" notifications@github.com wrote:

The below script Awk prints "wrong":

// { a = 0 ; if (a == "") { print "wrong" } else { print "right" } }

Also, integer numbers greater than 2^31 are treated as Double, and output with a pseudo-scientific notation (3.45789E+9), which is not the behavior of the "official" awk.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hoijui/Jawk/issues/13, or mute the thread https://github.com/notifications/unsubscribe-auth/ADAU9IaCT1ODhG6GrBagmX3c6XBgEPxpks5tQ52WgaJpZM4R37Lo .

bertysentry commented 6 years ago

Good question! ;-) What I consider as one official AWK, is GNU AWK: https://www.gnu.org/software/gawk/manual/html_node/Strings-And-Numbers.html

But I don't want to enter a political debate over AWK :-D

cdrasmussen commented 6 years ago

I agree. Gawk is well done. It is a proper superset of the Bell Labs version and the convenience functions that they added.

I would like to eventually see Jawk with those same extensions as long as the core Bell Labs compliant, if I can use that as a standard.

+CDR

On Feb 3, 2018 6:58 AM, "Bertrand Martin" notifications@github.com wrote:

Good question! ;-) What I consider as one official AWK, is GNU AWK: https://www.gnu.org/software/gawk/manual/html_node/Strings- And-Numbers.html

But I don't want to enter a political debate over AWK :-D

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hoijui/Jawk/issues/13#issuecomment-362800915, or mute the thread https://github.com/notifications/unsubscribe-auth/ADAU9AkkrpKeiReb2zhweOs1SsxqwRhrks5tREnNgaJpZM4R37Lo .