summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-11-05 02:14:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-11-05 02:14:26 +0900
commit368a1cb3c40ea7fd17809e6d2e78f6a77f770a29 (patch)
tree348b6663957c444148006ac053155fa3f41e4ecb
parent054a4672cb8dbb9edb3f84c14c09ac17fbec1102 (diff)
Do not use non-ASCII chars in sources
No encodings are guaranteed in C compilers, and other than UTF-8 encodings may be assumed in some platforms, e.g., CP932 on Windows Japanese edition, and may result in compilation errors.
-rw-r--r--coroutine/ppc/Context.S2
-rw-r--r--coroutine/ppc/Context.h2
-rw-r--r--coroutine/ppc64/Context.h2
-rw-r--r--prism/regexp.c24
-rwxr-xr-xprism/templates/template.rb4
5 files changed, 19 insertions, 15 deletions
diff --git a/coroutine/ppc/Context.S b/coroutine/ppc/Context.S
index cdda93e179..e2431a9250 100644
--- a/coroutine/ppc/Context.S
+++ b/coroutine/ppc/Context.S
@@ -3,7 +3,7 @@
; Some relevant examples: https://github.com/gcc-mirror/gcc/blob/master/libphobos/libdruntime/config/powerpc/switchcontext.S
; https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/rs6000/darwin-gpsave.S
; https://www.ibm.com/docs/en/aix/7.2?topic=epilogs-saving-gprs-only
-; ppc32 version may be re-written compactly with stmw/lwm, but the code wonʼt be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
+; ppc32 version may be re-written compactly with stmw/lwm, but the code won't be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
; Notice that this code is only for Darwin (macOS). Darwin ABI differs from AIX and ELF.
; To add support for AIX, *BSD or *Linux, please make separate implementations.
diff --git a/coroutine/ppc/Context.h b/coroutine/ppc/Context.h
index 1fce112579..8035d08556 100644
--- a/coroutine/ppc/Context.h
+++ b/coroutine/ppc/Context.h
@@ -13,7 +13,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/coroutine/ppc64/Context.h b/coroutine/ppc64/Context.h
index 3e6f77f55a..085b475ed5 100644
--- a/coroutine/ppc64/Context.h
+++ b/coroutine/ppc64/Context.h
@@ -12,7 +12,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/prism/regexp.c b/prism/regexp.c
index 22833d177f..cd52857f79 100644
--- a/prism/regexp.c
+++ b/prism/regexp.c
@@ -116,18 +116,18 @@ pm_regexp_char_find(pm_regexp_parser_t *parser, uint8_t value) {
* The properly track everything, we're going to build a little state machine.
* It looks something like the following:
*
- * ┌───────┐ ┌─────────┐ ────────────┐
- * ──── lbrace ───> │ start │ ──── digit ───> │ minimum │ │
- * └───────┘ └─────────┘ <─── digit ─┘
- * │ │ │
- * ┌───────┐ │ │ rbrace
- * │ comma │ <───── comma ┌──── comma ───────┘ │
- * └───────┘ V V
- * │ ┌─────────┐ ┌─────────┐
- * └── digit ──> │ maximum │ ── rbrace ──> │| final |│
- * └─────────┘ └─────────┘
- * │ ^
- * └─ digit ─┘
+ * +-------+ +---------+ ------------+
+ * ---- lbrace ---> | start | ---- digit ---> | minimum | |
+ * +-------+ +---------+ <--- digit -+
+ * | | |
+ * +-------+ | | rbrace
+ * | comma | <----- comma +---- comma -------+ |
+ * +-------+ V V
+ * | +---------+ +---------+
+ * +-- digit --> | maximum | -- rbrace --> || final ||
+ * +---------+ +---------+
+ * | ^
+ * +- digit -+
*
* Note that by the time we've hit this function, the lbrace has already been
* consumed so we're in the start state.
diff --git a/prism/templates/template.rb b/prism/templates/template.rb
index 553dbb5504..8a9825dfc0 100755
--- a/prism/templates/template.rb
+++ b/prism/templates/template.rb
@@ -360,6 +360,7 @@ module Prism
=end
HEADING
else
+ escape = true
<<~HEADING
/******************************************************************************/
/* This file is generated by the templates/template.rb script and should not */
@@ -373,6 +374,9 @@ module Prism
write_to ||= File.expand_path("../#{name}", __dir__)
contents = heading + erb.result_with_hash(locals)
+ if escape
+ (contents = contents.b).gsub!(/[^\t-~]/) {|c| "\\x%.2x" % c.ord}
+ end
FileUtils.mkdir_p(File.dirname(write_to))
File.write(write_to, contents)