Thu Mar 2 08:15:33 2023 UTC ()
devel/mgdiff: Add "Reload Both" command.

Apply the "Reload Both" patch by Ben Leslie <benno@benno.id.au>,
which adds a "Reload Both" (meta-R) command to re-run diff on both the
currently opened files.

Bump revision.


(vins)
diff -r1.2 -r1.3 pkgsrc/devel/mgdiff/Makefile
diff -r1.3 -r1.4 pkgsrc/devel/mgdiff/distinfo
diff -r1.1 -r1.2 pkgsrc/devel/mgdiff/patches/patch-Mgdiff.ad
diff -r1.1 -r1.2 pkgsrc/devel/mgdiff/patches/patch-mgdiff.man
diff -r1.3 -r1.4 pkgsrc/devel/mgdiff/patches/patch-mgdiff.c

cvs diff -r1.2 -r1.3 pkgsrc/devel/mgdiff/Makefile (expand / switch to unified diff)

--- pkgsrc/devel/mgdiff/Makefile 2023/03/01 23:48:00 1.2
+++ pkgsrc/devel/mgdiff/Makefile 2023/03/02 08:15:32 1.3
@@ -1,17 +1,18 @@ @@ -1,17 +1,18 @@
1# $NetBSD: Makefile,v 1.2 2023/03/01 23:48:00 vins Exp $ 1# $NetBSD: Makefile,v 1.3 2023/03/02 08:15:32 vins Exp $
2 2
3DISTNAME= mgdiff 3DISTNAME= mgdiff
4PKGNAME= ${DISTNAME}-1.0.1 4PKGNAME= ${DISTNAME}-1.0.1
 5PKGREVISION= 1
5CATEGORIES= devel x11 6CATEGORIES= devel x11
6MASTER_SITES= ${MASTER_SITE_XCONTRIB:=applications/} 7MASTER_SITES= ${MASTER_SITE_XCONTRIB:=applications/}
7DIST_SUBDIR= ${PKGNAME_NOREV} 8DIST_SUBDIR= ${PKGNAME_NOREV}
8 9
9MAINTAINER= vins@NetBSD.org 10MAINTAINER= vins@NetBSD.org
10HOMEPAGE= https://bsdforge.com/projects/textproc/mgdiff/ 11HOMEPAGE= https://bsdforge.com/projects/textproc/mgdiff/
11COMMENT= Graphical front end to Unix diff 12COMMENT= Graphical front end to Unix diff
12LICENSE= mit 13LICENSE= mit
13 14
14USE_IMAKE= yes 15USE_IMAKE= yes
15USE_TOOLS+= awk:run ksh:run 16USE_TOOLS+= awk:run ksh:run
16 17
17REPLACE_KSH= cvsmgdiff 18REPLACE_KSH= cvsmgdiff

cvs diff -r1.3 -r1.4 pkgsrc/devel/mgdiff/distinfo (expand / switch to unified diff)

--- pkgsrc/devel/mgdiff/distinfo 2023/03/01 23:48:00 1.3
+++ pkgsrc/devel/mgdiff/distinfo 2023/03/02 08:15:32 1.4
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1$NetBSD: distinfo,v 1.3 2023/03/01 23:48:00 vins Exp $ 1$NetBSD: distinfo,v 1.4 2023/03/02 08:15:32 vins Exp $
2 2
3BLAKE2s (mgdiff-1.0.1/mgdiff.tar.gz) = 7c90e00f9646d41e5e822055340fa41440acaa5ec0352606ccec1e14b43188de 3BLAKE2s (mgdiff-1.0.1/mgdiff.tar.gz) = 7c90e00f9646d41e5e822055340fa41440acaa5ec0352606ccec1e14b43188de
4SHA512 (mgdiff-1.0.1/mgdiff.tar.gz) = bf5ab4b2a9d42ff2edb73a6dda68a4d17d88f61c63f5ec8366cc49d372a56f3c6812d473a95d86bcb61680d1f91ce4ab7ad87a26748b45e2edd27b73044492a5 4SHA512 (mgdiff-1.0.1/mgdiff.tar.gz) = bf5ab4b2a9d42ff2edb73a6dda68a4d17d88f61c63f5ec8366cc49d372a56f3c6812d473a95d86bcb61680d1f91ce4ab7ad87a26748b45e2edd27b73044492a5
5Size (mgdiff-1.0.1/mgdiff.tar.gz) = 41187 bytes 5Size (mgdiff-1.0.1/mgdiff.tar.gz) = 41187 bytes
6SHA1 (patch-Imakefile) = 7c95728d50c4d835ceb330124eccce166c9e2845 6SHA1 (patch-Imakefile) = 7c95728d50c4d835ceb330124eccce166c9e2845
7SHA1 (patch-Mgdiff.ad) = 3be8cae459c84f355de65e37f679649472b38a16 7SHA1 (patch-Mgdiff.ad) = 1a3eade787f06b02c36bdc925a65ee0562f4d9f5
8SHA1 (patch-externs.h) = 8e536067c9834b8ef26a0210aaf8ece31004f310 8SHA1 (patch-externs.h) = 8e536067c9834b8ef26a0210aaf8ece31004f310
9SHA1 (patch-files.c) = fa06ab3916e0d0a95551bea5e3320c9e577b3d7a 9SHA1 (patch-files.c) = fa06ab3916e0d0a95551bea5e3320c9e577b3d7a
10SHA1 (patch-legend.c) = 8933bc2938f94bc7c0c11009074517f017d4f8ee 10SHA1 (patch-legend.c) = 8933bc2938f94bc7c0c11009074517f017d4f8ee
11SHA1 (patch-manual.c) = 2f430240696d6eec22d5dd576c4577e5b7b4578d 11SHA1 (patch-manual.c) = 2f430240696d6eec22d5dd576c4577e5b7b4578d
12SHA1 (patch-mgdiff.c) = f2e2fb5cc4722ae38e00566ebbc5e87e00457807 12SHA1 (patch-mgdiff.c) = 773c0a4c1a10194fdc44da401c1eb40cae1233fc
13SHA1 (patch-mgdiff.h) = e7958ebd5ca1ccb17c7bcc7cf860d88e81f50cb4 13SHA1 (patch-mgdiff.h) = e7958ebd5ca1ccb17c7bcc7cf860d88e81f50cb4
14SHA1 (patch-mgdiff.man) = 6d3a2fbecb7ae1e8f8a2cc4f3c7ac15f44a8e01a 14SHA1 (patch-mgdiff.man) = 65841f964644e7583ec0acb6601703cb44cf76f5
15SHA1 (patch-misc.c) = b6e1dd999f7fa5d013f3b6ad605f7c8c4cb4702e 15SHA1 (patch-misc.c) = b6e1dd999f7fa5d013f3b6ad605f7c8c4cb4702e
16SHA1 (patch-modal.c) = 8c9e9e5c165c01f18ffb568367fa8c279a6913fc 16SHA1 (patch-modal.c) = 8c9e9e5c165c01f18ffb568367fa8c279a6913fc
17SHA1 (patch-patchlevel.h) = a9f3923649af2f99fdd4cce8148cc15ad6aaa626 17SHA1 (patch-patchlevel.h) = a9f3923649af2f99fdd4cce8148cc15ad6aaa626
18SHA1 (patch-rundiff.c) = 4c6360f13f1f9871b3a86afb476bfd041a290c58 18SHA1 (patch-rundiff.c) = 4c6360f13f1f9871b3a86afb476bfd041a290c58
19SHA1 (patch-spawn.c) = 3c9f8be777e47f485aef54511c2603adf4d26af3 19SHA1 (patch-spawn.c) = 3c9f8be777e47f485aef54511c2603adf4d26af3

cvs diff -r1.1 -r1.2 pkgsrc/devel/mgdiff/patches/patch-Mgdiff.ad (expand / switch to unified diff)

--- pkgsrc/devel/mgdiff/patches/patch-Mgdiff.ad 2023/03/01 23:48:00 1.1
+++ pkgsrc/devel/mgdiff/patches/patch-Mgdiff.ad 2023/03/02 08:15:32 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: patch-Mgdiff.ad,v 1.1 2023/03/01 23:48:00 vins Exp $ 1$NetBSD: patch-Mgdiff.ad,v 1.2 2023/03/02 08:15:32 vins Exp $
2 2
3Pull patches from Debian. 3Pull patches from Debian.
4 4
5--- Mgdiff.ad.orig 1994-05-19 02:01:03.000000000 +0000 5--- Mgdiff.ad.orig 1994-05-19 02:01:03.000000000 +0000
6+++ Mgdiff.ad 6+++ Mgdiff.ad
7@@ -2,6 +2,8 @@ 7@@ -2,6 +2,8 @@
8 ! Mgdiff.ad,v 2.0 1994/05/19 02:01:03 dan Exp 8 ! Mgdiff.ad,v 2.0 1994/05/19 02:01:03 dan Exp
9 ! 9 !
10  10
11+*XmScrollBar*width: 15 11+*XmScrollBar*width: 15
12+ 12+
13 ! 13 !
14 ! widget hierarchy: 14 ! widget hierarchy:
@@ -27,32 +27,46 @@ Pull patches from Debian. @@ -27,32 +27,46 @@ Pull patches from Debian.
27 ! the overview area 27 ! the overview area
28 ! 28 !
29-*sbl.width: 16 29-*sbl.width: 16
30-*sbr.width: 16 30-*sbr.width: 16
31-*dam.width: 16 31-*dam.width: 16
32+*sbl.width: 15 32+*sbl.width: 15
33+*sbl.Background: lightgreen 33+*sbl.Background: lightgreen
34+*sbr.width: 15 34+*sbr.width: 15
35+*sbr.Background: lightgreen 35+*sbr.Background: lightgreen
36+*dam.width: 30 36+*dam.width: 30
37 *dam.Foreground: black 37 *dam.Foreground: black
38 *dam.Background: cyan 38 *dam.Background: cyan
39  39
40@@ -215,10 +219,14 @@ 40@@ -210,15 +214,23 @@
41 *file_menu*button_3.Accelerator: Ctrl<Key>s 41 *file_menu*button_2.Accelerator: Ctrl<Key>r
42 *file_menu*button_3.AcceleratorText: Ctrl+S 42 *file_menu*button_2.AcceleratorText: Ctrl+R
43  43
 44-*file_menu*button_3.XmString: Save As...
 45-*file_menu*button_3.Mnemonic: S
 46-*file_menu*button_3.Accelerator: Ctrl<Key>s
 47-*file_menu*button_3.AcceleratorText: Ctrl+S
 48-
44-*file_menu*button_4.XmString: Exit 49-*file_menu*button_4.XmString: Exit
45-*file_menu*button_4.Mnemonic: E 50-*file_menu*button_4.Mnemonic: E
46-*file_menu*button_4.Accelerator: Ctrl<Key>c 51-*file_menu*button_4.Accelerator: Ctrl<Key>c
47-*file_menu*button_4.AcceleratorText: Ctrl+C 52-*file_menu*button_4.AcceleratorText: Ctrl+C
48+*file_menu*button_4.XmString: Save As Left... 53+*file_menu*button_3.XmString: Reload Both
49+*file_menu*button_5.XmString: Save As Right... 54+*file_menu*button_3.Accelerator: Meta<Key>r
 55+*file_menu*button_3.AcceleratorText: Meta+R
50+ 56+
51+*file_menu*button_6.XmString: Exit 57+*file_menu*button_4.XmString: Save As...
52+*file_menu*button_6.Mnemonic: E 58+*file_menu*button_4.Mnemonic: S
53+*file_menu*button_6.Accelerator: Ctrl<Key>c 59+*file_menu*button_4.Accelerator: Ctrl<Key>s
54+*file_menu*button_6.AcceleratorText: Ctrl+C 60+*file_menu*button_4.AcceleratorText: Ctrl+S
 61+
 62+*file_menu*button_5.XmString: Save As Left...
 63+*file_menu*button_6.XmString: Save As Right...
 64+
 65+*file_menu*button_7.XmString: Exit
 66+*file_menu*button_7.Mnemonic: E
 67+*file_menu*button_7.Accelerator: Ctrl<Key>c
 68+*file_menu*button_7.AcceleratorText: Ctrl+C
55+ 69+
56 ! 70 !
57 ! 71 !
58 *view_menu*button_0.XmString: Previous 72 *view_menu*button_0.XmString: Previous

cvs diff -r1.1 -r1.2 pkgsrc/devel/mgdiff/patches/patch-mgdiff.man (expand / switch to unified diff)

--- pkgsrc/devel/mgdiff/patches/patch-mgdiff.man 2023/03/01 23:48:00 1.1
+++ pkgsrc/devel/mgdiff/patches/patch-mgdiff.man 2023/03/02 08:15:32 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: patch-mgdiff.man,v 1.1 2023/03/01 23:48:00 vins Exp $ 1$NetBSD: patch-mgdiff.man,v 1.2 2023/03/02 08:15:32 vins Exp $
2 2
3Pull patches from Debian. 3Pull patches from Debian.
4 4
5--- mgdiff.man.orig 1994-05-19 02:01:16.000000000 +0000 5--- mgdiff.man.orig 1994-05-19 02:01:16.000000000 +0000
6+++ mgdiff.man 6+++ mgdiff.man
7@@ -1,6 +1,7 @@ 7@@ -1,6 +1,7 @@
8 .\" mgdiff.man,v 2.0 1994/05/19 02:01:16 dan Exp 8 .\" mgdiff.man,v 2.0 1994/05/19 02:01:16 dan Exp
9 .\" 9 .\"
10 .\" Copyright (c) 1994 Daniel Williams 10 .\" Copyright (c) 1994 Daniel Williams
11+.\" Copyright (c) 2003 Erik de Castro Lopo 11+.\" Copyright (c) 2003 Erik de Castro Lopo
12 .\"  12 .\"
13 .\" The X Consortium, and any party obtaining a copy of these files from 13 .\" The X Consortium, and any party obtaining a copy of these files from
14 .\" the X Consortium, directly or indirectly, is granted, free of charge, 14 .\" the X Consortium, directly or indirectly, is granted, free of charge,
@@ -23,27 +23,38 @@ Pull patches from Debian. @@ -23,27 +23,38 @@ Pull patches from Debian.
23+current version allows the user to select both sides of a difference 23+current version allows the user to select both sides of a difference
24+by selecting blocks using the middle mouse button. When both sides of a  24+by selecting blocks using the middle mouse button. When both sides of a
25+difference are selected both blocks will be saved to the merged file and  25+difference are selected both blocks will be saved to the merged file and
26+marked in a similar manner to the way  26+marked in a similar manner to the way
27+.I CVS 27+.I CVS
28+marks merges that require manual resolution of conflicting changes. In 28+marks merges that require manual resolution of conflicting changes. In
29+addition, the current version also allows saving of a merged file with 29+addition, the current version also allows saving of a merged file with
30+unselected blocks. In this case, the merged file will contain  30+unselected blocks. In this case, the merged file will contain
31+neither the left hand side nor the right hand side of the unselected 31+neither the left hand side nor the right hand side of the unselected
32+blocks. 32+blocks.
33  33
34 .SH COMMAND LINE OPTIONS 34 .SH COMMAND LINE OPTIONS
35 .TP 8 35 .TP 8
36@@ -170,8 +185,27 @@ specify an output file for writing the m 36@@ -162,6 +177,10 @@ file.
 37 Brings up the "Open File" FileSelectionDialog to allow the user to
 38 specify a file to open and compare with the already opened left\-hand
 39 file.
 40+.IP "\fBReload Both\fP" \n(XYP
 41+.B Meta+R
 42+.LP
 43+Re-runs diff on both the currently opened files.
 44 .IP "\fBSave As...\fP" \n(XYP
 45 .B Ctrl+S
 46 .LP
 47@@ -170,8 +189,27 @@ specify an output file for writing the m
37 application modal dialog. The program will allow the user to 48 application modal dialog. The program will allow the user to
38 overwrite an existing file but pops up a QuestionDialog to allow the 49 overwrite an existing file but pops up a QuestionDialog to allow the
39 user to cancel the operation if desired. If there are any unselected 50 user to cancel the operation if desired. If there are any unselected
40-areas of difference between the two files the user is notified via an 51-areas of difference between the two files the user is notified via an
41-ErrorDialog and the save operation is canceled. 52-ErrorDialog and the save operation is canceled.
42+areas of difference between the two files the user is asked whether 53+areas of difference between the two files the user is asked whether
43+they want to continue or cancel the operation. If the user continues, 54+they want to continue or cancel the operation. If the user continues,
44+the output file will contain none of the unselected blocks. 55+the output file will contain none of the unselected blocks.
45+.IP "\fBSave As Left...\fP" \n(XYP 56+.IP "\fBSave As Left...\fP" \n(XYP
46+.LP 57+.LP
47+Saves the merged file to the location given by the left hand side 58+Saves the merged file to the location given by the left hand side
48+file location. The user will be asked if they are sure they wish the 59+file location. The user will be asked if they are sure they wish the
49+existing file to be overwritten. As with the "Save As", if there are  60+existing file to be overwritten. As with the "Save As", if there are
@@ -53,37 +64,41 @@ Pull patches from Debian. @@ -53,37 +64,41 @@ Pull patches from Debian.
53+unselected blocks. 64+unselected blocks.
54+.IP "\fBSave As Right...\fP" \n(XYP 65+.IP "\fBSave As Right...\fP" \n(XYP
55+.LP 66+.LP
56+Saves the merged file to the location given by the right hand side 67+Saves the merged file to the location given by the right hand side
57+file location. The user will be asked if they are sure they wish the 68+file location. The user will be asked if they are sure they wish the
58+existing file to be overwritten. As with the "Save As", if there are  69+existing file to be overwritten. As with the "Save As", if there are
59+any unselected areas of difference between the two files the user  70+any unselected areas of difference between the two files the user
60+asked whether they want to continue or cancel the operation. If the 71+asked whether they want to continue or cancel the operation. If the
61+user continues, the output file will contain none of the data in the 72+user continues, the output file will contain none of the data in the
62+unselected blocks. 73+unselected blocks.
63 .IP "\fBExit\fP" \n(XYP 74 .IP "\fBExit\fP" \n(XYP
64 .B Ctrl+C 75 .B Ctrl+C
65 .LP 76 .LP
66@@ -332,6 +366,9 @@ Mgdiff mgdiff 77@@ -330,8 +368,12 @@ Mgdiff mgdiff
 78 XmPushButtonGadget button_1
 79 XmPushButtonGadget button_2
67 XmPushButtonGadget button_3 80 XmPushButtonGadget button_3
68 XmSeparatorGadget separator_0 81- XmSeparatorGadget separator_0
69 XmPushButtonGadget button_4 82 XmPushButtonGadget button_4
 83+ XmSeparatorGadget separator_0
70+ XmPushButtonGadget button_5 84+ XmPushButtonGadget button_5
71+ XmSeparatorGadget separator_1 
72+ XmPushButtonGadget button_6 85+ XmPushButtonGadget button_6
 86+ XmSeparatorGadget separator_1
 87+ XmPushButtonGadget button_7
73 XmRowColumn options_menu 88 XmRowColumn options_menu
74 XmToggleButtonGadget button_0 89 XmToggleButtonGadget button_0
75 XmToggleButtonGadget button_1 90 XmToggleButtonGadget button_1
76@@ -543,12 +580,17 @@ command assumes arguments are delimited 91@@ -543,12 +585,17 @@ command assumes arguments are delimited
77 any quote processing. 92 any quote processing.
78 .SH COPYRIGHT 93 .SH COPYRIGHT
79 Copyright (c) 1994, Daniel Williams 94 Copyright (c) 1994, Daniel Williams
80+.br  95+.br
81+Copyright (c) 2003, Erik de Castro Lopo 96+Copyright (c) 2003, Erik de Castro Lopo
82 .br 97 .br
83 See 98 See
84 .B X (1) 99 .B X (1)
85 for a full statement of rights and permissions. 100 for a full statement of rights and permissions.
86-.SH AUTHOR 101-.SH AUTHOR
87+.SH AUTHORS 102+.SH AUTHORS
88 Daniel Williams (dan@sass.com) 103 Daniel Williams (dan@sass.com)
89+.br 104+.br

cvs diff -r1.3 -r1.4 pkgsrc/devel/mgdiff/patches/patch-mgdiff.c (expand / switch to unified diff)

--- pkgsrc/devel/mgdiff/patches/patch-mgdiff.c 2023/03/01 23:48:00 1.3
+++ pkgsrc/devel/mgdiff/patches/patch-mgdiff.c 2023/03/02 08:15:32 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: patch-mgdiff.c,v 1.3 2023/03/01 23:48:00 vins Exp $ 1$NetBSD: patch-mgdiff.c,v 1.4 2023/03/02 08:15:32 vins Exp $
2 2
3Prevent unsafe use of tmpnam().  3Prevent unsafe use of tmpnam().
4Pull patches from Debian. 4Pull patches from Debian.
5 5
6--- mgdiff.c.orig 1994-09-29 01:56:53.000000000 +0000 6--- mgdiff.c.orig 1994-09-29 01:56:53.000000000 +0000
7+++ mgdiff.c 7+++ mgdiff.c
8@@ -1,13 +1,14 @@ 8@@ -1,13 +1,14 @@
9-#ifndef lint 9-#ifndef lint
10-static char rcsid[] = "mgdiff.c,v 2.1 1994/09/29 01:56:53 dan Exp"; 10-static char rcsid[] = "mgdiff.c,v 2.1 1994/09/29 01:56:53 dan Exp";
11+#if 0 11+#if 0
12+static char rcsid[] __attribute__((unused)) = "mgdiff.c,v 2.1 1994/09/29 01:56:53 dan Exp"; 12+static char rcsid[] __attribute__((unused)) = "mgdiff.c,v 2.1 1994/09/29 01:56:53 dan Exp";
13 #endif 13 #endif
14  14
@@ -118,27 +118,27 @@ Pull patches from Debian. @@ -118,27 +118,27 @@ Pull patches from Debian.
118 * anyway) and less complex than turning on and correctly processing 118 * anyway) and less complex than turning on and correctly processing
119 * GraphicsExpose events. 119 * GraphicsExpose events.
120 */ 120 */
121-static int statel = VisibilityFullyObscured; 121-static int statel = VisibilityFullyObscured;
122-static int stater = VisibilityFullyObscured; 122-static int stater = VisibilityFullyObscured;
123+ 123+
124+/* Make the initial state unobscured. */ 124+/* Make the initial state unobscured. */
125+static int statel = VisibilityUnobscured; 125+static int statel = VisibilityUnobscured;
126+static int stater = VisibilityUnobscured; 126+static int stater = VisibilityUnobscured;
127+ 127+
128  128
129 /* ARGSUSED1 */ 129 /* ARGSUSED1 */
130 static void Visible (Widget widget, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch) 130 static void Visible (Widget widget, XtPointer closure, XEvent *event, Boolean *continue_to_dispatch)
131@@ -398,23 +420,37 @@ static void drawit (Widget w, XtPointer 131@@ -398,23 +420,37 @@ static void drawit (Widget w, XtPointer
132 Region region; 132 Region region;
133 Block *b; 133 Block *b;
134 GC fore, back; 134 GC fore, back;
135- int columns; 135- int columns;
136- 136-
137+ int columns, widget_side; 137+ int columns, widget_side;
138+  138+
139+ Side x_selection = NEITHER; 139+ Side x_selection = NEITHER;
140+ Block *curr_x_block = newss.lastSelected; 140+ Block *curr_x_block = newss.lastSelected;
141+  141+
142+ if (curr_x_block) { 142+ if (curr_x_block) {
143+ x_selection = curr_x_block->selected; 143+ x_selection = curr_x_block->selected;
144+ } 144+ }
@@ -160,385 +160,434 @@ Pull patches from Debian. @@ -160,385 +160,434 @@ Pull patches from Debian.
160 for (b = newss.b; b != NULL; b = b->next) { 160 for (b = newss.b; b != NULL; b = b->next) {
161 int j; 161 int j;
162 Chunk *ths, *oth; 162 Chunk *ths, *oth;
163  163
164- if (w == textl) { 164- if (w == textl) {
165+ if (widget_side == WIDGET_LEFT) { 165+ if (widget_side == WIDGET_LEFT) {
166 ths = &b->arr[LEFT]; 166 ths = &b->arr[LEFT];
167 oth = &b->arr[RIGHT]; 167 oth = &b->arr[RIGHT];
168- if (b->selected == LEFT) { 168- if (b->selected == LEFT) {
169+ if (b->selected == LEFT || b->selected == BOTH) { 169+ if (b->selected == LEFT || b->selected == BOTH) {
170 fore = gcfore[4]; 170 fore = gcfore[4];
171 back = gcback[4]; 171 back = gcback[4];
172 } 172 }
173@@ -423,10 +459,10 @@ static void drawit (Widget w, XtPointer 173@@ -423,10 +459,10 @@ static void drawit (Widget w, XtPointer
174 back = gcback[ths->type]; 174 back = gcback[ths->type];
175 } 175 }
176 } 176 }
177- else if (w == textr) { 177- else if (w == textr) {
178+ else if (widget_side == WIDGET_RIGHT) { 178+ else if (widget_side == WIDGET_RIGHT) {
179 ths = &b->arr[RIGHT]; 179 ths = &b->arr[RIGHT];
180 oth = &b->arr[LEFT]; 180 oth = &b->arr[LEFT];
181- if (b->selected == RIGHT) { 181- if (b->selected == RIGHT) {
182+ if (b->selected == RIGHT || b->selected == BOTH) { 182+ if (b->selected == RIGHT || b->selected == BOTH) {
183 fore = gcfore[4]; 183 fore = gcfore[4];
184 back = gcback[4]; 184 back = gcback[4];
185 } 185 }
186@@ -520,7 +556,7 @@ static void drawit (Widget w, XtPointer 186@@ -520,7 +556,7 @@ static void drawit (Widget w, XtPointer
187 /* ARGSUSED */ 187 /* ARGSUSED */
188 static void file_cb (Widget w, XtPointer closure, XtPointer call_data) 188 static void file_cb (Widget w, XtPointer closure, XtPointer call_data)
189 { 189 {
190- switch ((int) closure) { 190- switch ((int) closure) {
191+ switch ((intptr_t) closure) { 191+ switch ((intptr_t) closure) {
192 case 0: /* open */ 192 case 0: /* open */
193 toggle_open_sensitive (False); 193 toggle_open_sensitive (False);
194 set_cursor (toplevel); 194 set_cursor (toplevel);
195@@ -537,15 +573,32 @@ static void file_cb (Widget w, XtPointer 195@@ -536,16 +572,36 @@ static void file_cb (Widget w, XtPointer
 196 set_cursor (toplevel);
196 open_right_file (toplevel, str_fnamer); 197 open_right_file (toplevel, str_fnamer);
197 break; 198 break;
198 case 3: /* save as */ 199- case 3: /* save as */
199- if (all_selected ()) { 200- if (all_selected ()) {
200- set_cursor (toplevel); 201- set_cursor (toplevel);
201- save_file (toplevel, di->first, str_fnamel); 202- save_file (toplevel, di->first, str_fnamel);
 203+ case 3: /* refresh */
 204+ reload_both();
 205+ break;
 206+ case 4: /* save as */
202+ if (all_selected () == False) { 207+ if (all_selected () == False) {
203+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False) 208+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False)
204+ break; 209+ break;
205 } 210 }
206- else { 211- else {
207- werror (toplevel, "Save Error", "Save", "there are unselected text blocks"); 212- werror (toplevel, "Save Error", "Save", "there are unselected text blocks");
208+ save_file (toplevel, di->first, str_fnamel); 213+ save_file (toplevel, di->first, str_fnamel);
209+ break; 214+ break;
210+ case 4: /* save as left */ 215+ case 5: /* save as left */
211+ if (all_selected () == False) { 216+ if (all_selected () == False) {
212+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False) 217+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False)
213+ break; 218+ break;
214+ } 219 }
215+ set_cursor (toplevel); 220+ set_cursor (toplevel);
216+ save_as_filename (toplevel, di->first, str_fnamel); 221+ save_as_filename (toplevel, di->first, str_fnamel);
217+ reset_cursor (toplevel); 222+ reset_cursor (toplevel);
218+ break; 223 break;
219+ case 5: /* save as right */ 224- case 4: /* exit */
 225+ case 6: /* save as right */
220+ if (all_selected () == False) { 226+ if (all_selected () == False) {
221+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False) 227+ if (modal_question (toplevel, "Mgdiff Save", unselected_text_msg) == False)
222+ break; 228+ break;
223 } 229+ }
224+ set_cursor (toplevel); 230+ set_cursor (toplevel);
225+ save_as_filename (toplevel, di->first, str_fnamer); 231+ save_as_filename (toplevel, di->first, str_fnamer);
226+ reset_cursor (toplevel); 232+ reset_cursor (toplevel);
227+ 233+
228 break; 234+ break;
229- case 4: /* exit */ 235+ case 7: /* exit */
230+ case 6: /* exit */ 
231 exit_cb (w, NULL, NULL); 236 exit_cb (w, NULL, NULL);
232 break; 237 break;
233 default: 238 default:
234@@ -560,7 +613,7 @@ static void file_cb (Widget w, XtPointer 239@@ -560,7 +616,7 @@ static void file_cb (Widget w, XtPointer
235 /* ARGSUSED */ 240 /* ARGSUSED */
236 static void view_cb (Widget w, XtPointer closure, XtPointer call_data) 241 static void view_cb (Widget w, XtPointer closure, XtPointer call_data)
237 { 242 {
238- switch ((int) closure) { 243- switch ((int) closure) {
239+ switch ((intptr_t) closure) { 244+ switch ((intptr_t) closure) {
240 case 0: /* previous */ 245 case 0: /* previous */
241 prev_diff (NULL, NULL, NULL); 246 prev_diff (NULL, NULL, NULL);
242 break; 247 break;
243@@ -582,7 +635,7 @@ static void view_cb (Widget w, XtPointer 248@@ -582,7 +638,7 @@ static void view_cb (Widget w, XtPointer
244 /* ARGSUSED */ 249 /* ARGSUSED */
245 static void select_cb (Widget w, XtPointer closure, XtPointer call_data) 250 static void select_cb (Widget w, XtPointer closure, XtPointer call_data)
246 { 251 {
247- switch ((int) closure) { 252- switch ((int) closure) {
248+ switch ((intptr_t) closure) { 253+ switch ((intptr_t) closure) {
249 case 0: /* left */ 254 case 0: /* left */
250 select_all (LEFT); 255 select_all (LEFT);
251 break; 256 break;
252@@ -604,7 +657,7 @@ static void select_cb (Widget w, XtPoint 257@@ -604,7 +660,7 @@ static void select_cb (Widget w, XtPoint
253 /* ARGSUSED */ 258 /* ARGSUSED */
254 static void options_cb (Widget w, XtPointer closure, XtPointer call_data) 259 static void options_cb (Widget w, XtPointer closure, XtPointer call_data)
255 { 260 {
256- switch ((int) closure) { 261- switch ((int) closure) {
257+ switch ((intptr_t) closure) { 262+ switch ((intptr_t) closure) {
258 case 0: /* toggle overview area */ 263 case 0: /* toggle overview area */
259 overview_flag = !overview_flag; 264 overview_flag = !overview_flag;
260 if (overview_flag) { 265 if (overview_flag) {
261@@ -660,7 +713,7 @@ static void options_cb (Widget w, XtPoin 266@@ -660,7 +716,7 @@ static void options_cb (Widget w, XtPoin
262 /* ARGSUSED */ 267 /* ARGSUSED */
263 static void helpmenu_cb (Widget w, XtPointer closure, XtPointer call_data) 268 static void helpmenu_cb (Widget w, XtPointer closure, XtPointer call_data)
264 { 269 {
265- switch ((int) closure) { 270- switch ((int) closure) {
266+ switch ((intptr_t) closure) { 271+ switch ((intptr_t) closure) {
267 case 0: /* version */ 272 case 0: /* version */
268 show_version (toplevel); 273 show_version (toplevel);
269 break; 274 break;
270@@ -724,7 +777,6 @@ static void set_pixmaps (WidgetList chil 275@@ -724,7 +780,6 @@ static void set_pixmaps (WidgetList chil
271 dagcb = XtGetGC (children[1], GCForeground|GCBackground, &gc_values); 276 dagcb = XtGetGC (children[1], GCForeground|GCBackground, &gc_values);
272 been_here = 1; 277 been_here = 1;
273 } 278 }
274- 279-
275 for (i = 0; i < 3; i++) { 280 for (i = 0; i < 3; i++) {
276 XtVaGetValues (children[i], 281 XtVaGetValues (children[i],
277 XmNwidth, &width[i], 282 XmNwidth, &width[i],
278@@ -755,7 +807,7 @@ static void set_pixmaps (WidgetList chil 283@@ -755,7 +810,7 @@ static void set_pixmaps (WidgetList chil
279 yfpos[LEFT] += b->arr[LEFT].fsize; 284 yfpos[LEFT] += b->arr[LEFT].fsize;
280 h = ((int) height[0] * yfpos[LEFT] / max (di->flines[LEFT], 1)) - y; 285 h = ((int) height[0] * yfpos[LEFT] / max (di->flines[LEFT], 1)) - y;
281 y3 = ((h == 0) ? y1 : (y1 + h - 1)); 286 y3 = ((h == 0) ? y1 : (y1 + h - 1));
282- back = (b->selected == LEFT) ? 4 : b->arr[LEFT].type; 287- back = (b->selected == LEFT) ? 4 : b->arr[LEFT].type;
283+ back = (b->selected == LEFT || b->selected == BOTH) ? 4 : b->arr[LEFT].type; 288+ back = (b->selected == LEFT || b->selected == BOTH) ? 4 : b->arr[LEFT].type;
284 XFillRectangle (XtDisplay (children[0]), p[0], gcback[back], 289 XFillRectangle (XtDisplay (children[0]), p[0], gcback[back],
285 0, y, width[0], h); 290 0, y, width[0], h);
286  291
287@@ -763,7 +815,7 @@ static void set_pixmaps (WidgetList chil 292@@ -763,7 +818,7 @@ static void set_pixmaps (WidgetList chil
288 yfpos[RIGHT] += b->arr[RIGHT].fsize; 293 yfpos[RIGHT] += b->arr[RIGHT].fsize;
289 h = ((int) height[2] * yfpos[RIGHT] / max (di->flines[RIGHT], 1)) - y; 294 h = ((int) height[2] * yfpos[RIGHT] / max (di->flines[RIGHT], 1)) - y;
290 y4 = ((h == 0) ? y2 : (y2 + h - 1)); 295 y4 = ((h == 0) ? y2 : (y2 + h - 1));
291- back = (b->selected == RIGHT) ? 4 : b->arr[RIGHT].type; 296- back = (b->selected == RIGHT) ? 4 : b->arr[RIGHT].type;
292+ back = (b->selected == RIGHT || b->selected == BOTH) ? 4 : b->arr[RIGHT].type; 297+ back = (b->selected == RIGHT || b->selected == BOTH) ? 4 : b->arr[RIGHT].type;
293 XFillRectangle (XtDisplay (children[2]), p[2], gcback[back], 298 XFillRectangle (XtDisplay (children[2]), p[2], gcback[back],
294 0, y, width[2], h); 299 0, y, width[2], h);
295  300
296@@ -906,6 +958,7 @@ static void add_actions (XtAppContext ap 301@@ -906,6 +961,7 @@ static void add_actions (XtAppContext ap
297 */ 302 */
298 static char *foo3 = "\ 303 static char *foo3 = "\
299 <Btn1Down>: Select() \n\ 304 <Btn1Down>: Select() \n\
300+ <Btn2Down>: Select() \n\ 305+ <Btn2Down>: Select() \n\
301 ~Ctrl <Key>osfPageDown: Scroll(PageDown) \n\ 306 ~Ctrl <Key>osfPageDown: Scroll(PageDown) \n\
302 ~Ctrl <Key>osfPageUp: Scroll(PageUp) \n\ 307 ~Ctrl <Key>osfPageUp: Scroll(PageUp) \n\
303 <Key>osfLeft: Scroll(Left) \n\ 308 <Key>osfLeft: Scroll(Left) \n\
304@@ -951,8 +1004,9 @@ static void add_actions (XtAppContext ap 309@@ -951,8 +1007,9 @@ static void add_actions (XtAppContext ap
305 */ 310 */
306 static void cleanup_at_exit (void) 311 static void cleanup_at_exit (void)
307 { 312 {
308- if (tempfname != NULL) 313- if (tempfname != NULL)
309+ if (strlen (tempfname) > 0) 314+ if (strlen (tempfname) > 0)
310 (void) unlink (tempfname); 315 (void) unlink (tempfname);
311+ tempfname [0] = 0 ;  316+ tempfname [0] = 0 ;
312 } 317 }
313  318
314 /*  319 /*
315@@ -1017,8 +1071,11 @@ int main (int argc, char *argv[]) 320@@ -1017,8 +1074,11 @@ int main (int argc, char *argv[])
316 {"quitIfSame", "QuitIfSame", XtRBoolean, sizeof (Boolean), 0, XtRString, "false"}, 321 {"quitIfSame", "QuitIfSame", XtRBoolean, sizeof (Boolean), 0, XtRString, "false"},
317 {"debug", "Debug", XtRBoolean, sizeof (Boolean), 0, XtRString, "false"}, 322 {"debug", "Debug", XtRBoolean, sizeof (Boolean), 0, XtRString, "false"},
318 {"filename", "Filename", XtRString, sizeof (String), 0, XtRString, ""}}; 323 {"filename", "Filename", XtRString, sizeof (String), 0, XtRString, ""}};
319-  324-
320+#if !(defined __GLIBC__ && __GLIBC__ >= 2) 325+#if !(defined __GLIBC__ && __GLIBC__ >= 2)
321+ progname = mgdiff_basename (argv[0]); 326+ progname = mgdiff_basename (argv[0]);
322+#else 327+#else
323 progname = basename (argv[0]); 328 progname = basename (argv[0]);
324+#endif 329+#endif
325  330
326 toplevel = XtVaAppInitialize (&app, "Mgdiff", option_table, XtNumber (option_table), 331 toplevel = XtVaAppInitialize (&app, "Mgdiff", option_table, XtNumber (option_table),
327 #if X11R5 332 #if X11R5
328@@ -1027,6 +1084,10 @@ int main (int argc, char *argv[]) 333@@ -1027,6 +1087,10 @@ int main (int argc, char *argv[])
329 (unsigned int *) &argc, 334 (unsigned int *) &argc,
330 #endif 335 #endif
331 argv, fallbacks, NULL); 336 argv, fallbacks, NULL);
332+ setlocale (LC_ALL, ""); 337+ setlocale (LC_ALL, "");
333+ setlocale (LC_CTYPE, "POSIX"); 338+ setlocale (LC_CTYPE, "POSIX");
334+ XtSetLanguageProc (app, NULL, NULL); 339+ XtSetLanguageProc (app, NULL, NULL);
335+ 340+
336  341
337 XtVaGetValues (toplevel, XmNdepth, &depth, NULL); 342 XtVaGetValues (toplevel, XmNdepth, &depth, NULL);
338 if (depth == 1) 343 if (depth == 1)
339@@ -1079,7 +1140,6 @@ int main (int argc, char *argv[]) 344@@ -1079,7 +1143,6 @@ int main (int argc, char *argv[])
340 }; 345 };
341 werror_long (toplevel, "Wrong Application Defaults", array, sizeof (array) / sizeof (array[0])); 346 werror_long (toplevel, "Wrong Application Defaults", array, sizeof (array) / sizeof (array[0]));
342 } 347 }
343- 348-
344 if (debug_flag) { 349 if (debug_flag) {
345 XSetErrorHandler (x_error_handler); 350 XSetErrorHandler (x_error_handler);
346 XtAppSetErrorHandler (app, xt_error_handler); 351 XtAppSetErrorHandler (app, xt_error_handler);
347@@ -1087,7 +1147,10 @@ int main (int argc, char *argv[]) 352@@ -1087,7 +1150,10 @@ int main (int argc, char *argv[])
348 else 353 else
349 XtAppSetWarningHandler (app, xt_warning_handler); 354 XtAppSetWarningHandler (app, xt_warning_handler);
350  355
351-#if sun 356-#if sun
352+#if 0 357+#if 0
353+ /* May possibly be required on some old versions of SunOS. 358+ /* May possibly be required on some old versions of SunOS.
354+ ** Definitely not required on Solaris. 359+ ** Definitely not required on Solaris.
355+ */ 360+ */
356 (void) on_exit (cleanup_at_exit, NULL); 361 (void) on_exit (cleanup_at_exit, NULL);
357 #else 362 #else
358 (void) atexit (cleanup_at_exit); 363 (void) atexit (cleanup_at_exit);
359@@ -1109,14 +1172,17 @@ int main (int argc, char *argv[]) 364@@ -1109,14 +1175,17 @@ int main (int argc, char *argv[])
360 * two filenames on command line; process them 365 * two filenames on command line; process them
361 */ 366 */
362 case 3: 367 case 3:
363+ if (strcmp (argv[1], "-") == 0 && strcmp (argv[2], "-") == 0) { 368+ if (strcmp (argv[1], "-") == 0 && strcmp (argv[2], "-") == 0) {
364+ (void) fprintf (stderr, "Cannot use stdin for both file input\n"); 369+ (void) fprintf (stderr, "Cannot use stdin for both file input\n");
365+ exit (2); 370+ exit (2);
366+ } 371+ }
367 if (strcmp (argv[1], "-") == 0) { 372 if (strcmp (argv[1], "-") == 0) {
368- tempfname = tempnam (NULL, "mgdif"); 373- tempfname = tempnam (NULL, "mgdif");
369- str_fnamel = strdup (tempfname); 374- str_fnamel = strdup (tempfname);
370- str_snamel = strdup (user_filename); 375- str_snamel = strdup (user_filename);
371- if (!copy_to_file (stdin, tempfname)) { 376- if (!copy_to_file (stdin, tempfname)) {
372+ if (!copy_to_tempfile (stdin, tempfname, sizeof (tempfname))) { 377+ if (!copy_to_tempfile (stdin, tempfname, sizeof (tempfname))) {
373 (void) fprintf (stderr, "Error copying stdin to temp file \"%s\"\n", tempfname); 378 (void) fprintf (stderr, "Error copying stdin to temp file \"%s\"\n", tempfname);
374 exit (2); 379 exit (2);
375 } 380 }
376+ str_fnamel = strdup (tempfname); 381+ str_fnamel = strdup (tempfname);
377+ str_snamel = strdup (user_filename); 382+ str_snamel = strdup (user_filename);
378 } 383 }
379 else if (!file_tests (toplevel, argv[1])) { 384 else if (!file_tests (toplevel, argv[1])) {
380 no_files_flag = True; 385 no_files_flag = True;
381@@ -1131,13 +1197,12 @@ int main (int argc, char *argv[]) 386@@ -1131,13 +1200,12 @@ int main (int argc, char *argv[])
382 } 387 }
383  388
384 if (strcmp (argv[2], "-") == 0) { 389 if (strcmp (argv[2], "-") == 0) {
385- tempfname = tempnam (NULL, "mgdif"); 390- tempfname = tempnam (NULL, "mgdif");
386- str_fnamer = strdup (tempfname); 391- str_fnamer = strdup (tempfname);
387- str_snamer = strdup (user_filename); 392- str_snamer = strdup (user_filename);
388- if (!copy_to_file (stdin, tempfname)) { 393- if (!copy_to_file (stdin, tempfname)) {
389+ if (!copy_to_tempfile (stdin, tempfname, sizeof (tempfname))) { 394+ if (!copy_to_tempfile (stdin, tempfname, sizeof (tempfname))) {
390 (void) fprintf (stderr, "Error copying stdin to temp file \"%s\"\n", tempfname); 395 (void) fprintf (stderr, "Error copying stdin to temp file \"%s\"\n", tempfname);
391 exit (2); 396 exit (2);
392 } 397 }
393+ str_fnamer = strdup (tempfname); 398+ str_fnamer = strdup (tempfname);
394+ str_snamer = strdup (user_filename); 399+ str_snamer = strdup (user_filename);
395 } 400 }
396 else if (!file_tests (toplevel, argv[2])) { 401 else if (!file_tests (toplevel, argv[2])) {
397 no_files_flag = True; 402 no_files_flag = True;
398@@ -1174,6 +1239,7 @@ int main (int argc, char *argv[]) 403@@ -1174,6 +1242,7 @@ int main (int argc, char *argv[])
399 } 404 }
400  405
401 newss.b = di->first; 406 newss.b = di->first;
402+ newss.lastSelected= NULL; 407+ newss.lastSelected= NULL;
403 newss.topline = newss.sindex = newss.findex[LEFT] = newss.findex[RIGHT] = 0; 408 newss.topline = newss.sindex = newss.findex[LEFT] = newss.findex[RIGHT] = 0;
404  409
405 mainw = XtVaCreateManagedWidget ("mainw", xmMainWindowWidgetClass, 410 mainw = XtVaCreateManagedWidget ("mainw", xmMainWindowWidgetClass,
406@@ -1205,10 +1271,13 @@ int main (int argc, char *argv[]) 411@@ -1205,10 +1274,14 @@ int main (int argc, char *argv[])
407 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL, 412 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
408 XmVaSEPARATOR, 413 XmVaSEPARATOR,
409 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL, 414 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
410+ XmVaPUSHBUTTON, NULL, NULL, NULL, NULL, 415+ XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
 416+ XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
411+ XmVaSEPARATOR, 417+ XmVaSEPARATOR,
412+ XmVaPUSHBUTTON, NULL, NULL, NULL, NULL, 418+ XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
413 NULL); 419 NULL);
414 if (no_files_flag || (di->status == 2)) { 420 if (no_files_flag || (di->status == 2)) {
415 toggle_openlr_sensitive (False); 421 toggle_openlr_sensitive (False);
416- toggle_saveas_sensitive (False); 422- toggle_saveas_sensitive (False);
417+ toggle_saveas_sensitive (False, False, False); 423+ toggle_saveas_sensitive (False, False, False);
418 } 424 }
419 XmVaCreateSimplePulldownMenu (menubar, "view_menu", 1, view_cb, 425 XmVaCreateSimplePulldownMenu (menubar, "view_menu", 1, view_cb,
420 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL, 426 XmVaPUSHBUTTON, NULL, NULL, NULL, NULL,
421@@ -1491,6 +1560,7 @@ int main (int argc, char *argv[]) 427@@ -1491,6 +1564,7 @@ int main (int argc, char *argv[])
422  428
423 XtAppMainLoop (app); 429 XtAppMainLoop (app);
424 /* NOTREACHED */ 430 /* NOTREACHED */
425+ return 0; 431+ return 0;
426 } 432 }
427  433
428 static void redraw_partial_vert (Widget w) 434 static void redraw_partial_vert (Widget w)
429@@ -1622,9 +1692,9 @@ static void update_line_numbers (int l, 435@@ -1622,9 +1696,9 @@ static void update_line_numbers (int l,
430 { 436 {
431 char buffer[16]; 437 char buffer[16];
432  438
433- (void) sprintf (buffer, "%*d", linenum_columns, l); 439- (void) sprintf (buffer, "%*d", linenum_columns, l);
434+ (void) snprintf (buffer, sizeof (buffer), "%*d", linenum_columns, l); 440+ (void) snprintf (buffer, sizeof (buffer), "%*d", linenum_columns, l);
435 XmTextFieldSetString (linenuml, buffer); 441 XmTextFieldSetString (linenuml, buffer);
436- (void) sprintf (buffer, "%*d", linenum_columns, r); 442- (void) sprintf (buffer, "%*d", linenum_columns, r);
437+ (void) snprintf (buffer, sizeof (buffer), "%*d", linenum_columns, r); 443+ (void) snprintf (buffer, sizeof (buffer), "%*d", linenum_columns, r);
438 XmTextFieldSetString (linenumr, buffer); 444 XmTextFieldSetString (linenumr, buffer);
439 } 445 }
440  446
441@@ -1860,19 +1930,20 @@ static void next_diff (Widget w, XtPoint 447@@ -1860,19 +1934,20 @@ static void next_diff (Widget w, XtPoint
442  448
443 value = (b->sline >= lines_of_context) ? (b->sline - lines_of_context) : b->sline; 449 value = (b->sline >= lines_of_context) ? (b->sline - lines_of_context) : b->sline;
444 XtVaGetValues (sb, XmNmaximum, &maximum, XmNsliderSize, &slidersize, NULL); 450 XtVaGetValues (sb, XmNmaximum, &maximum, XmNsliderSize, &slidersize, NULL);
445- if (value > (maximum - slidersize)) 451- if (value > (maximum - slidersize))
446- value = maximum - slidersize; 452- value = maximum - slidersize;
447  453
448 if ((w == sbl) || (w == sbr)) { 454 if ((w == sbl) || (w == sbr)) {
449 int side = (w == sbl) ? LEFT : RIGHT; 455 int side = (w == sbl) ? LEFT : RIGHT;
450  456
451- if (newcbs.value > (maximum - slidersize)) { 457- if (newcbs.value > (maximum - slidersize)) {
452- newcbs.value = maximum - slidersize; 458- newcbs.value = maximum - slidersize;
453- XtVaSetValues (w, XmNvalue, newcbs.value - b->sline + b->arr[side].fline, NULL); 459- XtVaSetValues (w, XmNvalue, newcbs.value - b->sline + b->arr[side].fline, NULL);
454+ if (value > (maximum - slidersize)) { 460+ if (value > (maximum - slidersize)) {
455+ value = maximum - slidersize; 461+ value = maximum - slidersize;
456+ XtVaSetValues (w, XmNvalue, value - b->sline + b->arr[side].fline, NULL); 462+ XtVaSetValues (w, XmNvalue, value - b->sline + b->arr[side].fline, NULL);
457 return; 463 return;
458 } 464 }
459 } 465 }
460  466
461+ if (value > (maximum - slidersize)) 467+ if (value > (maximum - slidersize))
462+ value = maximum - slidersize; 468+ value = maximum - slidersize;
463+ 469+
464 newcbs.reason = XmCR_VALUE_CHANGED; 470 newcbs.reason = XmCR_VALUE_CHANGED;
465 newcbs.event = NULL; 471 newcbs.event = NULL;
466 newcbs.value = value; 472 newcbs.value = value;
467@@ -1986,7 +2057,7 @@ static void show_version (Widget parent) 473@@ -1986,7 +2061,7 @@ static void show_version (Widget parent)
468 mgdiff_width, mgdiff_height, 474 mgdiff_width, mgdiff_height,
469 fg, bg, 475 fg, bg,
470 DefaultDepth (dpy, DefaultScreen (dpy))); 476 DefaultDepth (dpy, DefaultScreen (dpy)));
471- (void) sprintf (buffer, "mgdiff\n\nA graphical difference browser\n\nAuthor: Dan Williams (dan@sass.com)\nVersion: %s PL%s", VERSION, PATCHLEVEL); 477- (void) sprintf (buffer, "mgdiff\n\nA graphical difference browser\n\nAuthor: Dan Williams (dan@sass.com)\nVersion: %s PL%s", VERSION, PATCHLEVEL);
472+ (void) snprintf (buffer, sizeof (buffer), "mgdiff\n\nA graphical difference browser\n\nAuthors: Dan Williams (dan@sass.com)\nErik de Castro Lopo (erikd@mega-nerd.com)\n\nVersion: %s PL%s", VERSION, PATCHLEVEL); 478+ (void) snprintf (buffer, sizeof (buffer), "mgdiff\n\nA graphical difference browser\n\nAuthors: Dan Williams (dan@sass.com)\nErik de Castro Lopo (erikd@mega-nerd.com)\n\nVersion: %s PL%s", VERSION, PATCHLEVEL);
473  479
474 XtVaSetValues (dialog, 480 XtVaSetValues (dialog,
475 XmNautoUnmanage, True, 481 XmNautoUnmanage, True,
476@@ -2041,12 +2112,12 @@ void process_both_files (char *file1, ch 482@@ -2020,6 +2095,42 @@ static void update_overall (void)
 483 newss.findex[RIGHT] = value;
 484 }
 485
 486+/* Re-run diff on the current files and update the display */
 487+void reload_both(void)
 488+{
 489+ DiffInfo *newdi;
 490+
 491+ set_cursor (toplevel);
 492+
 493+ if (no_files_flag == True) {
 494+ /* Currently there are no files,
 495+ so don't do anything */
 496+ return;
 497+ }
 498+
 499+ newdi = build_diff_info (diffcmd, diffargs, str_fnamel, str_fnamer);
 500+
 501+ free_diff_info (di);
 502+ di = newdi;
 503+ if (di->status == 2) {
 504+ no_files_flag = True;
 505+ toggle_openlr_sensitive (False);
 506+ toggle_saveas_sensitive (False, False, False);
 507+ free (str_fnamel);
 508+ free (str_snamel);
 509+ free (str_fnamer);
 510+ free (str_snamer);
 511+ str_snamel = strdup ("(no file)");
 512+ str_snamer = strdup ("(no file)");
 513+ str_fnamel = str_fnamer = NULL;
 514+ }
 515+ refresh ();
 516+ fake_adjust_label (fnamel);
 517+ reset_cursor (toplevel);
 518+
 519+ handle_diff_errors (di);
 520+}
 521+
 522 void process_both_files (char *file1, char *name1, char *file2, char *name2)
 523 {
 524 DiffInfo *newdi;
 525@@ -2041,12 +2152,12 @@ void process_both_files (char *file1, ch
477 if (di->status != 2) { 526 if (di->status != 2) {
478 no_files_flag = False; 527 no_files_flag = False;
479 toggle_openlr_sensitive (True); 528 toggle_openlr_sensitive (True);
480- toggle_saveas_sensitive (True); 529- toggle_saveas_sensitive (True);
481+ toggle_saveas_sensitive (True, True, True); 530+ toggle_saveas_sensitive (True, True, True);
482 } 531 }
483 else { 532 else {
484 no_files_flag = True; 533 no_files_flag = True;
485 toggle_openlr_sensitive (False); 534 toggle_openlr_sensitive (False);
486- toggle_saveas_sensitive (False); 535- toggle_saveas_sensitive (False);
487+ toggle_saveas_sensitive (False, False, False); 536+ toggle_saveas_sensitive (False, False, False);
488 free (str_fnamel); 537 free (str_fnamel);
489 free (str_snamel); 538 free (str_snamel);
490 free (str_fnamer); 539 free (str_fnamer);
491@@ -2082,7 +2153,7 @@ void process_left_file (char *file1, cha 540@@ -2082,7 +2193,7 @@ void process_left_file (char *file1, cha
492 if (di->status == 2) { 541 if (di->status == 2) {
493 no_files_flag = True; 542 no_files_flag = True;
494 toggle_openlr_sensitive (False); 543 toggle_openlr_sensitive (False);
495- toggle_saveas_sensitive (False); 544- toggle_saveas_sensitive (False);
496+ toggle_saveas_sensitive (False, False, False); 545+ toggle_saveas_sensitive (False, False, False);
497 free (str_fnamel); 546 free (str_fnamel);
498 free (str_snamel); 547 free (str_snamel);
499 free (str_fnamer); 548 free (str_fnamer);
500@@ -2117,7 +2188,7 @@ void process_right_file (char *file2, ch 549@@ -2117,7 +2228,7 @@ void process_right_file (char *file2, ch
501 if (di->status == 2) { 550 if (di->status == 2) {
502 no_files_flag = True; 551 no_files_flag = True;
503 toggle_openlr_sensitive (False); 552 toggle_openlr_sensitive (False);
504- toggle_saveas_sensitive (False); 553- toggle_saveas_sensitive (False);
505+ toggle_saveas_sensitive (False, False, False); 554+ toggle_saveas_sensitive (False, False, False);
506 free (str_fnamel); 555 free (str_fnamel);
507 free (str_snamel); 556 free (str_snamel);
508 free (str_fnamer); 557 free (str_fnamer);
509@@ -2133,6 +2204,7 @@ void process_right_file (char *file2, ch 558@@ -2133,6 +2244,7 @@ void process_right_file (char *file2, ch
510 handle_diff_errors (di); 559 handle_diff_errors (di);
511 } 560 }
512  561
513+ 562+
514 static void refresh (void) 563 static void refresh (void)
515 { 564 {
516 newss.b = di->first; 565 newss.b = di->first;
517@@ -2182,9 +2254,11 @@ void toggle_open_sensitive (Boolean sens 566@@ -2182,9 +2294,11 @@ void toggle_open_sensitive (Boolean sens
518 toggle_openlr_sensitive (sensitive); 567 toggle_openlr_sensitive (sensitive);
519 } 568 }
520  569
521-static void toggle_saveas_sensitive (Boolean sensitive) 570-static void toggle_saveas_sensitive (Boolean sensitive)
522+static void toggle_saveas_sensitive (Boolean saveas, Boolean save_left, Boolean save_right) 571+static void toggle_saveas_sensitive (Boolean saveas, Boolean save_left, Boolean save_right)
523 { 572 {
524- XtSetSensitive (XtNameToWidget (file_menu, "button_3"), sensitive); 573- XtSetSensitive (XtNameToWidget (file_menu, "button_3"), sensitive);
525+ XtSetSensitive (XtNameToWidget (file_menu, "button_3"), saveas); 574+ XtSetSensitive (XtNameToWidget (file_menu, "button_4"), saveas);
526+ XtSetSensitive (XtNameToWidget (file_menu, "button_4"), save_left); 575+ XtSetSensitive (XtNameToWidget (file_menu, "button_5"), save_left);
527+ XtSetSensitive (XtNameToWidget (file_menu, "button_5"), save_right); 576+ XtSetSensitive (XtNameToWidget (file_menu, "button_6"), save_right);
528 } 577 }
529  578
530 /*  579 /*
531@@ -2196,78 +2270,263 @@ static void exit_cb (Widget w, XtPointer 580@@ -2196,78 +2310,263 @@ static void exit_cb (Widget w, XtPointer
532 exit ((di != NULL) ? di->status : 2); 581 exit ((di != NULL) ? di->status : 2);
533 } 582 }
534  583
535+static void lost_selection ( Widget widget, Atom* selection) {  584+static void lost_selection ( Widget widget, Atom* selection) {
536+  585+
537+ if (debug_flag) { 586+ if (debug_flag) {
538+ fprintf(stderr,"selection lost on widget %p\n",widget); 587+ fprintf(stderr,"selection lost on widget %p\n",widget);
539+ } 588+ }
540+// newss.lastSelected=NULL; 589+// newss.lastSelected=NULL;
541+} 590+}
542+ 591+
543+static Boolean do_selection(Widget widget, Atom* selection, Atom* target , 592+static Boolean do_selection(Widget widget, Atom* selection, Atom* target ,
544+ Atom* type, XtPointer* value,  593+ Atom* type, XtPointer* value,
@@ -829,45 +878,45 @@ Pull patches from Debian. @@ -829,45 +878,45 @@ Pull patches from Debian.
829+ { 878+ {
830+ XtDisownSelection(widget,XA_PRIMARY, CurrentTime); 879+ XtDisownSelection(widget,XA_PRIMARY, CurrentTime);
831+ } 880+ }
832+  881+
833+ if (newss.lastSelected) { 882+ if (newss.lastSelected) {
834+ XtOwnSelection(widget,XA_PRIMARY, CurrentTime,&do_selection,&lost_selection,NULL); 883+ XtOwnSelection(widget,XA_PRIMARY, CurrentTime,&do_selection,&lost_selection,NULL);
835+ } 884+ }
836+ 885+
837+ return; 886+ return;
838+ } 887+ }
839 } 888 }
840  889
841 /*  890 /*
842@@ -2307,14 +2566,14 @@ static void Scroll (Widget widget, XEven 891@@ -2307,14 +2606,14 @@ static void Scroll (Widget widget, XEven
843 else { 892 else {
844 char buffer[1024]; 893 char buffer[1024];
845  894
846- (void) sprintf (buffer, "Illegal argument to action proc Scroll (\"%s\")", params[0]); 895- (void) sprintf (buffer, "Illegal argument to action proc Scroll (\"%s\")", params[0]);
847+ (void) snprintf (buffer, sizeof (buffer), "Illegal argument to action proc Scroll (\"%s\")", params[0]); 896+ (void) snprintf (buffer, sizeof (buffer), "Illegal argument to action proc Scroll (\"%s\")", params[0]);
848 XtAppWarning (XtWidgetToApplicationContext (widget), buffer); 897 XtAppWarning (XtWidgetToApplicationContext (widget), buffer);
849 } 898 }
850 } 899 }
851 else { 900 else {
852 char buffer[1024]; 901 char buffer[1024];
853  902
854- (void) sprintf (buffer, "Illegal number of arguments to action proc Scroll (\"%d\")", *num_params); 903- (void) sprintf (buffer, "Illegal number of arguments to action proc Scroll (\"%d\")", *num_params);
855+ (void) snprintf (buffer, sizeof (buffer), "Illegal number of arguments to action proc Scroll (\"%d\")", *num_params); 904+ (void) snprintf (buffer, sizeof (buffer), "Illegal number of arguments to action proc Scroll (\"%d\")", *num_params);
856 XtAppWarning (XtWidgetToApplicationContext (widget), buffer); 905 XtAppWarning (XtWidgetToApplicationContext (widget), buffer);
857 } 906 }
858 } 907 }
859@@ -2391,7 +2650,8 @@ static Dimension get_preferred_width (Wi 908@@ -2391,7 +2690,8 @@ static Dimension get_preferred_width (Wi
860 /*  909 /*
861 * delete any prefix ending in '/' and return a copy 910 * delete any prefix ending in '/' and return a copy
862 */ 911 */
863-static char *basename (char *path) 912-static char *basename (char *path)
864+#if !(defined __GLIBC__ && __GLIBC__ >= 2) 913+#if !(defined __GLIBC__ && __GLIBC__ >= 2)
865+static char *mgdiff_basename (char *path) 914+static char *mgdiff_basename (char *path)
866 { 915 {
867 if (path) { 916 if (path) {
868 char *p; 917 char *p;
869@@ -2416,3 +2676,4 @@ static char *basename (char *path) 918@@ -2416,3 +2716,4 @@ static char *basename (char *path)
870 else 919 else
871 return (NULL); 920 return (NULL);
872 } 921 }
873+#endif 922+#endif