remove obsolete /opt/local include/lib directories on mac os x
[oweals/jsonpath.git] / ast.c
diff --git a/ast.c b/ast.c
index 5093e8b5167b61f19473e7536ab80d530ff36536..3f88d947d3ff70e613d678c8c3ab97e2c0544b89 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2013-2014 Jo-Philipp Wich <jo@mein.io>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -73,9 +73,6 @@ jp_free(struct jp_state *s)
                op = tmp;
        }
 
-       if (s->error)
-               free(s->error);
-
        free(s);
 }
 
@@ -101,18 +98,11 @@ jp_parse(const char *expr)
 
        while (len > 0)
        {
-               s->off = (ptr - expr);
-
                op = jp_get_token(s, ptr, &mlen);
 
                if (mlen < 0)
                {
-                       s->erroff = s->off;
-                       s->error = strdup((mlen == -3) ? "String too long" :
-                                                               (mlen == -2) ? "Invalid escape sequence" :
-                                                                       (mlen == -1) ? "Unterminated string" :
-                                                                               "Unknown error");
-
+                       s->error_code = mlen;
                        goto out;
                }
 
@@ -121,6 +111,8 @@ jp_parse(const char *expr)
 
                len -= mlen;
                ptr += mlen;
+
+               s->off += mlen;
        }
 
        Parse(pParser, 0, NULL, s);