summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/luatexdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/inputstack.w89
2 files changed, 66 insertions, 27 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog
index 2273375d482..7719ca4a8cf 100644
--- a/Build/source/texk/web2c/luatexdir/ChangeLog
+++ b/Build/source/texk/web2c/luatexdir/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-31 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * tex/inputstack.w: Sync with the upstream.
+
2015-10-13 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* tex/mlist.w: Sync with the upstream.
diff --git a/Build/source/texk/web2c/luatexdir/tex/inputstack.w b/Build/source/texk/web2c/luatexdir/tex/inputstack.w
index 129f2207650..0f591c3c776 100644
--- a/Build/source/texk/web2c/luatexdir/tex/inputstack.w
+++ b/Build/source/texk/web2c/luatexdir/tex/inputstack.w
@@ -234,36 +234,71 @@ void set_trick_count(void)
trick_count = error_line;
}
-#define begin_pseudoprint() do { \
- l=tally; tally=0; selector=pseudo; \
- trick_count=1000000; \
+#define begin_pseudoprint() do { \
+ l=tally; \
+ tally=0; \
+ selector=pseudo; \
+ trick_count=1000000; \
} while (0)
-#define PSEUDO_PRINT_THE_LINE() do { \
- begin_pseudoprint(); \
- if (buffer[ilimit]==end_line_char) j=ilimit; \
- else j=ilimit+1; /* determine the effective end of the line */ \
- if (j>0) { \
- for (i=istart;i<=j-1;i++) { \
- if (i==iloc) set_trick_count(); \
- print_char(buffer[i]); \
- } \
- } \
- } while (0)
+#define PSEUDO_PRINT_THE_LINE() do { \
+ begin_pseudoprint(); \
+ if (buffer[ilimit]==end_line_char) \
+ j=ilimit; \
+ else \
+ j=ilimit+1; /* determine the effective end of the line */ \
+ if (j>0) { \
+ for (i=istart;i<=j-1;i++) { \
+ if (i==iloc) \
+ set_trick_count(); \
+ print_char(buffer[i]); \
+ } \
+ } \
+} while (0)
+
+/*
+ We don't care too much if we stay a bit too much below the max error_line
+ even if we have more room on the line. If length is really an issue then
+ any length is. After all on can set the length larger.
+*/
+
+#define print_valid_utf8(q) do { \
+ c = (int)trick_buf[q % error_line]; \
+ if (c < 128) { \
+ print_char(c); \
+ } else if (c < 194) { \
+ /* invalid */ \
+ } else if (c < 224) { \
+ print_char(c); \
+ print_char(trick_buf[(q+1) % error_line]); \
+ } else if (c < 240) { \
+ print_char(c); \
+ print_char(trick_buf[(q+1) % error_line]); \
+ print_char(trick_buf[(q+2) % error_line]); \
+ } else if (c < 245) { \
+ print_char(c); \
+ print_char(trick_buf[(q+1) % error_line]); \
+ print_char(trick_buf[(q+2) % error_line]); \
+ print_char(trick_buf[(q+3) % error_line]); \
+ } else { \
+ /* invalid */ \
+ } \
+} while (0)
@ @c
void show_context(void)
-{ /* prints where the scanner is */
- int old_setting; /* saved |selector| setting */
- int nn; /* number of contexts shown so far, less one */
- boolean bottom_line; /* have we reached the final context to be shown? */
- int i; /* index into |buffer| */
- int j; /* end of current line in |buffer| */
- int l; /* length of descriptive information on line 1 */
- int m; /* context information gathered for line 2 */
- int n; /* length of line 1 */
- int p; /* starting or ending place in |trick_buf| */
- int q; /* temporary index */
+{ /* prints where the scanner is */
+ int old_setting; /* saved |selector| setting */
+ int nn; /* number of contexts shown so far, less one */
+ boolean bottom_line; /* have we reached the final context to be shown? */
+ int i; /* index into |buffer| */
+ int j; /* end of current line in |buffer| */
+ int l; /* length of descriptive information on line 1 */
+ int m; /* context information gathered for line 2 */
+ int n; /* length of line 1 */
+ int p; /* starting or ending place in |trick_buf| */
+ int q; /* temporary index */
+ int c; /* used in sanitizer */
base_ptr = input_ptr;
input_stack[base_ptr] = cur_input;
@@ -342,7 +377,7 @@ void show_context(void)
n = half_error_line;
}
for (q = p; q <= first_count - 1; q++)
- print_char(trick_buf[(q % error_line)]);
+ print_valid_utf8(q);
print_ln();
for (q = 1; q <= n; q++)
print_char(' '); /* print |n| spaces to begin line~2 */
@@ -351,7 +386,7 @@ void show_context(void)
else
p = first_count + (error_line - n - 3);
for (q = first_count; q <= p - 1; q++)
- print_char(trick_buf[(q % error_line)]);
+ print_valid_utf8(q);
if (m + n > error_line)
tprint("...");