You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/04/12 16:14:35 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #8783: Adds a simple tool to generate new escape tables

bneradt commented on code in PR #8783:
URL: https://github.com/apache/trafficserver/pull/8783#discussion_r848619204


##########
tools/escape_mapper/escape_mapper.c:
##########
@@ -0,0 +1,80 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+void
+add_mapping(unsigned char *table, char c)
+{
+  int i = c / 8;
+  int x = 7 - c % 8;
+  int r = 1 << x;
+
+  table[i] = table[i] | r;
+}
+
+int
+main(int argc, char *argv[])
+{
+  // only support a single arg that contains all the chars we wish to escapify
+  if (argc > 1 && argc != 2) {
+    printf("Provide a single argument with a list of characters to add to the default encoding table\n");
+    return (1);
+  }
+
+  // default characters supported by the codes_to_escape table found in LogUtils.cc

Review Comment:
   It would be good to add a comment above codes_to_escape requesting developers who modify it to modify this tool.



##########
tools/Makefile.am:
##########
@@ -54,6 +54,14 @@ http_load_http_load_SOURCES = \
 
 endif
 
+if BUILD_TEST_TOOLS
+bin_PROGRAMS += escape_mapper/escape_mapper
+else
+noinst_PROGRAMS += escape_mapper/escape_mapper
+endif

Review Comment:
   Let's add `tools/escape_mapper/escape_mapper` to the .gitignore file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org