[postgis-tickets] r15049 - Adding some commandline options to test_main.c for debugging.

Stephen woodbri at swoodbridge.com
Tue Aug 30 19:23:03 PDT 2016


Author: woodbri
Date: 2016-08-30 19:23:02 -0700 (Tue, 30 Aug 2016)
New Revision: 15049

Modified:
   trunk/extensions/address_standardizer/test_main.c
   trunk/extensions/address_standardizer/tokenize.c
Log:
Adding some commandline options to test_main.c for debugging.
Fixed a bug in tokenize.c to allow MIXED token to follow an AMPERS token in the rules.
This should close #3616


Modified: trunk/extensions/address_standardizer/test_main.c
===================================================================
--- trunk/extensions/address_standardizer/test_main.c	2016-08-28 17:05:38 UTC (rev 15048)
+++ trunk/extensions/address_standardizer/test_main.c	2016-08-31 02:23:02 UTC (rev 15049)
@@ -103,6 +103,7 @@
         if (p == q) break;
         p = q;
         nr++;
+        assert(nr < RULESIZE);
         r++;
     }
 
@@ -111,7 +112,7 @@
 
 void Usage()
 {
-        printf("Usage: test_main [-o n] \n");
+        printf("Usage: test_main [-o n] lex.txt gaz.txt rules.txt \n");
         printf("       -o n = options bit flag\n");
         printf("          1 = print lexicon\n");
         printf("          2 = print gazeteer\n");
@@ -139,15 +140,18 @@
     int err;
     int cnt;
     int option = 0;
+    char *flex;
+    char *fgaz;
+    char *frules;
 
     FILE *in;
 
-    if (argc == 3 && !strcmp(argv[1], "-o")) {
+    if (argc > 3 && !strcmp(argv[1], "-o")) {
         option = strtol(argv[2], NULL, 10);
         argc -= 2;
         argv += 2;
     }
-    else if (argc != 1)
+    else if (argc != 4)
         Usage();
 
     std = std_init();
@@ -156,7 +160,8 @@
     lex = lex_init(std->err_p);
     assert(lex);
 
-    in = fopen(LEXIN, "rb");
+    flex = argv[1];
+    in = fopen(flex, "rb");
     assert(in);
 
     cnt = 0;
@@ -184,7 +189,8 @@
     gaz = lex_init(std->err_p);
     assert(gaz);
 
-    in = fopen(GAZIN, "rb");
+    fgaz = argv[2];
+    in = fopen(fgaz, "rb");
     assert(in);
 
     cnt = 0;
@@ -215,7 +221,8 @@
 
     /* ************ RULES **************** */
 
-    in = fopen(RULESIN, "rb");
+    frules = argv[3];
+    in = fopen(frules, "rb");
     assert(in);
 
     cnt = 0;

Modified: trunk/extensions/address_standardizer/tokenize.c
===================================================================
--- trunk/extensions/address_standardizer/tokenize.c	2016-08-28 17:05:38 UTC (rev 15048)
+++ trunk/extensions/address_standardizer/tokenize.c	2016-08-31 02:23:02 UTC (rev 15049)
@@ -27,7 +27,7 @@
 #include <stddef.h>
 #include "pagc_api.h"
 
-static SYMB precedes_identifier_list[] = { BOXT , ROAD , UNITH , PRETYP , BUILDH , RR , FAIL } ;
+static SYMB precedes_identifier_list[] = { BOXT , ROAD , AMPERS, UNITH , PRETYP , BUILDH , RR , FAIL } ;
 static SYMB precedes_route_list[] = { TYPE , QUALIF , PROV , FAIL } ;
 #ifdef COMBINE_FRACTS_WITH_NUMBS
 static SYMB FractL[] = { FRACT , FAIL } ;



More information about the postgis-tickets mailing list