aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2013-02-14 00:04:38 +0100
committerJoakim Verona2013-02-14 00:04:38 +0100
commit694d759a9dd8fcbd23078bab33f84ff399d58971 (patch)
tree7b9f2b697ffa06f315be78cd84b94d84659d02c2 /src
parente46029ad6dda065541c8de40de0fe9d5800ac770 (diff)
parentfe3362617385f936576ba0acdac66e2f7da38391 (diff)
downloademacs-694d759a9dd8fcbd23078bab33f84ff399d58971.tar.gz
emacs-694d759a9dd8fcbd23078bab33f84ff399d58971.zip
auto upstream
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog73
-rw-r--r--src/bidi.c5
-rw-r--r--src/callproc.c10
-rw-r--r--src/coding.c2
-rw-r--r--src/composite.c14
-rw-r--r--src/dispnew.c4
-rw-r--r--src/font.c23
-rw-r--r--src/font.h2
-rw-r--r--src/indent.c2
-rw-r--r--src/keyboard.c9
-rw-r--r--src/makefile.w32-in4
-rw-r--r--src/pre-crt0.c6
-rw-r--r--src/sysdep.c4
-rw-r--r--src/unexaix.c93
14 files changed, 156 insertions, 95 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 05737bb1194..82cc8f0f552 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,76 @@
12013-02-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * keyboard.c (syms_of_keyboard): Further tweaks of docstring.
4
52013-02-13 Dmitry Antipov <dmantipov@yandex.ru>
6
7 * font.c (font_range): Add pos_byte argument. Adjust comment
8 and break long line.
9 * font.h (font_range): Adjust prototype.
10 * composite.c (autocmp_chars): Pass byte position to font_range.
11 Break long line. Remove useless prototype and format comment.
12
132013-02-13 Glenn Morris <rgm@gnu.org>
14
15 * keyboard.c (input-decode-map, key-translation-map): Doc fixes.
16
172013-02-13 Paul Eggert <eggert@cs.ucla.edu>
18
19 Improve AIX port some more (Bug#13650).
20 With this, it should be as good as it was in 23.3, though it's
21 still pretty bad: the dumped emacs does not run. See Mark Fleishman in
22 http://lists.gnu.org/archive/html/help-gnu-emacs/2011-04/msg00287.html
23 * unexaix.c (start_of_text): Remove.
24 (_data, _text): Declare as char[], not int, as AIX manual suggests.
25 (bias, lnnoptr, text_scnptr, data_scnptr, load_scnptr)
26 (orig_load_scnptr, orig_data_scnptr):
27 Now off_t, not long, since they are file offsets.
28 (make_hdr): Use _data, not start_of_data ().
29 This is the key part of the fix.
30 (make_hdr, unrelocate_symbols): Use off_t for file offsets.
31 (unrelocate_symbols): Cast pointers to intptr_t, not to ulong.
32
33 * pre-crt0.c (data_start): Initialize to 1.
34 This ports to compilers that optimize the external declaration
35 'int x = 0;' as if it were 'int x;' to shrink the executable.
36
37 Improve AIX port (Bug#13650).
38 This doesn't fix the bug, but it makes progress: Emacs builds now.
39 * unexaix.c: Include inttypes.h, stdarg.h.
40 (report_error, report_error_1): Mark as _Noreturn.
41 (report_error): Don't report the wrong errno.
42 (report_error_1): Now varargs. All callers changed.
43 (make_hdr): Use uintptr_t, not unsigned, when converting pointers
44 to unsigned. Don't use ADDR_CORRECT, as it no longer exists.
45 (write_ptr): Use %p to print address rather than %lx and a cast
46 to unsigned long. Grow buffer a bit, to be safer.
47
482013-02-13 Eli Zaretskii <eliz@gnu.org>
49
50 * bidi.c (bidi_resolve_neutral): After finding the next
51 non-neutral character, accept NEUTRAL_ON type as well, because
52 directional control characters, such as LRE and RLE, have their
53 type converted to that by bidi_resolve_weak. This avoids aborts
54 when LRE/RLE follows a run of neutrals.
55 (bidi_move_to_visually_next): Assert that return value of
56 bidi_peek_at_next_level is non-negative. Negative values will
57 cause an infloop.
58
592013-02-13 Paul Eggert <eggert@cs.ucla.edu>
60
61 Minor getenv-related fixes.
62 * callproc.c (Fcall_process_region) [!DOS_NT]:
63 Avoid unnecessary duplicate call to getenv.
64 * callproc.c (init_callproc):
65 * dispnew.c (init_display):
66 * sysdep.c (sys_subshell):
67 Omit unnecessary cast of getenv or egetenv.
68
692013-02-13 Juanma Barranquero <lekktu@gmail.com>
70
71 * makefile.w32-in ($(BLD)/filelock.$(O), $(BLD)/sysdep.$(O)):
72 Update dependencies.
73
12013-02-12 Eli Zaretskii <eliz@gnu.org> 742013-02-12 Eli Zaretskii <eliz@gnu.org>
2 75
3 * xdisp.c (redisplay_internal): Don't set w->region_showing to the 76 * xdisp.c (redisplay_internal): Don't set w->region_showing to the
diff --git a/src/bidi.c b/src/bidi.c
index b067c8134e3..db2e48a2ca7 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1973,6 +1973,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1973 next_type = STRONG_R; 1973 next_type = STRONG_R;
1974 break; 1974 break;
1975 case WEAK_BN: 1975 case WEAK_BN:
1976 case NEUTRAL_ON: /* W6/Retaining */
1976 if (!bidi_explicit_dir_char (bidi_it->ch)) 1977 if (!bidi_explicit_dir_char (bidi_it->ch))
1977 emacs_abort (); /* can't happen: BNs are skipped */ 1978 emacs_abort (); /* can't happen: BNs are skipped */
1978 /* FALLTHROUGH */ 1979 /* FALLTHROUGH */
@@ -2391,6 +2392,10 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2391 next_level = bidi_peek_at_next_level (bidi_it); 2392 next_level = bidi_peek_at_next_level (bidi_it);
2392 while (next_level != expected_next_level) 2393 while (next_level != expected_next_level)
2393 { 2394 {
2395 /* If next_level is -1, it means we have an unresolved level
2396 in the cache, which at this point should not happen. If
2397 it does, we will infloop. */
2398 eassert (next_level >= 0);
2394 expected_next_level += incr; 2399 expected_next_level += incr;
2395 level_to_search += incr; 2400 level_to_search += incr;
2396 bidi_find_other_level_edge (bidi_it, level_to_search, !ascending); 2401 bidi_find_other_level_edge (bidi_it, level_to_search, !ascending);
diff --git a/src/callproc.c b/src/callproc.c
index cb11ee0cc53..9132c0dd976 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -997,13 +997,11 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
997 tmpdir = Vtemporary_file_directory; 997 tmpdir = Vtemporary_file_directory;
998 else 998 else
999 { 999 {
1000 char *outf;
1000#ifndef DOS_NT 1001#ifndef DOS_NT
1001 if (getenv ("TMPDIR")) 1002 outf = getenv ("TMPDIR");
1002 tmpdir = build_string (getenv ("TMPDIR")); 1003 tmpdir = build_string (outf ? outf : "/tmp/");
1003 else
1004 tmpdir = build_string ("/tmp/");
1005#else /* DOS_NT */ 1004#else /* DOS_NT */
1006 char *outf;
1007 if ((outf = egetenv ("TMPDIR")) 1005 if ((outf = egetenv ("TMPDIR"))
1008 || (outf = egetenv ("TMP")) 1006 || (outf = egetenv ("TMP"))
1009 || (outf = egetenv ("TEMP"))) 1007 || (outf = egetenv ("TEMP")))
@@ -1655,7 +1653,7 @@ init_callproc (void)
1655 if (! file_accessible_directory_p (SSDATA (tempdir))) 1653 if (! file_accessible_directory_p (SSDATA (tempdir)))
1656 dir_warning ("arch-independent data dir", Vdata_directory); 1654 dir_warning ("arch-independent data dir", Vdata_directory);
1657 1655
1658 sh = (char *) getenv ("SHELL"); 1656 sh = getenv ("SHELL");
1659 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); 1657 Vshell_file_name = build_string (sh ? sh : "/bin/sh");
1660 1658
1661#ifdef DOS_NT 1659#ifdef DOS_NT
diff --git a/src/coding.c b/src/coding.c
index b881f162ab9..868fb7df0ea 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10712,7 +10712,7 @@ reading if you suppress escape sequence detection.
10712 10712
10713The other way to read escape sequences in a file without decoding is 10713The other way to read escape sequences in a file without decoding is
10714to explicitly specify some coding system that doesn't use ISO-2022 10714to explicitly specify some coding system that doesn't use ISO-2022
10715escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); 10715escape sequence (e.g., `latin-1') on reading by \\[universal-coding-system-argument]. */);
10716 inhibit_iso_escape_detection = 0; 10716 inhibit_iso_escape_detection = 0;
10717 10717
10718 DEFVAR_BOOL ("inhibit-null-byte-detection", 10718 DEFVAR_BOOL ("inhibit-null-byte-detection",
diff --git a/src/composite.c b/src/composite.c
index 54cebc00eb7..9bbd4550c7b 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -642,13 +642,7 @@ compose_text (ptrdiff_t start, ptrdiff_t end, Lisp_Object components,
642 Qcomposition, prop, string); 642 Qcomposition, prop, string);
643} 643}
644 644
645 645/* Lisp glyph-string handlers. */
646static Lisp_Object autocmp_chars (Lisp_Object, ptrdiff_t, ptrdiff_t,
647 ptrdiff_t, struct window *,
648 struct face *, Lisp_Object);
649
650
651/* Lisp glyph-string handlers */
652 646
653/* Hash table for automatic composition. The key is a header of a 647/* Hash table for automatic composition. The key is a header of a
654 lgstring (Lispy glyph-string), and the value is a body of a 648 lgstring (Lispy glyph-string), and the value is a body of a
@@ -905,7 +899,9 @@ fill_gstring_body (Lisp_Object gstring)
905 object. Otherwise return nil. */ 899 object. Otherwise return nil. */
906 900
907static Lisp_Object 901static Lisp_Object
908autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t limit, struct window *win, struct face *face, Lisp_Object string) 902autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos,
903 ptrdiff_t limit, struct window *win, struct face *face,
904 Lisp_Object string)
909{ 905{
910 ptrdiff_t count = SPECPDL_INDEX (); 906 ptrdiff_t count = SPECPDL_INDEX ();
911 FRAME_PTR f = XFRAME (win->frame); 907 FRAME_PTR f = XFRAME (win->frame);
@@ -935,7 +931,7 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t
935#ifdef HAVE_WINDOW_SYSTEM 931#ifdef HAVE_WINDOW_SYSTEM
936 if (FRAME_WINDOW_P (f)) 932 if (FRAME_WINDOW_P (f))
937 { 933 {
938 font_object = font_range (charpos, &to, win, face, string); 934 font_object = font_range (charpos, bytepos, &to, win, face, string);
939 if (! FONT_OBJECT_P (font_object) 935 if (! FONT_OBJECT_P (font_object)
940 || (! NILP (re) 936 || (! NILP (re)
941 && to < limit 937 && to < limit
diff --git a/src/dispnew.c b/src/dispnew.c
index 0037c0269de..54004daada9 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6025,7 +6025,6 @@ init_display (void)
6025 6025
6026 inverse_video = 0; 6026 inverse_video = 0;
6027 cursor_in_echo_area = 0; 6027 cursor_in_echo_area = 0;
6028 terminal_type = (char *) 0;
6029 6028
6030 /* Now is the time to initialize this; it's used by init_sys_modes 6029 /* Now is the time to initialize this; it's used by init_sys_modes
6031 during startup. */ 6030 during startup. */
@@ -6120,8 +6119,7 @@ init_display (void)
6120#ifdef WINDOWSNT 6119#ifdef WINDOWSNT
6121 terminal_type = "w32console"; 6120 terminal_type = "w32console";
6122#else 6121#else
6123 /* Look at the TERM variable. */ 6122 terminal_type = getenv ("TERM");
6124 terminal_type = (char *) getenv ("TERM");
6125#endif 6123#endif
6126 if (!terminal_type) 6124 if (!terminal_type)
6127 { 6125 {
diff --git a/src/font.c b/src/font.c
index bed0ac8caf2..e2ea7262397 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3689,11 +3689,11 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3689 3689
3690#ifdef HAVE_WINDOW_SYSTEM 3690#ifdef HAVE_WINDOW_SYSTEM
3691 3691
3692/* Check how many characters after POS (at most to *LIMIT) can be 3692/* Check how many characters after character/byte position POS/POS_BYTE
3693 displayed by the same font in the window W. FACE, if non-NULL, is 3693 (at most to *LIMIT) can be displayed by the same font in the window W.
3694 the face selected for the character at POS. If STRING is not nil, 3694 FACE, if non-NULL, is the face selected for the character at POS.
3695 it is the string to check instead of the current buffer. In that 3695 If STRING is not nil, it is the string to check instead of the current
3696 case, FACE must be not NULL. 3696 buffer. In that case, FACE must be not NULL.
3697 3697
3698 The return value is the font-object for the character at POS. 3698 The return value is the font-object for the character at POS.
3699 *LIMIT is set to the position where that font can't be used. 3699 *LIMIT is set to the position where that font can't be used.
@@ -3701,15 +3701,15 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
3701 It is assured that the current buffer (or STRING) is multibyte. */ 3701 It is assured that the current buffer (or STRING) is multibyte. */
3702 3702
3703Lisp_Object 3703Lisp_Object
3704font_range (ptrdiff_t pos, ptrdiff_t *limit, struct window *w, struct face *face, Lisp_Object string) 3704font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
3705 struct window *w, struct face *face, Lisp_Object string)
3705{ 3706{
3706 ptrdiff_t pos_byte, ignore; 3707 ptrdiff_t ignore;
3707 int c; 3708 int c;
3708 Lisp_Object font_object = Qnil; 3709 Lisp_Object font_object = Qnil;
3709 3710
3710 if (NILP (string)) 3711 if (NILP (string))
3711 { 3712 {
3712 pos_byte = CHAR_TO_BYTE (pos);
3713 if (! face) 3713 if (! face)
3714 { 3714 {
3715 int face_id; 3715 int face_id;
@@ -3720,10 +3720,7 @@ font_range (ptrdiff_t pos, ptrdiff_t *limit, struct window *w, struct face *face
3720 } 3720 }
3721 } 3721 }
3722 else 3722 else
3723 { 3723 eassert (face);
3724 eassert (face);
3725 pos_byte = string_char_to_byte (string, pos);
3726 }
3727 3724
3728 while (pos < *limit) 3725 while (pos < *limit)
3729 { 3726 {
@@ -4831,7 +4828,7 @@ where
4831 OPENED-NAME is the name used for opening the font, 4828 OPENED-NAME is the name used for opening the font,
4832 FULL-NAME is the full name of the font, 4829 FULL-NAME is the full name of the font,
4833 SIZE is the pixelsize of the font, 4830 SIZE is the pixelsize of the font,
4834 HEIGHT is the pixel-height of the font (i.e ascent + descent), 4831 HEIGHT is the pixel-height of the font (i.e., ascent + descent),
4835 BASELINE-OFFSET is the upward offset pixels from ASCII baseline, 4832 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,
4836 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling 4833 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling
4837 how to compose characters. 4834 how to compose characters.
diff --git a/src/font.h b/src/font.h
index b565fb4b01b..ffed0461ff7 100644
--- a/src/font.h
+++ b/src/font.h
@@ -781,7 +781,7 @@ extern int font_unparse_fcname (Lisp_Object font, int pixel_size,
781extern void register_font_driver (struct font_driver *driver, FRAME_PTR f); 781extern void register_font_driver (struct font_driver *driver, FRAME_PTR f);
782extern void free_font_driver_list (FRAME_PTR f); 782extern void free_font_driver_list (FRAME_PTR f);
783extern Lisp_Object font_update_drivers (FRAME_PTR f, Lisp_Object list); 783extern Lisp_Object font_update_drivers (FRAME_PTR f, Lisp_Object list);
784extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t *, 784extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t, ptrdiff_t *,
785 struct window *, struct face *, 785 struct window *, struct face *,
786 Lisp_Object); 786 Lisp_Object);
787extern void font_fill_lglyph_metrics (Lisp_Object, Lisp_Object); 787extern void font_fill_lglyph_metrics (Lisp_Object, Lisp_Object);
diff --git a/src/indent.c b/src/indent.c
index 44ecbbc8a58..ce1639eae1e 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -291,7 +291,7 @@ DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0,
291 doc: /* Return the horizontal position of point. Beginning of line is column 0. 291 doc: /* Return the horizontal position of point. Beginning of line is column 0.
292This is calculated by adding together the widths of all the displayed 292This is calculated by adding together the widths of all the displayed
293representations of the character between the start of the previous line 293representations of the character between the start of the previous line
294and point (eg. control characters will have a width of 2 or 4, tabs 294and point (e.g., control characters will have a width of 2 or 4, tabs
295will have a variable width). 295will have a variable width).
296Ignores finite width of frame, which means that this function may return 296Ignores finite width of frame, which means that this function may return
297values greater than (frame-width). 297values greater than (frame-width).
diff --git a/src/keyboard.c b/src/keyboard.c
index 4a92cea30c8..3e1a6ba3346 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11641,9 +11641,7 @@ If the binding is a function, it is called with one argument (the prompt)
11641and its return value (a key sequence) is used. 11641and its return value (a key sequence) is used.
11642 11642
11643The events that come from bindings in `input-decode-map' are not 11643The events that come from bindings in `input-decode-map' are not
11644themselves looked up in `input-decode-map'. 11644themselves looked up in `input-decode-map'. */);
11645
11646This variable is keyboard-local. */);
11647 11645
11648 DEFVAR_LISP ("function-key-map", Vfunction_key_map, 11646 DEFVAR_LISP ("function-key-map", Vfunction_key_map,
11649 doc: /* The parent keymap of all `local-function-key-map' instances. 11647 doc: /* The parent keymap of all `local-function-key-map' instances.
@@ -11655,9 +11653,8 @@ definition will take precedence. */);
11655 11653
11656 DEFVAR_LISP ("key-translation-map", Vkey_translation_map, 11654 DEFVAR_LISP ("key-translation-map", Vkey_translation_map,
11657 doc: /* Keymap of key translations that can override keymaps. 11655 doc: /* Keymap of key translations that can override keymaps.
11658This keymap works like `function-key-map', but comes after that, 11656This keymap works like `input-decode-map', but comes after `function-key-map'.
11659and its non-prefix bindings override ordinary bindings. 11657Another difference is that it is global rather than terminal-local. */);
11660Another difference is that it is global rather than keyboard-local. */);
11661 Vkey_translation_map = Fmake_sparse_keymap (Qnil); 11658 Vkey_translation_map = Fmake_sparse_keymap (Qnil);
11662 11659
11663 DEFVAR_LISP ("deferred-action-list", Vdeferred_action_list, 11660 DEFVAR_LISP ("deferred-action-list", Vdeferred_action_list,
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index bbd9fd907b6..6e1873f8e49 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -847,7 +847,9 @@ $(BLD)/fileio.$(O) : \
847 $(NT_INC)/sys/file.h \ 847 $(NT_INC)/sys/file.h \
848 $(NT_INC)/sys/stat.h \ 848 $(NT_INC)/sys/stat.h \
849 $(NT_INC)/unistd.h \ 849 $(NT_INC)/unistd.h \
850 $(GNU_LIB)/allocator.h \
850 $(BUFFER_H) \ 851 $(BUFFER_H) \
852 $(CAREADLINKAT_H) \
851 $(CHARACTER_H) \ 853 $(CHARACTER_H) \
852 $(CODING_H) \ 854 $(CODING_H) \
853 $(CONFIG_H) \ 855 $(CONFIG_H) \
@@ -1397,11 +1399,9 @@ $(BLD)/sysdep.$(O) : \
1397 $(NT_INC)/sys/file.h \ 1399 $(NT_INC)/sys/file.h \
1398 $(NT_INC)/sys/stat.h \ 1400 $(NT_INC)/sys/stat.h \
1399 $(NT_INC)/unistd.h \ 1401 $(NT_INC)/unistd.h \
1400 $(GNU_LIB)/allocator.h \
1401 $(GNU_LIB)/execinfo.h \ 1402 $(GNU_LIB)/execinfo.h \
1402 $(GNU_LIB)/ignore-value.h \ 1403 $(GNU_LIB)/ignore-value.h \
1403 $(GNU_LIB)/utimens.h \ 1404 $(GNU_LIB)/utimens.h \
1404 $(CAREADLINKAT_H) \
1405 $(CONFIG_H) \ 1405 $(CONFIG_H) \
1406 $(C_CTYPE_H) \ 1406 $(C_CTYPE_H) \
1407 $(DISPEXTERN_H) \ 1407 $(DISPEXTERN_H) \
diff --git a/src/pre-crt0.c b/src/pre-crt0.c
index ea5736eba2a..6b9618c8dc3 100644
--- a/src/pre-crt0.c
+++ b/src/pre-crt0.c
@@ -4,7 +4,7 @@
4 that make environ an initialized variable. However, we do 4 that make environ an initialized variable. However, we do
5 need to make sure the label data_start exists anyway. */ 5 need to make sure the label data_start exists anyway. */
6 6
7/* Create a label to appear at the beginning of data space. */ 7/* Create a label to appear at the beginning of data space.
8 8 Its value is nonzero so that it cannot be put into bss. */
9int data_start = 0;
10 9
10int data_start = 1;
diff --git a/src/sysdep.c b/src/sysdep.c
index 57ca8265a65..606a5b038ca 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -527,10 +527,10 @@ sys_subshell (void)
527#ifdef DOS_NT /* MW, Aug 1993 */ 527#ifdef DOS_NT /* MW, Aug 1993 */
528 getcwd (oldwd, sizeof oldwd); 528 getcwd (oldwd, sizeof oldwd);
529 if (sh == 0) 529 if (sh == 0)
530 sh = (char *) egetenv ("SUSPEND"); /* KFS, 1994-12-14 */ 530 sh = egetenv ("SUSPEND"); /* KFS, 1994-12-14 */
531#endif 531#endif
532 if (sh == 0) 532 if (sh == 0)
533 sh = (char *) egetenv ("SHELL"); 533 sh = egetenv ("SHELL");
534 if (sh == 0) 534 if (sh == 0)
535 sh = "sh"; 535 sh = "sh";
536 536
diff --git a/src/unexaix.c b/src/unexaix.c
index 92ebd2e3ceb..da44480fdca 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -51,6 +51,8 @@ what you give them. Help stamp out software-hoarding! */
51#include "getpagesize.h" 51#include "getpagesize.h"
52 52
53#include <sys/types.h> 53#include <sys/types.h>
54#include <inttypes.h>
55#include <stdarg.h>
54#include <stdio.h> 56#include <stdio.h>
55#include <sys/stat.h> 57#include <sys/stat.h>
56#include <errno.h> 58#include <errno.h>
@@ -59,10 +61,8 @@ what you give them. Help stamp out software-hoarding! */
59 61
60#include "mem-limits.h" 62#include "mem-limits.h"
61 63
62char *start_of_text (void); /* Start of text */ 64extern char _data[];
63 65extern char _text[];
64extern int _data;
65extern int _text;
66 66
67#include <filehdr.h> 67#include <filehdr.h>
68#include <aouthdr.h> 68#include <aouthdr.h>
@@ -71,15 +71,15 @@ extern int _text;
71 71
72static struct filehdr f_hdr; /* File header */ 72static struct filehdr f_hdr; /* File header */
73static struct aouthdr f_ohdr; /* Optional file header (a.out) */ 73static struct aouthdr f_ohdr; /* Optional file header (a.out) */
74static long bias; /* Bias to add for growth */ 74static off_t bias; /* Bias to add for growth */
75static long lnnoptr; /* Pointer to line-number info within file */ 75static off_t lnnoptr; /* Pointer to line-number info within file */
76 76
77static long text_scnptr; 77static off_t text_scnptr;
78static long data_scnptr; 78static off_t data_scnptr;
79#define ALIGN(val, pwr) (((val) + ((1L<<(pwr))-1)) & ~((1L<<(pwr))-1)) 79#define ALIGN(val, pwr) (((val) + ((1L<<(pwr))-1)) & ~((1L<<(pwr))-1))
80static long load_scnptr; 80static off_t load_scnptr;
81static long orig_load_scnptr; 81static off_t orig_load_scnptr;
82static long orig_data_scnptr; 82static off_t orig_data_scnptr;
83static int unrelocate_symbols (int, int, const char *, const char *); 83static int unrelocate_symbols (int, int, const char *, const char *);
84 84
85#ifndef MAX_SECTIONS 85#ifndef MAX_SECTIONS
@@ -92,23 +92,30 @@ static int pagemask;
92 92
93#include "lisp.h" 93#include "lisp.h"
94 94
95static void 95static _Noreturn void
96report_error (const char *file, int fd) 96report_error (const char *file, int fd)
97{ 97{
98 if (fd) 98 if (fd)
99 close (fd); 99 {
100 int failed_errno = errno;
101 close (fd);
102 errno = failed_errno;
103 }
100 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); 104 report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
101} 105}
102 106
103#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 107#define ERROR0(msg) report_error_1 (new, msg)
104#define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 108#define ERROR1(msg,x) report_error_1 (new, msg, x)
105#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 109#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y)
106 110
107static void 111static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3)
108report_error_1 (int fd, const char *msg, int a1, int a2) 112report_error_1 (int fd, const char *msg, ...)
109{ 113{
114 va_list ap;
110 close (fd); 115 close (fd);
111 error (msg, a1, a2); 116 va_start (ap, msg);
117 verror (msg, ap);
118 va_end (ap);
112} 119}
113 120
114static int make_hdr (int, int, const char *, const char *); 121static int make_hdr (int, int, const char *, const char *);
@@ -163,8 +170,8 @@ make_hdr (int new, int a_out,
163 const char *a_name, const char *new_name) 170 const char *a_name, const char *new_name)
164{ 171{
165 int scns; 172 int scns;
166 unsigned int bss_start; 173 uintptr_t bss_start;
167 unsigned int data_start; 174 uintptr_t data_start;
168 175
169 struct scnhdr section[MAX_SECTIONS]; 176 struct scnhdr section[MAX_SECTIONS];
170 struct scnhdr * f_thdr; /* Text section header */ 177 struct scnhdr * f_thdr; /* Text section header */
@@ -179,17 +186,17 @@ make_hdr (int new, int a_out,
179 pagemask = getpagesize () - 1; 186 pagemask = getpagesize () - 1;
180 187
181 /* Adjust text/data boundary. */ 188 /* Adjust text/data boundary. */
182 data_start = (long) start_of_data (); 189 data_start = (uintptr_t) _data;
183 data_start = ADDR_CORRECT (data_start);
184 190
185 data_start = data_start & ~pagemask; /* (Down) to page boundary. */ 191 data_start = data_start & ~pagemask; /* (Down) to page boundary. */
186 192
187 bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; 193 bss_start = (uintptr_t) sbrk (0) + pagemask;
188 bss_start &= ~ pagemask; 194 bss_start &= ~ pagemask;
189 195
190 if (data_start > bss_start) /* Can't have negative data size. */ 196 if (data_start > bss_start) /* Can't have negative data size. */
191 { 197 {
192 ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)", 198 ERROR2 (("unexec: data_start (0x%"PRIxPTR
199 ") can't be greater than bss_start (0x%"PRIxPTR")"),
193 data_start, bss_start); 200 data_start, bss_start);
194 } 201 }
195 202
@@ -279,7 +286,7 @@ make_hdr (int new, int a_out,
279 286
280 /* fix scnptr's */ 287 /* fix scnptr's */
281 { 288 {
282 ulong ptr = section[0].s_scnptr; 289 off_t ptr = section[0].s_scnptr;
283 290
284 bias = -1; 291 bias = -1;
285 for (scns = 0; scns < f_hdr.f_nscns; scns++) 292 for (scns = 0; scns < f_hdr.f_nscns; scns++)
@@ -375,12 +382,12 @@ copy_text_and_data (int new)
375 char *end; 382 char *end;
376 char *ptr; 383 char *ptr;
377 384
378 lseek (new, (long) text_scnptr, SEEK_SET); 385 lseek (new, text_scnptr, SEEK_SET);
379 ptr = start_of_text () + text_scnptr; 386 ptr = _text + text_scnptr;
380 end = ptr + f_ohdr.tsize; 387 end = ptr + f_ohdr.tsize;
381 write_segment (new, ptr, end); 388 write_segment (new, ptr, end);
382 389
383 lseek (new, (long) data_scnptr, SEEK_SET); 390 lseek (new, data_scnptr, SEEK_SET);
384 ptr = (char *) f_ohdr.data_start; 391 ptr = (char *) f_ohdr.data_start;
385 end = ptr + f_ohdr.dsize; 392 end = ptr + f_ohdr.dsize;
386 write_segment (new, ptr, end); 393 write_segment (new, ptr, end);
@@ -393,7 +400,6 @@ static void
393write_segment (int new, char *ptr, char *end) 400write_segment (int new, char *ptr, char *end)
394{ 401{
395 int i, nwrite, ret; 402 int i, nwrite, ret;
396 char buf[80];
397 char zeros[UnexBlockSz]; 403 char zeros[UnexBlockSz];
398 404
399 for (i = 0; ptr < end;) 405 for (i = 0; ptr < end;)
@@ -414,9 +420,13 @@ write_segment (int new, char *ptr, char *end)
414 } 420 }
415 else if (nwrite != ret) 421 else if (nwrite != ret)
416 { 422 {
423 int write_errno = errno;
424 char buf[1000];
425 void *addr = ptr;
417 sprintf (buf, 426 sprintf (buf,
418 "unexec write failure: addr 0x%lx, fileno %d, size 0x%x, wrote 0x%x, errno %d", 427 "unexec write failure: addr %p, fileno %d, size 0x%x, wrote 0x%x, errno %d",
419 (unsigned long)ptr, new, nwrite, ret, errno); 428 addr, new, nwrite, ret, errno);
429 errno = write_errno;
420 PERROR (buf); 430 PERROR (buf);
421 } 431 }
422 i += nwrite; 432 i += nwrite;
@@ -537,13 +547,13 @@ unrelocate_symbols (int new, int a_out,
537 int i; 547 int i;
538 LDHDR ldhdr; 548 LDHDR ldhdr;
539 LDREL ldrel; 549 LDREL ldrel;
540 ulong t_reloc = (ulong) &_text - f_ohdr.text_start; 550 off_t t_reloc = (intptr_t) _text - f_ohdr.text_start;
541#ifndef ALIGN_DATA_RELOC 551#ifndef ALIGN_DATA_RELOC
542 ulong d_reloc = (ulong) &_data - f_ohdr.data_start; 552 off_t d_reloc = (intptr_t) _data - f_ohdr.data_start;
543#else 553#else
544 /* This worked (and was needed) before AIX 4.2. 554 /* This worked (and was needed) before AIX 4.2.
545 I have no idea why. -- Mike */ 555 I have no idea why. -- Mike */
546 ulong d_reloc = (ulong) &_data - ALIGN (f_ohdr.data_start, 2); 556 off_t d_reloc = (intptr_t) _data - ALIGN (f_ohdr.data_start, 2);
547#endif 557#endif
548 int * p; 558 int * p;
549 559
@@ -628,16 +638,3 @@ unrelocate_symbols (int new, int a_out,
628 } 638 }
629 return 0; 639 return 0;
630} 640}
631
632/*
633 * Return the address of the start of the text segment prior to
634 * doing an unexec. After unexec the return value is undefined.
635 * See crt0.c for further explanation and _start.
636 *
637 */
638
639char *
640start_of_text (void)
641{
642 return ((char *) 0x10000000);
643}