Extend enterprises.tsv to accept spaces as separators
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Mon, 17 Jul 2017 19:47:38 +0000 (20:47 +0100)
committerAnders Broman <a.broman58@gmail.com>
Tue, 18 Jul 2017 04:41:12 +0000 (04:41 +0000)
We can do so easily because the format is so simple. This makes it
more convenient for a user to hand-edit a dictionary in the personal
config folder. We still use tabs in the system file for a small space
gain.

Also add a brief description of the format as a comment.

Change-Id: If3f741bff16f1f42c8ef07d643dc6463caaad1a5
Reviewed-on: https://code.wireshark.org/review/22678
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
enterprises.tsv
epan/addr_resolv.c
tools/make-sminmpec.pl

index caa44f4c0787f0ede1134f08a6f61ff1de57acee..700508b9ec76f50a533f4a402146a04ca6bf5379 100644 (file)
@@ -2,6 +2,9 @@
 # generated from http://www.iana.org/assignments/enterprise-numbers
 # run "tools/make-sminmpec.pl [infile]" to regenerate
 #
+# The format used here is: <NUMERICAL_ID><SPACE><NAME>
+# Where SPACE can be any sequence of spaces and tabs.
+#
 # (last updated 2017-07-14)
 
 0      Reserved
index 9bbab22cb515aef6033224f6598e9b5194671cc6..3d0aab8055b3bb0dcb02e00a8433c3ac3562bb2a 100644 (file)
@@ -385,16 +385,6 @@ typedef struct {
  *  Miscellaneous functions
  */
 
-static char *
-remove_comment_and_strip_line(char *buf)
-{
-    char *tok;
-
-    if ((tok = strchr(buf, '#')))
-        *tok = '\0';
-    return g_strstrip(buf);
-}
-
 static int
 fgetline(char **buf, int *size, FILE *fp)
 {
@@ -698,14 +688,17 @@ service_name_lookup_cleanup(void)
 static void
 parse_enterprises_line (char *line)
 {
-    char *str, *dec_str, *org_str;
+    char *tok, *dec_str, *org_str;
     guint32 dec;
 
-    str = remove_comment_and_strip_line(line);
-    dec_str = strtok(str, "\t");
+    if ((tok = strchr(line, '#')))
+        *tok = '\0';
+    dec_str = strtok(line, " \t");
     if (!dec_str)
         return;
-    org_str = strtok(NULL, "\t");
+    org_str = strtok(NULL, ""); /* everything else */
+    if (org_str)
+        org_str = g_strstrip(org_str);
     if (!org_str)
         return;
     if (!ws_strtou32(dec_str, NULL, &dec))
index e00583f4504bb232a57a6bafd000c691570dbe3a..0c0019ecd22926a81a32a64b36eb1e6bf59e27f6 100755 (executable)
@@ -96,6 +96,9 @@ print OUT <<"_SMINMPEC";
 # generated from http://www.iana.org/assignments/enterprise-numbers
 # run "tools/make-sminmpec.pl [infile]" to regenerate
 #
+# The format used here is: <NUMERICAL_ID><SPACE><NAME>
+# Where SPACE can be any sequence of spaces and tabs.
+#
 # $last_updated
 $body
 _SMINMPEC