1 /* $NetBSD: sdiff.c,v 1.1.1.1 2003/01/26 00:43:17 wiz Exp $ */
3 /* sdiff - side-by-side merge of file differences
5 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 2001, 2002 Free
6 Software Foundation, Inc.
8 This file is part of GNU DIFF.
10 GNU DIFF is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU DIFF is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; see the file COPYING.
22 If not, write to the Free Software Foundation,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
37 static char const authorship_msgid
[] = N_("Written by Thomas Lord.");
39 static char const copyright_string
[] =
40 "Copyright (C) 2002 Free Software Foundation, Inc.";
42 extern char const version_string
[];
44 /* Size of chunks read from files which must be parsed into lines. */
45 #define SDIFF_BUFSIZE ((size_t) 65536)
49 static char const *editor_program
= DEFAULT_EDITOR_PROGRAM
;
50 static char const **diffargv
;
52 static char * volatile tmpname
;
55 #if HAVE_WORKING_FORK || HAVE_WORKING_VFORK
56 static pid_t
volatile diffpid
;
61 static RETSIGTYPE
catchsig (int);
62 static bool edit (struct line_filter
*, char const *, lin
, lin
, struct line_filter
*, char const *, lin
, lin
, FILE *);
63 static bool interact (struct line_filter
*, struct line_filter
*, char const *, struct line_filter
*, char const *, FILE *);
64 static void checksigs (void);
65 static void diffarg (char const *);
66 static void fatal (char const *) __attribute__((noreturn
));
67 static void perror_fatal (char const *) __attribute__((noreturn
));
68 static void trapsigs (void);
69 static void untrapsig (int);
71 #define NUM_SIGS (sizeof sigs / sizeof *sigs)
72 static int const sigs
[] = {
91 #define handler_index_of_SIGINT (NUM_SIGS - 2)
92 #define handler_index_of_SIGPIPE (NUM_SIGS - 1)
95 /* Prefer `sigaction' if available, since `signal' can lose signals. */
96 static struct sigaction initial_action
[NUM_SIGS
];
97 # define initial_handler(i) (initial_action[i].sa_handler)
98 static void signal_handler (int, RETSIGTYPE (*) (int));
100 static RETSIGTYPE (*initial_action
[NUM_SIGS
]) ();
101 # define initial_handler(i) (initial_action[i])
102 # define signal_handler(sig, handler) signal (sig, handler)
105 #if ! HAVE_SIGPROCMASK
106 # define sigset_t int
107 # define sigemptyset(s) (*(s) = 0)
109 # define sigmask(sig) (1 << ((sig) - 1))
111 # define sigaddset(s, sig) (*(s) |= sigmask (sig))
116 # define SIG_SETMASK (! SIG_BLOCK)
118 # define sigprocmask(how, n, o) \
119 ((how) == SIG_BLOCK ? *(o) = sigblock (*(n)) : sigsetmask (*(n)))
122 static bool diraccess (char const *);
123 static int temporary_file (void);
127 /* Name of output file if -o specified. */
128 static char const *output
;
130 /* Do not print common lines. */
131 static bool suppress_common_lines
;
133 /* Value for the long option that does not have single-letter equivalents. */
136 DIFF_PROGRAM_OPTION
= CHAR_MAX
+ 1,
138 STRIP_TRAILING_CR_OPTION
141 static struct option
const longopts
[] =
143 {"diff-program", 1, 0, DIFF_PROGRAM_OPTION
},
144 {"expand-tabs", 0, 0, 't'},
145 {"help", 0, 0, HELP_OPTION
},
146 {"ignore-all-space", 0, 0, 'W'}, /* swap W and w for historical reasons */
147 {"ignore-blank-lines", 0, 0, 'B'},
148 {"ignore-case", 0, 0, 'i'},
149 {"ignore-matching-lines", 1, 0, 'I'},
150 {"ignore-space-change", 0, 0, 'b'},
151 {"ignore-tab-expansion", 0, 0, 'E'},
152 {"left-column", 0, 0, 'l'},
153 {"minimal", 0, 0, 'd'},
154 {"output", 1, 0, 'o'},
155 {"speed-large-files", 0, 0, 'H'},
156 {"strip-trailing-cr", 0, 0, STRIP_TRAILING_CR_OPTION
},
157 {"suppress-common-lines", 0, 0, 's'},
159 {"version", 0, 0, 'v'},
160 {"width", 1, 0, 'w'},
164 static void try_help (char const *, char const *) __attribute__((noreturn
));
166 try_help (char const *reason_msgid
, char const *operand
)
169 error (0, 0, _(reason_msgid
), operand
);
170 error (EXIT_TROUBLE
, 0, _("Try `%s --help' for more information."),
179 fatal ("write failed");
180 else if (fclose (stdout
) != 0)
181 perror_fatal (_("standard output"));
184 static char const * const option_help_msgid
[] = {
185 N_("-o FILE --output=FILE Operate interactively, sending output to FILE."),
187 N_("-i --ignore-case Consider upper- and lower-case to be the same."),
188 N_("-E --ignore-tab-expansion Ignore changes due to tab expansion."),
189 N_("-b --ignore-space-change Ignore changes in the amount of white space."),
190 N_("-W --ignore-all-space Ignore all white space."),
191 N_("-B --ignore-blank-lines Ignore changes whose lines are all blank."),
192 N_("-I RE --ignore-matching-lines=RE Ignore changes whose lines all match RE."),
193 N_("--strip-trailing-cr Strip trailing carriage return on input."),
194 N_("-a --text Treat all files as text."),
196 N_("-w NUM --width=NUM Output at most NUM (default 130) columns per line."),
197 N_("-l --left-column Output only the left column of common lines."),
198 N_("-s --suppress-common-lines Do not output common lines."),
200 N_("-t --expand-tabs Expand tabs to spaces in output."),
202 N_("-d --minimal Try hard to find a smaller set of changes."),
203 N_("-H --speed-large-files Assume large files and many scattered small changes."),
204 N_("--diff-program=PROGRAM Use PROGRAM to compare files."),
206 N_("-v --version Output version info."),
207 N_("--help Output this help."),
214 char const * const *p
;
216 printf (_("Usage: %s [OPTION]... FILE1 FILE2\n"), program_name
);
217 printf ("%s\n\n", _("Side-by-side merge of file differences."));
218 for (p
= option_help_msgid
; *p
; p
++)
220 printf (" %s\n", _(*p
));
223 printf ("\n%s\n\n%s\n",
224 _("If a FILE is `-', read standard input."),
225 _("Report bugs to <bug-gnu-utils@gnu.org>."));
231 #if HAVE_WORKING_FORK || HAVE_WORKING_VFORK
233 kill (diffpid
, SIGPIPE
);
239 static void exiterr (void) __attribute__((noreturn
));
250 fatal (char const *msgid
)
252 error (0, 0, "%s", _(msgid
));
257 perror_fatal (char const *msg
)
261 error (0, e
, "%s", msg
);
266 check_child_status (int werrno
, int wstatus
, int max_ok_status
,
267 char const *subsidiary_program
)
269 int status
= (! werrno
&& WIFEXITED (wstatus
)
270 ? WEXITSTATUS (wstatus
)
273 if (max_ok_status
< status
)
277 ? "subsidiary program `%s' could not be invoked"
279 ? "subsidiary program `%s' not found"
281 ? "subsidiary program `%s' failed"
282 : "subsidiary program `%s' failed (exit status %d)"),
283 subsidiary_program
, status
);
289 ck_fopen (char const *fname
, char const *type
)
291 FILE *r
= fopen (fname
, type
);
293 perror_fatal (fname
);
301 perror_fatal ("fclose");
305 ck_fread (char *buf
, size_t size
, FILE *f
)
307 size_t r
= fread (buf
, sizeof (char), size
, f
);
308 if (r
== 0 && ferror (f
))
309 perror_fatal (_("read failed"));
314 ck_fwrite (char const *buf
, size_t size
, FILE *f
)
316 if (fwrite (buf
, sizeof (char), size
, f
) != size
)
317 perror_fatal (_("write failed"));
324 perror_fatal (_("write failed"));
328 expand_name (char *name
, bool is_dir
, char const *other_name
)
330 if (strcmp (name
, "-") == 0)
331 fatal ("cannot interactively merge standard input");
336 /* Yield NAME/BASE, where BASE is OTHER_NAME's basename. */
337 char const *base
= base_name (other_name
);
338 size_t namelen
= strlen (name
), baselen
= strlen (base
);
339 bool insert_slash
= *base_name (name
) && name
[namelen
- 1] != '/';
340 char *r
= xmalloc (namelen
+ insert_slash
+ baselen
+ 1);
341 memcpy (r
, name
, namelen
);
343 memcpy (r
+ namelen
+ insert_slash
, base
, baselen
+ 1);
358 lf_init (struct line_filter
*lf
, FILE *infile
)
361 lf
->bufpos
= lf
->buffer
= lf
->buflim
= xmalloc (SDIFF_BUFSIZE
+ 1);
362 lf
->buflim
[0] = '\n';
365 /* Fill an exhausted line_filter buffer from its INFILE */
367 lf_refill (struct line_filter
*lf
)
369 size_t s
= ck_fread (lf
->buffer
, SDIFF_BUFSIZE
, lf
->infile
);
370 lf
->bufpos
= lf
->buffer
;
371 lf
->buflim
= lf
->buffer
+ s
;
372 lf
->buflim
[0] = '\n';
377 /* Advance LINES on LF's infile, copying lines to OUTFILE */
379 lf_copy (struct line_filter
*lf
, lin lines
, FILE *outfile
)
381 char *start
= lf
->bufpos
;
385 lf
->bufpos
= (char *) memchr (lf
->bufpos
, '\n', lf
->buflim
- lf
->bufpos
);
388 ck_fwrite (start
, lf
->buflim
- start
, outfile
);
389 if (! lf_refill (lf
))
400 ck_fwrite (start
, lf
->bufpos
- start
, outfile
);
403 /* Advance LINES on LF's infile without doing output */
405 lf_skip (struct line_filter
*lf
, lin lines
)
409 lf
->bufpos
= (char *) memchr (lf
->bufpos
, '\n', lf
->buflim
- lf
->bufpos
);
412 if (! lf_refill (lf
))
423 /* Snarf a line into a buffer. Return EOF if EOF, 0 if error, 1 if OK. */
425 lf_snarf (struct line_filter
*lf
, char *buffer
, size_t bufsize
)
429 char *start
= lf
->bufpos
;
430 char *next
= (char *) memchr (start
, '\n', lf
->buflim
+ 1 - start
);
431 size_t s
= next
- start
;
434 memcpy (buffer
, start
, s
);
435 if (next
< lf
->buflim
)
438 lf
->bufpos
= next
+ 1;
441 if (! lf_refill (lf
))
451 main (int argc
, char *argv
[])
456 exit_failure
= EXIT_TROUBLE
;
457 initialize_main (&argc
, &argv
);
458 program_name
= argv
[0];
459 setlocale (LC_ALL
, "");
460 bindtextdomain (PACKAGE
, LOCALEDIR
);
461 textdomain (PACKAGE
);
462 c_stack_action (c_stack_die
);
464 prog
= getenv ("EDITOR");
466 editor_program
= prog
;
468 diffarg (DEFAULT_DIFF_PROGRAM
);
470 /* parse command line args */
471 while ((opt
= getopt_long (argc
, argv
, "abBdHiI:lo:stvw:W", longopts
, 0))
510 diffarg ("--left-column");
518 suppress_common_lines
= 1;
526 printf ("sdiff %s\n%s\n\n%s\n\n%s\n",
527 version_string
, copyright_string
,
528 _(free_software_msgid
), _(authorship_msgid
));
541 case DIFF_PROGRAM_OPTION
:
542 diffargv
[0] = optarg
;
550 case STRIP_TRAILING_CR_OPTION
:
551 diffarg ("--strip-trailing-cr");
559 if (argc
- optind
!= 2)
561 if (argc
- optind
< 2)
562 try_help ("missing operand after `%s'", argv
[argc
- 1]);
564 try_help ("extra operand `%s'", argv
[optind
+ 2]);
569 /* easy case: diff does everything for us */
570 if (suppress_common_lines
)
571 diffarg ("--suppress-common-lines");
574 diffarg (argv
[optind
]);
575 diffarg (argv
[optind
+ 1]);
577 execvp (diffargv
[0], (char **) diffargv
);
578 perror_fatal (diffargv
[0]);
582 char const *lname
, *rname
;
583 FILE *left
, *right
, *out
, *diffout
;
585 struct line_filter lfilt
;
586 struct line_filter rfilt
;
587 struct line_filter diff_filt
;
588 bool leftdir
= diraccess (argv
[optind
]);
589 bool rightdir
= diraccess (argv
[optind
+ 1]);
591 if (leftdir
& rightdir
)
592 fatal ("both files to be compared are directories");
594 lname
= expand_name (argv
[optind
], leftdir
, argv
[optind
+ 1]);
595 left
= ck_fopen (lname
, "r");
596 rname
= expand_name (argv
[optind
+ 1], rightdir
, argv
[optind
]);
597 right
= ck_fopen (rname
, "r");
598 out
= ck_fopen (output
, "w");
600 diffarg ("--sdiff-merge-assist");
602 diffarg (argv
[optind
]);
603 diffarg (argv
[optind
+ 1]);
608 #if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK)
614 for (i
= 0; diffargv
[i
]; i
++)
615 cmdsize
+= quote_system_arg (0, diffargv
[i
]) + 1;
616 command
= p
= xmalloc (cmdsize
);
617 for (i
= 0; diffargv
[i
]; i
++)
619 p
+= quote_system_arg (p
, diffargv
[i
]);
624 diffout
= popen (command
, "r");
626 perror_fatal (command
);
632 # if HAVE_WORKING_VFORK
637 if (pipe (diff_fds
) != 0)
638 perror_fatal ("pipe");
640 # if HAVE_WORKING_VFORK
641 /* Block SIGINT and SIGPIPE. */
642 sigemptyset (&blocked
);
643 sigaddset (&blocked
, SIGINT
);
644 sigaddset (&blocked
, SIGPIPE
);
645 sigprocmask (SIG_BLOCK
, &blocked
, &procmask
);
649 perror_fatal ("fork");
652 /* Alter the child's SIGINT and SIGPIPE handlers;
653 this may munge the parent.
654 The child ignores SIGINT in case the user interrupts the editor.
655 The child does not ignore SIGPIPE, even if the parent does. */
656 if (initial_handler (handler_index_of_SIGINT
) != SIG_IGN
)
657 signal_handler (SIGINT
, SIG_IGN
);
658 signal_handler (SIGPIPE
, SIG_DFL
);
659 # if HAVE_WORKING_VFORK
660 /* Stop blocking SIGINT and SIGPIPE in the child. */
661 sigprocmask (SIG_SETMASK
, &procmask
, 0);
664 if (diff_fds
[1] != STDOUT_FILENO
)
666 dup2 (diff_fds
[1], STDOUT_FILENO
);
670 execvp (diffargv
[0], (char **) diffargv
);
671 _exit (errno
== ENOEXEC
? 126 : 127);
674 # if HAVE_WORKING_VFORK
675 /* Restore the parent's SIGINT and SIGPIPE behavior. */
676 if (initial_handler (handler_index_of_SIGINT
) != SIG_IGN
)
677 signal_handler (SIGINT
, catchsig
);
678 if (initial_handler (handler_index_of_SIGPIPE
) != SIG_IGN
)
679 signal_handler (SIGPIPE
, catchsig
);
681 signal_handler (SIGPIPE
, SIG_IGN
);
683 /* Stop blocking SIGINT and SIGPIPE in the parent. */
684 sigprocmask (SIG_SETMASK
, &procmask
, 0);
688 diffout
= fdopen (diff_fds
[0], "r");
690 perror_fatal ("fdopen");
694 lf_init (&diff_filt
, diffout
);
695 lf_init (&lfilt
, left
);
696 lf_init (&rfilt
, right
);
698 interact_ok
= interact (&diff_filt
, &lfilt
, lname
, &rfilt
, rname
, out
);
708 #if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK)
709 wstatus
= pclose (diffout
);
714 while (waitpid (diffpid
, &wstatus
, 0) < 0)
718 perror_fatal ("waitpid");
731 check_child_status (werrno
, wstatus
, EXIT_FAILURE
, diffargv
[0]);
734 exit (WEXITSTATUS (wstatus
));
737 return EXIT_SUCCESS
; /* Fool `-Wall'. */
741 diffarg (char const *a
)
743 static size_t diffargs
, diffarglim
;
745 if (diffargs
== diffarglim
)
749 else if (PTRDIFF_MAX
/ (2 * sizeof *diffargv
) <= diffarglim
)
753 diffargv
= xrealloc (diffargv
, diffarglim
* sizeof *diffargv
);
755 diffargv
[diffargs
++] = a
;
761 /* Signal handling */
763 static bool volatile ignore_SIGINT
;
764 static int volatile signal_received
;
765 static bool sigs_trapped
;
773 if (! (s
== SIGINT
&& ignore_SIGINT
))
778 static struct sigaction catchaction
;
781 signal_handler (int sig
, RETSIGTYPE (*handler
) (int))
783 catchaction
.sa_handler
= handler
;
784 sigaction (sig
, &catchaction
, 0);
794 catchaction
.sa_flags
= SA_RESTART
;
795 sigemptyset (&catchaction
.sa_mask
);
796 for (i
= 0; i
< NUM_SIGS
; i
++)
797 sigaddset (&catchaction
.sa_mask
, sigs
[i
]);
800 for (i
= 0; i
< NUM_SIGS
; i
++)
803 sigaction (sigs
[i
], 0, &initial_action
[i
]);
805 initial_action
[i
] = signal (sigs
[i
], SIG_IGN
);
807 if (initial_handler (i
) != SIG_IGN
)
808 signal_handler (sigs
[i
], catchsig
);
812 /* System V fork+wait does not work if SIGCHLD is ignored. */
813 signal (SIGCHLD
, SIG_DFL
);
819 /* Untrap signal S, or all trapped signals if S is zero. */
826 for (i
= 0; i
< NUM_SIGS
; i
++)
827 if ((! s
|| sigs
[i
] == s
) && initial_handler (i
) != SIG_IGN
)
829 sigaction (sigs
[i
], &initial_action
[i
], 0);
831 signal (sigs
[i
], initial_action
[i
]);
835 /* Exit if a signal has been received. */
839 int s
= signal_received
;
844 /* Yield an exit status indicating that a signal was received. */
848 /* That didn't work, so exit with error status. */
857 fprintf (stderr
, "%s", _("\
858 ed:\tEdit then use both versions, each decorated with a header.\n\
859 eb:\tEdit then use both versions.\n\
860 el:\tEdit then use the left version.\n\
861 er:\tEdit then use the right version.\n\
862 e:\tEdit a new version.\n\
863 l:\tUse the left version.\n\
864 r:\tUse the right version.\n\
865 s:\tSilently include common lines.\n\
866 v:\tVerbosely include common lines.\n\
878 if (! ISSPACE (c
) || c
== '\n')
883 perror_fatal (_("read failed"));
891 while ((c
= getchar ()) != '\n' && c
!= EOF
)
894 perror_fatal (_("read failed"));
898 /* interpret an edit command */
900 edit (struct line_filter
*left
, char const *lname
, lin lline
, lin llen
,
901 struct line_filter
*right
, char const *rname
, lin rline
, lin rlen
,
909 cmd1
= 0; /* Pacify `gcc -W'. */
913 if (putchar ('%') != '%')
914 perror_fatal (_("write failed"));
917 cmd0
= skip_white ();
920 case 'l': case 'r': case 's': case 'v': case 'q':
921 if (skip_white () != '\n')
931 cmd1
= skip_white ();
934 case 'b': case 'd': case 'l': case 'r':
935 if (skip_white () != '\n')
973 lf_copy (left
, llen
, outfile
);
974 lf_skip (right
, rlen
);
977 lf_copy (right
, rlen
, outfile
);
978 lf_skip (left
, llen
);
981 suppress_common_lines
= 1;
984 suppress_common_lines
= 0;
993 tmp
= fopen (tmpname
, "w");
996 if ((fd
= temporary_file ()) < 0)
997 perror_fatal ("mkstemp");
998 tmp
= fdopen (fd
, "w");
1002 perror_fatal (tmpname
);
1010 fprintf (tmp
, "--- %s %ld\n", lname
, (long) lline
);
1012 fprintf (tmp
, "--- %s %ld,%ld\n", lname
,
1013 (long) lline
, (long) (lline
+ llen
- 1));
1017 lf_copy (left
, llen
, tmp
);
1021 lf_skip (left
, llen
);
1031 fprintf (tmp
, "+++ %s %ld\n", rname
, (long) rline
);
1033 fprintf (tmp
, "+++ %s %ld,%ld\n", rname
,
1034 (long) rline
, (long) (rline
+ rlen
- 1));
1038 lf_copy (right
, rlen
, tmp
);
1042 lf_skip (right
, rlen
);
1055 #if ! (HAVE_WORKING_FORK || HAVE_WORKING_VFORK)
1057 xmalloc (quote_system_arg (0, editor_program
)
1058 + 1 + strlen (tmpname
) + 1);
1059 sprintf (command
+ quote_system_arg (command
, editor_program
),
1061 wstatus
= system (command
);
1071 char const *argv
[3];
1074 argv
[i
++] = editor_program
;
1075 argv
[i
++] = tmpname
;
1078 execvp (editor_program
, (char **) argv
);
1079 _exit (errno
== ENOEXEC
? 126 : 127);
1083 perror_fatal ("fork");
1085 while (waitpid (pid
, &wstatus
, 0) < 0)
1089 perror_fatal ("waitpid");
1094 check_child_status (werrno
, wstatus
, EXIT_SUCCESS
,
1099 char buf
[SDIFF_BUFSIZE
];
1101 tmp
= ck_fopen (tmpname
, "r");
1102 while ((size
= ck_fread (buf
, SDIFF_BUFSIZE
, tmp
)) != 0)
1105 ck_fwrite (buf
, size
, outfile
);
1120 /* Alternately reveal bursts of diff output and handle user commands. */
1122 interact (struct line_filter
*diff
,
1123 struct line_filter
*left
, char const *lname
,
1124 struct line_filter
*right
, char const *rname
,
1127 lin lline
= 1, rline
= 1;
1131 char diff_help
[256];
1132 int snarfed
= lf_snarf (diff
, diff_help
, sizeof diff_help
);
1135 return snarfed
!= 0;
1139 if (diff_help
[0] == ' ')
1140 puts (diff_help
+ 1);
1145 lin llen
, rlen
, lenmax
;
1147 llen
= val
= strtoumax (diff_help
+ 1, &numend
, 10);
1148 if (llen
< 0 || llen
!= val
|| errno
|| *numend
!= ',')
1150 rlen
= val
= strtoumax (numend
+ 1, &numend
, 10);
1151 if (rlen
< 0 || rlen
!= val
|| errno
|| *numend
)
1154 lenmax
= MAX (llen
, rlen
);
1156 switch (diff_help
[0])
1159 if (suppress_common_lines
)
1160 lf_skip (diff
, lenmax
);
1162 lf_copy (diff
, lenmax
, stdout
);
1164 lf_copy (left
, llen
, outfile
);
1165 lf_skip (right
, rlen
);
1169 lf_copy (diff
, lenmax
, stdout
);
1170 if (! edit (left
, lname
, lline
, llen
,
1171 right
, rname
, rline
, rlen
,
1186 /* Return nonzero if DIR is an existing directory. */
1188 diraccess (char const *dir
)
1191 return stat (dir
, &buf
) == 0 && S_ISDIR (buf
.st_mode
);
1195 # define P_tmpdir "/tmp"
1198 # define TMPDIR_ENV "TMPDIR"
1201 /* Open a temporary file and return its file descriptor. Put into
1202 tmpname the address of a newly allocated buffer that holds the
1203 file's name. Use the prefix "sdiff". */
1205 temporary_file (void)
1207 char const *tmpdir
= getenv (TMPDIR_ENV
);
1208 char const *dir
= tmpdir
? tmpdir
: P_tmpdir
;
1209 char *buf
= xmalloc (strlen (dir
) + 1 + 5 + 6 + 1);
1214 sprintf (buf
, "%s/sdiffXXXXXX", dir
);
1215 sigemptyset (&blocked
);
1216 sigaddset (&blocked
, SIGINT
);
1217 sigprocmask (SIG_BLOCK
, &blocked
, &procmask
);
1222 sigprocmask (SIG_SETMASK
, &procmask
, 0);