<div dir="ltr"><div><div><div>Hi Дмитрий<br><br></div>Thanx for this. This is great.<br><br></div>I'm going to update and test.<br><br></div><div>Best regards to all nginx team, <br><br>------------------------------<wbr>--------<br>
Paulo Pacheco | Паулу Пашеку<br><br></div><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 31, 2017 at 12:56 PM, Dmitry Volyntsev <span dir="ltr"><<a href="mailto:xeioex@nginx.com" target="_blank">xeioex@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi, Paulo<br>
<br>
the support for hexadecimal literal values was committed in <a href="http://hg.nginx.org/njs/rev/a38c33e9f728" rel="noreferrer" target="_blank">http://hg.nginx.org/njs/rev/a3<wbr>8c33e9f728</a><br>
<br>
Thank you for prodding.<span class="gmail-m_-7238246515718702302gmail-"><br>
<br>
On <a href="tel:21.05.2017%2020" value="+12105201720" target="_blank">21.05.2017 20</a>:52, Paulo Pacheco wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
# HG changeset patch<br>
# User Paulo Pacheco <<a href="mailto:fooinha@gmail.com" target="_blank">fooinha@gmail.com</a> <mailto:<a href="mailto:fooinha@gmail.com" target="_blank">fooinha@gmail.com</a>>><div><div class="gmail-m_-7238246515718702302gmail-h5"><br>
# Date 1495388206 0<br>
# Sun May 21 17:36:46 2017 +0000<br>
# Node ID 22db6b6a3a0eebff8453fb22035628<wbr>410c05c5c8<br>
# Parent 96fda9957427e1ea78d0096b019a3f<wbr>3183db7346<br>
[njs] Lexer support for hexadecimal literal values.<br>
<br>
diff -r 96fda9957427 -r 22db6b6a3a0e njs/njs_lexer.c<br>
--- a/njs/njs_lexer.c Wed Apr 19 17:48:56 2017 +0300<br>
+++ b/njs/njs_lexer.c Sun May 21 17:36:46 2017 +0000<br>
@@ -19,7 +19,7 @@<br>
#include <njs_variable.h><br>
#include <njs_parser.h><br>
#include <string.h><br>
-<br>
+#include <stdlib.h><br>
<br>
typedef struct njs_lexer_multi_s njs_lexer_multi_t;<br>
<br>
@@ -539,10 +539,28 @@<br>
{<br>
u_char c, *p;<br>
double num, frac, scale;<br>
+ char *endptr;<br>
<br>
/* TODO: "1e2" */<br>
<br>
p = lexer->start;<br>
+<br>
+ /* Hexadecimal literal values */<br>
+ if ( (lexer->end - lexer->start) > 2<br>
+ && (*p == 'x' || *p == 'X')<br>
+ && (lexer->prev_token > 0<br>
+ || ((lexer->start - 1) == lexer->text.start)<br>
+ )<br>
+ && (*(p-1) == '0')) {<br>
+<br>
+ lexer->number = strtod((const char *) p-1, &endptr);<br>
+ if ((u_char *) endptr <= lexer->end) {<br>
+ lexer->start = (u_char *) endptr;<br>
+ return NJS_TOKEN_NUMBER;<br>
+ }<br>
+ lexer->number = 0;<br>
+ }<br>
+<br>
c = p[-1];<br>
<br>
/* Values below '0' become >= 208. */<br>
diff -r 96fda9957427 -r 22db6b6a3a0e njs/test/njs_unit_test.c<br>
--- a/njs/test/njs_unit_test.c Wed Apr 19 17:48:56 2017 +0300<br>
+++ b/njs/test/njs_unit_test.c Sun May 21 17:36:46 2017 +0000<br>
@@ -112,6 +112,18 @@<br>
{ nxt_string("+1"),<br>
nxt_string("1") },<br>
<br>
+ { nxt_string("var a = 0x01; a"),<br>
+ nxt_string("1") },<br>
+<br>
+ { nxt_string("var x = 0xffff; x"),<br>
+ nxt_string("65535") },<br>
+<br>
+ { nxt_string("0x01"),<br>
+ nxt_string("1") },<br>
+<br>
+ { nxt_string("0xffff"),<br>
+ nxt_string("65535") },<br>
+<br>
{ nxt_string("+1\n"),<br>
nxt_string("1") },<br>
<br>
<br>
------------------------------<wbr>---- CUT HERE<br>
------------------------------<wbr>--------<br>
Paulo Pacheco | Паулу Пашеку<br>
<br>
<br>
<br>
<br></div></div>
______________________________<wbr>_________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx-devel</a><br>
<br>
</blockquote>
</blockquote></div><br></div></div></div></div></div></div>