public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "lijunlong at openresty dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/31119] did not escape Golang program symbol name
Date: Thu, 07 Dec 2023 02:50:19 +0000	[thread overview]
Message-ID: <bug-31119-6586-uHQy7mioGA@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31119-6586@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31119

--- Comment #2 from lijunlong <lijunlong at openresty dot com> ---
Comment on attachment 15242
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15242
did not escape golang symbol

commit d10ae580f8791606739ae6bfa7db7277d6921cc9
Author: lijunlong <lijunlong@openresty.com>
Date:   Thu Dec 7 10:49:37 2023 +0800

    bugfix: escape char should cast to 'unsigned char' instead of 'unsigned'.

diff --git a/util.cxx b/util.cxx
index f2eaf54f4..7a1081654 100644
--- a/util.cxx
+++ b/util.cxx
@@ -1301,10 +1301,9 @@ octal_character (unsigned c)
   return '0' + c % 8;
 }

-string
-escaped_character (unsigned c)
+static inline void
+escaped_character_impl (unsigned c, ostringstream &o)
 {
-  ostringstream o;
   int oc = (int)c;

   switch (oc)
@@ -1362,18 +1361,28 @@ escaped_character (unsigned c)
             << octal_character(oc);
         }
     }
+}
+
+string
+escaped_character (unsigned c)
+{
+  ostringstream o;
+
+  escaped_character_impl(c, o);
+
   return o.str();
 }

 string
 escaped_literal_string (const string& str)
 {
-  string op;
+  ostringstream o;
+
   for (unsigned i = 0; i < str.size (); i++)
     {
-      op += escaped_character((unsigned)str[i]);
+      escaped_character_impl((unsigned char)str[i], o);
     }
-  return op;
+  return o.str();
 }

 string

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2023-12-07  2:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  0:44 [Bug translator/31119] New: " lijunlong at openresty dot com
2023-12-07  2:50 ` [Bug translator/31119] " lijunlong at openresty dot com
2023-12-07  2:50 ` lijunlong at openresty dot com [this message]
2023-12-13 15:35 ` wcohen at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31119-6586-uHQy7mioGA@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).