--- Diff22:ifdef.c Wed Sep 30 03:21:58 1992 +++ ifdef.c Sun Apr 04 19:39:37 1993 @@ -21,10 +21,16 @@ #include "diff.h" +#ifdef KULTUR +static void print_ifdef_hunk (struct change *hunk); +static void format_ifdef (const char *format, int beg0, int end0, int beg1, int end1); +static void print_ifdef_lines (const char *format, const struct file_data *current, int from, int upto); +#else static void format_ifdef (); static void print_ifdef_hunk (); static void print_ifdef_lines (); struct change *find_change (); +#endif static int next_line; --- Diff22:getopt1.c Sun Jan 17 18:51:30 1993 +++ getopt1.c Sun Apr 04 20:34:29 1993 @@ -21,9 +21,11 @@ #include "getopt.h" +#ifndef __SASC_60 #if !__STDC__ && !defined(const) && IN_GCC #define const #endif +#endif #include --- Diff22:getopt.c Sun Jan 17 18:50:26 1993 +++ getopt.c Sun Apr 04 20:33:18 1993 @@ -42,9 +42,11 @@ #endif /* alloca.h */ #endif /* not __GNUC__ */ +#ifndef __SASC_60 #if !__STDC__ && !defined(const) && IN_GCC #define const #endif +#endif #include @@ -150,6 +152,16 @@ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; +#ifdef KULTUR +#include +#include +#define my_index strchr +#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) + +static void exchange (char **); +int getopt (int, char *const *, const char *); +#else + #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. @@ -189,6 +201,7 @@ to[i] = from[i]; } #endif /* GNU C library. */ +#endif /* Handle permutation of arguments. */ @@ -213,7 +226,11 @@ char **argv; { int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); +#ifdef KULTUR + char **temp = (char **) malloc (nonopts_size); +#else char **temp = (char **) __alloca (nonopts_size); +#endif /* Interchange the two blocks of data in ARGV. */ @@ -228,6 +245,9 @@ first_nonopt += (optind - last_nonopt); last_nonopt = optind; +#ifdef KULTUR + free (temp); +#endif } /* Scan elements of ARGV (whose length is ARGC) for option characters --- Diff22:error.c Sat Jul 18 12:23:10 1992 +++ error.c Sun Apr 04 19:39:29 1993 @@ -19,6 +19,10 @@ #include +#ifdef KULTUR +void error (int status, int errnum, char *message, ...); +#endif + #ifdef HAVE_VPRINTF #if __STDC__ --- Diff22:ed.c Sat Sep 05 22:35:52 1992 +++ ed.c Sun Apr 04 19:39:26 1993 @@ -19,6 +19,11 @@ #include "diff.h" +#ifdef KULTUR +static void print_ed_hunk (struct change *); +static void print_rcs_hunk (struct change *); +static void pr_forward_ed_hunk (struct change *); +#else int change_letter (); int translate_line_number (); static void print_rcs_hunk (); @@ -27,6 +32,7 @@ void translate_range (); struct change *find_change (); struct change *find_reverse_change (); +#endif /* Print our script as ed commands. */ --- Diff22:dir.c Thu Feb 11 02:36:08 1993 +++ dir.c Sun Apr 04 19:39:23 1993 @@ -19,8 +19,6 @@ #include "diff.h" -static int compare_names (); - /* Read the directory named by DIR and store into DIRDATA a sorted vector of filenames for its contents. DIR->desc == -1 means this directory is known to be nonexistent, so set DIRDATA to an empty vector. @@ -32,6 +30,13 @@ char *data; /* Allocated storage for file names. */ }; +#ifdef KULTUR +static int compare_names (char **file1, char **file2); +static int dir_sort (struct file_data *dir, struct dirdata *dirdata); +#else +static int compare_names (); +#endif + static int dir_sort (dir, dirdata) struct file_data *dir; @@ -152,7 +157,11 @@ int diff_dirs (filevec, handle_file, depth) struct file_data filevec[]; +#ifdef KULTUR + int (*handle_file) (char *, char *, char *, char *, int); +#else int (*handle_file) (); +#endif int depth; { struct dirdata dirdata[2]; --- Diff22:diff3.c Thu Feb 11 12:48:30 1993 +++ diff3.c Sun Apr 04 20:34:18 1993 @@ -28,6 +28,22 @@ #include "getopt.h" #include "system.h" +#ifdef AMIGA +#include +#ifdef KULTUR +#pragma msg 149 ignore push +#endif +#include +#include +#include +#include +#ifdef KULTUR +#pragma msg 149 pop +#endif + +extern struct DosLibrary *DOSBase; +#endif /* AMIGA */ + /* * Internal data structures and macros for the diff3 program; includes * data structures for both diff3 diffs and normal diffs. @@ -176,6 +192,30 @@ /* * Forward function declarations. */ +#ifdef KULTUR +static void usage (void); +static struct diff3_block *make_3way_diff (struct diff_block *, struct diff_block *); +static struct diff3_block *using_to_diff3_block (struct diff_block *[2], struct diff_block *[2], int, int, struct diff3_block *); +static int copy_stringlist (char *[], int *, char *[], int *, int); +static struct diff3_block *create_diff3_block (int, int, int, int, int, int); +static int compare_line_list (char *[], int *, char *[], int *, int); +static struct diff_block *process_diff (char *, char *); +static enum diff_type process_diff_control (char **, struct diff_block *); +static char *read_diff (char *, char *, char **); +static char *scan_diff_line (char *, char **, int *, char *, char); +static void output_diff3 (FILE *, struct diff3_block *, int [3], int [3]); +static int dotlines (FILE *, struct diff3_block *b, int); +static void undotlines (FILE *, int, int, int); +static int output_diff3_edscript (FILE *, struct diff3_block *, int [3], int [3], char *, char *, char *); +static int output_diff3_merge (FILE *, FILE *, struct diff3_block *, int [3], int [3], char *, char *, char *); +static struct diff3_block *reverse_diff3_blocklist (struct diff3_block *); +static int myread (int fd, char *ptr, int size); +static void fatal (char *); +static void perror_with_exit (char *); +VOID *xmalloc (unsigned); +static VOID *xrealloc (VOID *, unsigned); +#define DIFF_PROGRAM "diff" +#else static int myread (); static void fatal (); static void perror_with_exit (); @@ -197,8 +237,12 @@ static struct diff3_block *reverse_diff3_blocklist (); +#ifndef KULTUR VOID *xmalloc (); static VOID *xrealloc (); +#endif + +#endif static char diff_program[] = DIFF_PROGRAM; @@ -240,6 +284,13 @@ char **file; struct stat statb; +#ifdef AMIGA + if (DOSBase->dl_lib.lib_Version < 37) { + fputs ("Need Amiga OS 2.0 (V.37) to execute.\n", stderr); + exit (20); + } +#endif /* AMIGA */ + incompat = 0; argv0 = argv[0]; @@ -596,7 +647,9 @@ if (high_water_mark < D_HIGHLINE (other_diff, FC)) { high_water_thread ^= 1; +#ifndef KULTUR high_water_diff = other_diff; +#endif high_water_mark = D_HIGHLINE (other_diff, FC); } @@ -1089,6 +1142,8 @@ char *filea, *fileb; char **output_placement; { +#ifndef AMIGA + char *argv[6]; char **ap; int fds[2]; @@ -1132,6 +1187,86 @@ perror_with_exit ("fork failed"); close (fds[1]); /* Prevent erroneous lack of EOF */ + +#else /* AMIGA */ + + static char diff_command_line[200]; + int fds[2]; + char *diff_result; + int current_chunk_size; + int bytes; + int total; + void (*oldsigint)(); + static long num_invocations = 0; + char pipe_name[20]; + struct Task *Task; + struct TagItem STags[5]; + BPTR StdOutDiff; + + /* The user should not be able to break the program while the child + process is being executed, otherwise the child process will still + be writing to the pipe-device until it deadlocks because there is + no reader on the other side of the pipe. So prohibit breaking the + program until the pipe is closed. */ + oldsigint = signal (SIGINT, SIG_IGN); + + /* Construct command line. Enclose filenames in double quotes in + case the user specifies files with spaces in their names. */ + strcpy (diff_command_line, diff_program); + if (always_text) + strcat (diff_command_line, " -a"); + strcat (diff_command_line, " --"); + strcat (diff_command_line, " \""); + strcat (diff_command_line, filea); + strcat (diff_command_line, "\" \""); + strcat (diff_command_line, fileb); + strcat (diff_command_line, "\""); + + /* Construct filename for the pipe to be used */ + Task = FindTask (NULL); + num_invocations++; + sprintf (pipe_name, "PIPE:%08lX_%ld", Task, num_invocations); + + /* Open pipe for child process */ + StdOutDiff = Open (pipe_name, MODE_NEWFILE); + if (!StdOutDiff) + perror_with_exit ("pipe failed"); + + /* Child process runs asynchronously with pipe as stdout */ +#ifdef KULTUR + STags[0].ti_Tag = (Tag) SYS_Input; + STags[0].ti_Data = NULL; + STags[1].ti_Tag = (Tag) SYS_Output; + STags[1].ti_Data = StdOutDiff; + STags[2].ti_Tag = (Tag) SYS_Asynch; + STags[2].ti_Data = TRUE; + STags[3].ti_Tag = (Tag) SYS_UserShell; +#else + STags[0].ti_Tag = SYS_Input; + STags[0].ti_Data = NULL; + STags[1].ti_Tag = SYS_Output; + STags[1].ti_Data = StdOutDiff; + STags[2].ti_Tag = SYS_Asynch; + STags[2].ti_Data = TRUE; + STags[3].ti_Tag = SYS_UserShell; +#endif + STags[3].ti_Data = TRUE; + STags[4].ti_Tag = TAG_DONE; + /* Start child process */ + if ((System (diff_command_line, STags)) != 0) { + Close (StdOutDiff); + perror_with_exit ("diff: not found"); + } + + /* Open pipe for this side of the communication */ + fds[0] = open (pipe_name, O_RDONLY); + if (fds[0] < 0) { + Close (StdOutDiff); + perror_with_exit ("pipe failed"); + } + +#endif /* !AMIGA */ + current_chunk_size = DIFF_CHUNK_SIZE; diff_result = (char *) xmalloc (current_chunk_size); total = 0; @@ -1149,6 +1284,7 @@ *output_placement = diff_result; +#ifndef AMIGA do if ((w = wait (&wstatus)) == -1) perror_with_exit ("wait failed"); @@ -1156,6 +1292,12 @@ if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2)) fatal ("subsidiary diff failed"); +#else /* AMIGA */ + /* Close pipe */ + close (fds[0]); + /* Re-install break-handler */ + signal (SIGINT, oldsigint); +#endif /* !AMIGA */ return diff_result + total; } @@ -1168,12 +1310,16 @@ * This next routine began life as a macro and many parameters in it * are used as call-by-reference values. */ +#ifdef KULTUR +static char *scan_diff_line (char *scan_ptr, char **set_start, int *set_length, char *limit, char firstchar) +#else static char * scan_diff_line (scan_ptr, set_start, set_length, limit, firstchar) char *scan_ptr, **set_start; int *set_length; char *limit; char firstchar; +#endif { char *line_ptr; @@ -1638,7 +1784,11 @@ return result; } +#ifndef AMIGA +static VOID * +#else /* AMIGA */ VOID * +#endif /* !AMIGA */ xmalloc (size) unsigned size; { --- Diff22:diff.c Wed Nov 18 10:17:00 1992 +++ diff.c Sun Apr 04 19:39:11 1993 @@ -33,6 +33,18 @@ #define GUTTER_WIDTH_MINIMUM 3 #endif +#ifdef KULTUR +static char *option_list (char **, int); +static int add_exclude_file (void); +static int ck_atoi (char *, int *); +static int compare_files (char *, char *, char *, char *, int); +static int fake_stat_result (struct stat *); +static int specify_format (const char **, const char *); +static void add_exclude (const char *); +static void add_regexp (struct regexp_list **, char *); +static void specify_style (enum output_style); +static void usage (void); +#else int diff_dirs (); int diff_2_files (); @@ -41,6 +53,10 @@ static void add_regexp(); static void specify_style (); static void usage (); +#ifdef AMIGA +static int fake_stat_result (); +#endif /* AMIGA */ +#endif /* Nonzero for -r: if comparing two directories, compare their common subdirectories recursively. */ @@ -123,14 +139,18 @@ exclude = (const char **) (exclude_alloc == 0 ? xmalloc ((exclude_alloc = 64) * sizeof (*exclude)) - : xrealloc (exclude, (exclude_alloc *= 2) * sizeof (*exclude))); + : xrealloc ((VOID *)exclude, (exclude_alloc *= 2) * sizeof (*exclude))); exclude[exclude_count++] = pattern; } static int +#ifdef KULTUR +add_exclude_file (void) +#else add_exclude_file (name) const char *name; +#endif { struct file_data f; char *p, *q, *lim; @@ -477,7 +497,11 @@ break; case 'X': +#ifdef KULTUR + if (add_exclude_file () != 0) +#else if (add_exclude_file (optarg) != 0) +#endif pfatal_with_name (optarg); break; @@ -579,8 +603,8 @@ if (!group_format[UNCHANGED]) group_format[UNCHANGED] = "%="; if (!group_format[CHANGED]) - group_format[CHANGED] = concat (group_format[OLD], - group_format[NEW], ""); + group_format[CHANGED] = concat ((char *) group_format[OLD], + (char *) group_format[NEW], ""); } no_diff_means_no_output = @@ -618,7 +642,7 @@ r->buf.fastmap = (char *) xmalloc (256); m = re_compile_pattern (pattern, strlen (pattern), &r->buf); if (m != 0) - error ("%s: %s", pattern, m); + error ("%s: %s", pattern, (char *) m); /* Add to the start of the list, since it's easier than the end. */ r->next = *reglist; @@ -918,3 +942,22 @@ return val; } + +#ifdef AMIGA +static int fake_stat_result (sbuf) + struct stat *sbuf; +{ + time_t cur_time; + + time (&cur_time); + sbuf->st_dev = 0; + sbuf->st_ino = 0; + sbuf->st_mode = S_IREAD; + sbuf->st_nlink = 1; + sbuf->st_uid = 0; + sbuf->st_gid = 0; + sbuf->st_size = 0; + sbuf->st_ctime = sbuf->st_atime = sbuf->st_mtime = cur_time; + return 0; +} +#endif /* AMIGA */ --- Diff22:context.c Sun Oct 18 22:33:04 1992 +++ context.c Sun Apr 04 19:38:59 1993 @@ -19,11 +19,22 @@ #include "diff.h" +#ifdef KULTUR +static struct change *find_hunk (struct change *); +static void find_function (struct file_data *, int, const char **, int *); +static void mark_ignorable (struct change *); +static void print_context_label (const char *, struct file_data *, const char *); +static void print_context_number_range (struct file_data *, int, int); +static void print_unidiff_number_range (struct file_data *, int, int); +static void pr_context_hunk (struct change *); +static void pr_unidiff_hunk (struct change *); +#else static void pr_context_hunk (); static void pr_unidiff_hunk (); static struct change *find_hunk (); static void mark_ignorable (); static void find_function (); +#endif /* Last place find_function started searching from. */ static int find_function_last_search; --- Diff22:cmp.c Wed Jul 08 13:58:06 1992 +++ cmp.c Sun Apr 04 19:38:53 1993 @@ -21,6 +21,19 @@ #include "system.h" #include "getopt.h" +#ifdef KULTUR +extern void *xmalloc (unsigned); +extern void error (int, int, char *, ...); +static int block_compare_and_count (int *count, char *p1, char *p2, unsigned char c); +static int block_compare (char *p1, char *p2); +static int block_read (int fd, char *buf, int nchars); +static void printc (FILE *fs, int width, unsigned c); +static void usage (char *reason); +static int cmp (void); +#ifdef AMIGA +static void fake_stat_result (struct stat *sbuf); +#endif +#else char *xmalloc (); int block_compare (); int block_compare_and_count (); @@ -28,6 +41,10 @@ int cmp (); void printc (); void error (); +#ifdef AMIGA +void fake_stat_result (); +#endif /* AMIGA */ +#endif /* Name under which this program was invoked. */ char *program_name; @@ -71,7 +88,7 @@ {NULL, 0, NULL, 0} }; -void +static void usage (reason) char *reason; { @@ -235,7 +252,7 @@ using `buf1' and `buf2'. Return 0 if identical, 1 if different, >1 if error. */ -int +static int cmp () { long line_number = 1; /* Line number (1...) of first difference. */ @@ -368,11 +385,15 @@ Return the offset of the first byte that differs. Place the count at the address pointed to by COUNT. */ -int +static int +#ifdef KULTUR +block_compare_and_count (int *count, char *p1, char *p2, unsigned char c) +#else block_compare_and_count (count, p1, p2, c) int *count; char *p1, *p2; unsigned char c; +#endif { long w; /* Word for counting C. */ long i1, i2; /* One word from each buffer to compare. */ @@ -430,7 +451,7 @@ Return the offset of the first byte that differs. */ -int +static int block_compare (p1, p2) char *p1, *p2; { @@ -454,7 +475,7 @@ /* Read NCHARS bytes from descriptor FD into BUF. Return the number of characters successfully read. */ -int +static int block_read (fd, buf, nchars) int fd; char *buf; @@ -480,7 +501,7 @@ visible by quoting like cat -t does. Pad with spaces on the right to WIDTH characters. */ -void +static void printc (fs, width, c) FILE *fs; int width; @@ -510,3 +531,21 @@ while (--width > 0) putc (' ', fs); } + +#ifdef AMIGA +static void fake_stat_result (sbuf) + struct stat *sbuf; +{ + time_t cur_time; + + time (&cur_time); + sbuf->st_dev = 0; + sbuf->st_ino = 0; + sbuf->st_mode = S_IREAD; + sbuf->st_nlink = 1; + sbuf->st_uid = 0; + sbuf->st_gid = 0; + sbuf->st_size = 0; + sbuf->st_ctime = sbuf->st_atime = sbuf->st_mtime = cur_time; +} +#endif /* AMIGA */ --- Diff22:regex.c Wed Jan 06 19:47:10 1993 +++ regex.c Sun Apr 04 19:40:56 1993 @@ -90,6 +90,10 @@ static char re_syntax_table[CHAR_SET_SIZE]; +#ifdef KULTUR +static void init_syntax_once (void); +#endif + static void init_syntax_once () { @@ -124,6 +128,62 @@ /* Get the interface, including the syntax bits. */ #include "regex.h" +#ifdef KULTUR +#define register +void *alloca (unsigned); +#define MATCH_NULL_UNSET_VALUE 3 +typedef unsigned regnum_t; +typedef const unsigned char *fail_stack_elt_t; +typedef union { fail_stack_elt_t word; struct { unsigned match_null_string_p : +2; unsigned is_active : 1; unsigned matched_something : 1; unsigned +ever_matched_something : 1; } bits; } register_info_type; +typedef int pattern_offset_t; +typedef struct { pattern_offset_t begalt_offset; pattern_offset_t +fixup_alt_jump; pattern_offset_t inner_group_offset; pattern_offset_t +laststart_offset; regnum_t regnum; } compile_stack_elt_t; +typedef struct { compile_stack_elt_t *stack; unsigned size; unsigned avail; } +compile_stack_type; +typedef enum { no_op = 0, exactn = 1, anychar, charset, charset_not, +start_memory, stop_memory, duplicate, begline, endline, begbuf, endbuf, jump, +jump_past_alt, on_failure_jump, on_failure_keep_string_jump, pop_failure_jump, +maybe_pop_jump, dummy_failure_jump, push_dummy_failure, succeed_n, jump_n, +set_number_at, wordchar, notwordchar, wordbeg, wordend, wordbound, notwordbound +} re_opcode_t; +typedef char boolean; +static void init_syntax_once (void); +void print_fastmap (char *); +void print_partial_compiled_pattern (unsigned char *, unsigned char *); +void print_compiled_pattern (struct re_pattern_buffer *); +void print_double_string (const char *, const char *, const char *, int, int); +reg_syntax_t re_set_syntax (reg_syntax_t); +static reg_errcode_t regex_compile (const char *, int, reg_syntax_t, struct re_pattern_buffer *); +static void store_op1 (re_opcode_t, unsigned char *, int); +static void store_op2 (re_opcode_t, unsigned char *, int, int); +static void insert_op1 (re_opcode_t, unsigned char *, int, unsigned char *); +static void insert_op2 (re_opcode_t, unsigned char *, int, int, unsigned char *); +static boolean at_begline_loc_p (const char *, const char *, reg_syntax_t); +static boolean at_endline_loc_p (const char *, const char *, int); +static boolean group_in_compile_stack (compile_stack_type, regnum_t); +static reg_errcode_t compile_range (const char **, const char *, char *, reg_syntax_t, unsigned char *); +int re_compile_fastmap (struct re_pattern_buffer *); +void re_set_registers (struct re_pattern_buffer *, struct re_registers *, unsigned, regoff_t *, regoff_t *); +int re_search (struct re_pattern_buffer *, const char *, int, int, int, struct re_registers *); +int re_search_2 (struct re_pattern_buffer *, const char *, int, const char *, int, int, int, struct re_registers *, int); +int re_match (struct re_pattern_buffer *, const char *, int, int, struct re_registers *); +int re_match_2 (struct re_pattern_buffer *, const char *, int, const char *, int, int, struct re_registers *, int); +static boolean group_match_null_string_p (unsigned char **, unsigned char *, register_info_type *); +static boolean alt_match_null_string_p (unsigned char *, unsigned char *, register_info_type *); +static boolean common_op_match_null_string_p (unsigned char **, unsigned char *, register_info_type *); +static int bcmp_translate (unsigned char *, unsigned char *, int, char *); +const char *re_compile_pattern (const char *, int, struct re_pattern_buffer *); +char *re_comp (const char *); +int re_exec (const char *); +int regcomp (regex_t *, const char *, int); +int regexec (const regex_t *, const char *, size_t, regmatch_t [], int); +/* size_t regerror (int, const regex_t *, char *, size_t); */ +void regfree (regex_t *); +#endif + /* isalpha etc. are used for the character classes. */ #include @@ -197,7 +257,11 @@ #include #else /* not __GNUC__ or HAVE_ALLOCA_H */ #ifndef _AIX /* Already did AIX, up at the top. */ +#ifdef KULTUR +void *alloca (unsigned); +#else char *alloca (); +#endif #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ @@ -207,10 +271,17 @@ #define REGEX_ALLOCATE alloca /* Assumes a `char *destination' variable. */ +#ifdef KULTUR +#define REGEX_REALLOCATE(source, osize, nsize) \ + (destination = (char *) alloca (nsize), \ + bcopy ((const void *)source, (void *)destination, (size_t) osize), \ + destination) +#else #define REGEX_REALLOCATE(source, osize, nsize) \ (destination = (char *) alloca (nsize), \ bcopy (source, destination, osize), \ destination) +#endif #endif /* not REGEX_MALLOC */ @@ -233,7 +304,9 @@ #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#ifndef KULTUR typedef char boolean; +#endif #define false 0 #define true 1 @@ -246,6 +319,7 @@ So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of `exactn' we use here must also be 1. */ +#ifndef KULTUR typedef enum { no_op = 0, @@ -376,6 +450,7 @@ notsyntaxspec #endif /* emacs */ } re_opcode_t; +#endif /* Common operations on the compiled pattern. */ @@ -839,11 +914,13 @@ /* Subroutine declarations and macros for regex_compile. */ +#ifndef KULTUR static void store_op1 (), store_op2 (); static void insert_op1 (), insert_op2 (); static boolean at_begline_loc_p (), at_endline_loc_p (); static boolean group_in_compile_stack (); static reg_errcode_t compile_range (); +#endif /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant @@ -946,7 +1023,7 @@ bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ + bufp->buffer = (unsigned char *) realloc (bufp->buffer, (size_t) bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ @@ -971,13 +1048,16 @@ /* But patterns can have more than `MAX_REGNUM' registers. We just ignore the excess. */ +#ifndef KULTUR typedef unsigned regnum_t; +#endif /* Macros for the compile stack. */ /* Since offsets can go either forwards or backwards, this type needs to be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ +#ifndef KULTUR typedef int pattern_offset_t; typedef struct @@ -996,7 +1076,7 @@ unsigned size; unsigned avail; /* Offset of next open position. */ } compile_stack_type; - +#endif #define INIT_COMPILE_STACK_SIZE 32 @@ -2126,11 +2206,11 @@ const char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - return + return (boolean)( /* After a subexpression? */ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) /* After an alternative? */ - || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); + || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash))); } @@ -2146,13 +2226,13 @@ boolean next_backslash = *next == '\\'; const char *next_next = p + 1 < pend ? p + 1 : NULL; - return + return (boolean)( /* Before a subexpression? */ (syntax & RE_NO_BK_PARENS ? *next == ')' : next_backslash && next_next && *next_next == ')') /* Before an alternative? */ || (syntax & RE_NO_BK_VBAR ? *next == '|' - : next_backslash && next_next && *next_next == '|'); + : next_backslash && next_next && *next_next == '|')); } @@ -2250,7 +2330,9 @@ change it ourselves. */ int re_max_failures = 2000; +#ifndef KULTUR typedef const unsigned char *fail_stack_elt_t; +#endif typedef struct { @@ -2449,7 +2531,7 @@ Also assumes the variables `fail_stack' and (if debugging), `bufp', `pend', `string1', `size1', `string2', and `size2'. */ -#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ +#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info) \ { \ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ int this_reg; \ @@ -2981,6 +3063,7 @@ /* Declarations and macros for re_match_2. */ +#ifndef KULTUR static int bcmp_translate (); static boolean alt_match_null_string_p (), common_op_match_null_string_p (), @@ -3011,6 +3094,7 @@ unsigned ever_matched_something : 1; } bits; } register_info_type; +#endif #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) #define IS_ACTIVE(R) ((R).bits.is_active) @@ -3822,7 +3906,11 @@ /* Compare that many; failure if mismatch, else move past them. */ if (translate +#ifdef KULTUR + ? bcmp_translate ((unsigned char *) d, (unsigned char *) d2, mcnt, translate) +#else ? bcmp_translate (d, d2, mcnt, translate) +#endif : bcmp (d, d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; @@ -4862,6 +4950,7 @@ /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. We don't use PREG here. */ +#ifdef INCLUDE_ALL_STUPID_FUNCTIONS size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; @@ -4895,7 +4984,7 @@ return msg_size; } - +#endif /* Free dynamically allocated space used by PREG. */ --- Diff22:analyze.c Wed Sep 30 03:21:58 1992 +++ analyze.c Sun Apr 04 19:38:46 1993 @@ -23,6 +23,15 @@ #include "diff.h" +#ifdef KULTUR +static int diag (int, int, int, int, int *); +static struct change *add_change (int, int, int, int, struct change *); +static struct change *build_reverse_script (struct file_data []); +static struct change *build_script (struct file_data []); +static void compareseq (int, int, int, int); +static void discard_confusing_lines (struct file_data []); +static void shift_boundaries (struct file_data []); +#else int read_files (); void finish_output (); void print_context_script (); @@ -33,6 +42,7 @@ void print_rcs_script (); void pr_forward_ed_script (); void setup_output (); +#endif extern int no_discards; @@ -259,12 +269,18 @@ files[0].changed_flag[files[0].realindexes[xoff++]] = 1; else { +#ifdef KULTUR + int c, d, b; +#else int c, d, f, b; +#endif /* Find a point of correspondence in the middle of the files. */ d = diag (xoff, xlim, yoff, ylim, &c); +#ifndef KULTUR f = fdiag[d]; +#endif b = bdiag[d]; if (c == 1) @@ -308,7 +324,7 @@ When we discard a line, we also mark it as a deletion or insertion so that it will be printed in the output. */ -void +static void discard_confusing_lines (filevec) struct file_data filevec[]; { @@ -919,7 +935,11 @@ free (filevec[i].equivs); for (i = 0; i < 2; ++i) +#ifdef KULTUR + free ((VOID *) (filevec[i].linbuf + filevec[i].linbuf_base)); +#else free (filevec[i].linbuf + filevec[i].linbuf_base); +#endif for (e = script; e; e = p) { --- Diff22:alloca.c Tue Dec 01 12:25:52 1992 +++ alloca.c Sun Apr 04 20:33:39 1993 @@ -58,8 +58,15 @@ #define NULL 0 /* null pointer constant */ +#ifdef KULTUR +static void find_stack_direction (void); +pointer alloca (unsigned size); +extern void free (pointer); +extern pointer xmalloc (unsigned); +#else extern void free(); extern pointer xmalloc(); +#endif /* Define STACK_DIRECTION if you know the direction of stack --- Diff22:fnmatch.c Wed Nov 18 13:24:16 1992 +++ fnmatch.c Sun Apr 04 20:32:32 1993 @@ -16,7 +16,11 @@ Cambridge, MA 02139, USA. */ #include +#ifdef __SASC_60 +#include "fnmatch.h" +#else #include +#endif #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) extern int errno; --- Diff22:diff.h Wed Sep 30 03:21:58 1992 +++ diff.h Sun Apr 04 19:39:16 1993 @@ -306,6 +306,10 @@ #else #define VOID char #endif + +#ifdef KULTUR +#include "Diff_Protos.h" +#else VOID *xmalloc (); VOID *xrealloc (); char *concat (); @@ -330,3 +334,4 @@ void print_script (); void slurp (); void translate_range (); +#endif --- Diff22:xmalloc.c Sat Jul 18 12:27:22 1992 +++ xmalloc.c Sun Apr 04 19:41:26 1993 @@ -23,11 +23,21 @@ void free (); #endif +#ifdef KULTUR +void error (int, int, char *, ...); +void *xmalloc (unsigned n); +void *xrealloc (void *p, unsigned n); +#else void error (); +#endif /* Allocate N bytes of memory dynamically, with error checking. */ +#ifdef KULTUR +void * +#else char * +#endif xmalloc (n) unsigned n; { @@ -45,10 +55,14 @@ If P is NULL, run xmalloc. If N is 0, run free and return NULL. */ +#ifdef KULTUR +void *xrealloc (void *p, unsigned n) +#else char * xrealloc (p, n) char *p; unsigned n; +#endif { if (p == 0) return xmalloc (n); --- Diff22:util.c Thu Nov 12 10:02:18 1992 +++ util.c Sun Apr 04 19:41:22 1993 @@ -19,6 +19,27 @@ #include "diff.h" +#ifdef KULTUR +static void debug_script (struct change *sp); +#endif + +#ifdef AMIGA +#include +#ifdef KULTUR +#pragma msg 149 ignore push +#endif +#include +#include +#include +#include +#ifdef KULTUR +#pragma msg 149 pop +#endif + +extern struct DosLibrary *DOSBase; +static char tmpfilename[L_tmpnam]; +#endif /* AMIGA */ + /* Use when a system call returns non-zero status. TEXT should normally be the file name. */ @@ -154,6 +175,7 @@ strcat (name, current_name1); if (paginate_flag) +#ifndef AMIGA { int pipes[2]; int desc; @@ -187,6 +209,26 @@ outfile = fdopen (pipes[1], "w"); } } +#else /* AMIGA */ + { + if (DOSBase->dl_lib.lib_Version < 37) + { + fputs ("Need Amiga OS 2.0 (V.37) to paginate. ", stderr); + fputs ("Using stdout instead.\n", stderr); + outfile = stdout; + } + else + { + /* Output the differences to a file and process the file with + * pr later on. This is a really bad hack (a kluge??? :-) ), + * but I couldn't find something better... */ + tmpnam (tmpfilename); + outfile = fopen (tmpfilename, "w"); + if (outfile == NULL) + pfatal_with_name ("pipe"); + } + } +#endif else { @@ -225,10 +267,64 @@ finish_output () { if (outfile != 0 && outfile != stdout) +#ifndef AMIGA { fclose (outfile); wait (0); } +#else /* AMIGA */ + { + char *command_line; + struct TagItem STags[5]; + BPTR StdInPr; + + /* Close the temporary file and run pr with this file as input */ + fclose (outfile); + command_line = (char *) xmalloc (strlen (current_name0) + + strlen (current_name1) + + strlen (switch_string) + 30); + strcpy (command_line, "pr -f -h \""); + strcat (command_line, "diff"); + strcat (command_line, switch_string); + strcat (command_line, " "); + strcat (command_line, current_name0); + strcat (command_line, " "); + strcat (command_line, current_name1); + strcat (command_line, "\""); + StdInPr = Open (tmpfilename, MODE_OLDFILE); + if (StdInPr == NULL) + pfatal_with_name ("pipe"); +#ifdef KULTUR + STags[0].ti_Tag = (Tag) SYS_Input; + STags[0].ti_Data = StdInPr; + STags[1].ti_Tag = (Tag) SYS_Output; + STags[1].ti_Data = Output (); + STags[2].ti_Tag = (Tag) SYS_Asynch; + STags[2].ti_Data = FALSE; + STags[3].ti_Tag = (Tag) SYS_UserShell; + STags[3].ti_Data = TRUE; + STags[4].ti_Tag = TAG_DONE; +#else + STags[0].ti_Tag = SYS_Input; + STags[0].ti_Data = StdInPr; + STags[1].ti_Tag = SYS_Output; + STags[1].ti_Data = Output (); + STags[2].ti_Tag = SYS_Asynch; + STags[2].ti_Data = FALSE; + STags[3].ti_Tag = SYS_UserShell; + STags[3].ti_Data = TRUE; + STags[4].ti_Tag = TAG_DONE; +#endif + if (System (command_line, STags) != 0) + { + Close (StdInPr); + DeleteFile (tmpfilename); + pfatal_with_name ("pr"); + } + Close (StdInPr); + DeleteFile (tmpfilename); + } +#endif /* !AMIGA */ outfile = 0; } @@ -364,8 +460,13 @@ void print_script (script, hunkfun, printfun) struct change *script; +#ifdef KULTUR + struct change * (*hunkfun) (struct change *); + void (*printfun) (struct change *); +#else struct change * (*hunkfun) (); void (*printfun) (); +#endif { struct change *next = script; @@ -480,7 +581,11 @@ } } +#ifdef KULTUR +char +#else int +#endif change_letter (inserts, deletes) int inserts, deletes; { @@ -523,11 +628,16 @@ Args A and B are internal line numbers. We print the translated (real) line numbers. */ +#ifdef KULTUR +void +print_number_range (char sepchar, struct file_data *file, int a, int b) +#else void print_number_range (sepchar, file, a, b) char sepchar; struct file_data *file; int a, b; +#endif { int trans_a, trans_b; translate_range (file, a, b, &trans_a, &trans_b); @@ -676,7 +786,7 @@ return new; } -void +static void debug_script (sp) struct change *sp; { --- Diff22:side.c Sat Jan 30 20:49:14 1993 +++ side.c Sun Apr 04 19:41:09 1993 @@ -18,13 +18,19 @@ file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ - #include "diff.h" - +#ifdef KULTUR +static unsigned tab_from_to (unsigned from, unsigned to); +static unsigned print_half_line (const char * const *line, unsigned indent, unsigned out_bound); +static void print_1sdiff_line (const char * const *left, int sep, const char * const *right); +static void print_sdiff_common_lines (int limit0, int limit1); +static void print_sdiff_hunk (struct change *hunk); +#else static void print_sdiff_hunk (); static void print_sdiff_common_lines (); static void print_1sdiff_line (); +#endif /* Next line number to be printed in the two input files. */ static int next0, next1; --- Diff22:sdiff.c Thu Feb 11 02:39:42 1993 +++ sdiff.c Sun Apr 04 20:34:58 1993 @@ -25,10 +25,30 @@ #include #include "getopt.h" +#ifdef AMIGA +#ifdef KULTUR +#pragma msg 149 ignore push +#endif +#include +#include +#include +#include +#ifdef KULTUR +#pragma msg 149 pop +#endif + +extern struct DosLibrary *DOSBase; +#endif /* AMIGA */ + #ifndef SEEK_SET #define SEEK_SET 0 #endif +#ifdef KULTUR +#define DIFF_PROGRAM "diff" +#define DEFAULT_EDITOR "ed -sticky" +#endif + /* Size of chunks read from files which must be parsed into lines. */ #define SDIFF_BUFSIZE 65536 @@ -49,8 +69,56 @@ static char *tmpname; static int volatile tmpmade; +#ifndef AMIGA static pid_t volatile diffpid; +#endif /* !AMIGA */ + +#ifdef KULTUR +#include +extern int onbreak(int (*)(void)); +extern FILE *fdopen(int, const char *); +struct line_filter { + FILE *infile; + char *bufpos; + char *buffer; + char *buflim; +}; +char *xmalloc (unsigned); +static char command_line[512]; +static FILE *diff_file = NULL; +static int user_quit = 0; +static char const *expand_name (char *, int, char const *); +static FILE *ck_fdopen (int, char *); +static FILE *ck_fopen (char *, char *); +static int amiga_break (void); +static int diraccess (const char *); +static int edit (struct line_filter *, int, struct line_filter *, int, FILE *); +static int exists (const char *); +static int interact (struct line_filter *, struct line_filter *, struct line_filter *, FILE *); +static int lf_snarf (struct line_filter *, char *, size_t); +static int skip_white (void); +static size_t ck_fread (char *, size_t, FILE *); +static size_t lf_refill (struct line_filter *); +static void amiga_exit (void); +static void ck_fclose (FILE *); +static void ck_fflush (FILE *); +static void ck_fwrite (char *, size_t, FILE *); +static void cleanup (void); +static void construct_command_line (char *, char **, char *); +static void construct_pipe_name (char *); +static void diffarg (char *); +static void execdiff (int, char *, char *, char *, long, BPTR); +static void exiterr (void); +static void fatal (char *); +static void flush_line (void); +static void give_help (void); +static void lf_copy (struct line_filter *, int, FILE *); +static void lf_init (struct line_filter *, FILE *); +static void lf_skip (struct line_filter *, int); +static void perror_fatal (char *); +static void usage (void); +#else struct line_filter; static void diffarg (); /* (char *); */ static void execdiff (); /* (int, char const *, char const *, char const *); */ @@ -65,6 +133,7 @@ #define PVT_tmpdir "/tmp" static char *private_tempnam (); /* (const char *, const char *, int, int *); */ static int diraccess (); +#endif /* Options: */ @@ -108,13 +177,54 @@ exit (2); } +#ifdef AMIGA +static void +amiga_exit () +{ + char *buf; + size_t a; + + if (tmpmade) + { + remove (tmpname); + tmpmade = 0; + } + if (diff_file) + { + /* Provide empty pipe! */ + buf = xmalloc (SDIFF_BUFSIZE); + do + a = fread (buf, sizeof (char), SDIFF_BUFSIZE, diff_file); + while (a == SDIFF_BUFSIZE); + fclose (diff_file); + diff_file = NULL; + free (buf); + } +} + +static int +amiga_break () +{ + amiga_exit (); + return 20; +} +#endif /* AMIGA */ + static void cleanup () { +#ifndef AMIGA if (0 < diffpid) kill (diffpid, SIGPIPE); if (tmpmade) unlink (tmpname); +#else /* AMIGA */ + if (tmpmade) + { + remove (tmpname); + tmpmade = 0; + } +#endif /* !AMIGA */ } static void @@ -230,6 +340,7 @@ } #endif +#ifndef AMIGA #ifndef HAVE_WAITPID /* Emulate waitpid well enough for sdiff, which has at most two children. */ static pid_t @@ -259,6 +370,7 @@ return pid; } #endif +#endif /* !AMIGA */ static char const * expand_name (name, isdir, other_name) @@ -273,6 +385,7 @@ else { /* Yield NAME/BASE, where BASE is OTHER_NAME's basename. */ +#ifndef AMIGA const char *p = rindex (other_name, '/'), *base = p ? p+1 : other_name; @@ -282,17 +395,45 @@ r[namelen] = '/'; bcopy (base, r + namelen + 1, baselen + 1); return r; +#else /* AMIGA */ + const char *p1, *p2, *base; + size_t namelen, baselen; + char *r; + + p1 = rindex (other_name, '/'); + p2 = rindex (other_name, ':'); + if (p1 == NULL && p2 == NULL) + base = other_name; + else + base = max (p1 + 1 , p2 + 1); + namelen = strlen (name); + baselen = strlen (base); + r = xmalloc (namelen + baselen + 2); + bcopy (name, r, namelen); + if (name[namelen-1] != ':') + { + r[namelen] = '/'; + bcopy (base, r + namelen + 1, baselen + 1); + } + else + { + bcopy (base, r + namelen, baselen + 1); + } + return r; +#endif /* AMIGA */ } } +#ifndef KULTUR struct line_filter { FILE *infile; char *bufpos; char *buffer; char *buflim; }; +#endif static void lf_init (lf, infile) @@ -409,6 +550,18 @@ char *editor = getenv ("EDITOR"); char *differ = getenv ("DIFF"); +#ifdef AMIGA + if (DOSBase->dl_lib.lib_Version < 37) { + fputs ("Need Amiga OS 2.0 (V.37) to execute.\n", stderr); + exit (20); + } + /* Install break and exit traps */ + if (atexit (&amiga_exit)) + fatal ("couldn't set exit trap"); + if (onbreak (&amiga_break)) + fatal ("couldn't set break trap"); +#endif /* AMIGA */ + prog = argv[0]; if (editor) edbin = editor; @@ -496,13 +649,19 @@ if (! out_file) /* easy case: diff does everything for us */ +#ifndef AMIGA execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]); +#else /* AMIGA */ + execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1], FALSE, NULL); +#endif /* !AMIGA */ else { FILE *left, *right, *out, *diffout; int diff_fds[2]; int interact_ok; +#ifndef AMIGA pid_t pid; +#endif struct line_filter lfilt; struct line_filter rfilt; struct line_filter diff_filt; @@ -512,11 +671,13 @@ if (leftdir && rightdir) fatal ("both files to be compared are directories"); - left = ck_fopen (expand_name (argv[optind], leftdir, argv[optind + 1]), "r"); + left = ck_fopen ((char *) expand_name (argv[optind], leftdir, argv[optind + 1]), "r"); ; - right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r"); + right = ck_fopen ((char *) expand_name (argv[optind + 1], rightdir, argv[optind]), "r"); out = ck_fopen (out_file, "w"); +#ifndef AMIGA + if (pipe (diff_fds)) perror_fatal ("pipe"); @@ -545,18 +706,51 @@ close (diff_fds[1]); diffout = ck_fdopen (diff_fds[0], "r"); +#else /* AMIGA */ + + { + BPTR StdOutDiff; + char pipe_name[20]; + + construct_pipe_name (pipe_name); + + StdOutDiff = Open (pipe_name, MODE_NEWFILE); + if (!StdOutDiff) + perror_fatal ("pipe"); + + diff_fds[0] = open (pipe_name, O_RDONLY); + if (diff_fds[0] == -1) + perror_fatal ("pipe"); + + execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1], TRUE, StdOutDiff); + + } + + diffout = ck_fdopen (diff_fds[0], "r"); + diff_file = diffout; + +#endif /* !AMIGA */ + lf_init (&diff_filt, diffout); lf_init (&lfilt, left); lf_init (&rfilt, right); interact_ok = interact (&diff_filt, &lfilt, &rfilt, out); +#ifndef AMIGA ck_fclose (diffout); +#else /* AMIGA */ + /* If the user signaled quit, let the exit code clean up the + pipe and close the file */ + if (!user_quit) + ck_fclose (diffout); +#endif /* !AMIGA */ ck_fclose (left); ck_fclose (right); ck_fclose (out); { +#ifndef AMIGA int wstatus; if (waitpid (pid, &wstatus, 0) < 0) @@ -576,6 +770,20 @@ fatal ("Subsidiary diff failed"); exit (WEXITSTATUS (wstatus)); +#else /* AMIGA */ + if (tmpmade) + { + remove (tmpname); + tmpmade = 0; + } + + if (! interact_ok) + exit (2); + + diff_file = NULL; + + exit (0); +#endif /* !AMIGA */ } } return 0; /* Fool -Wall . . . */ @@ -604,6 +812,8 @@ diffargv[diffargs++] = a; } +#ifndef AMIGA + static void execdiff (differences_only, option, file1, file2) int differences_only; @@ -623,9 +833,102 @@ _exit (2); } - +#else /* AMIGA */ + +static void +execdiff (differences_only, option, file1, file2, asynch, handle) + int differences_only; + char *option, *file1, *file2; + long asynch; + BPTR handle; +{ + struct TagItem STags[5]; + + if (differences_only) + diffarg ("--suppress-common-lines"); + diffarg (option); + diffarg ("--"); + diffarg (file1); + diffarg (file2); + diffarg (0); + + construct_command_line ((char *) diffbin, diffargv, command_line); + if (asynch) + { +#ifdef KULTUR + STags[0].ti_Tag = (Tag) SYS_Input; + STags[0].ti_Data = NULL; + STags[1].ti_Tag = (Tag) SYS_Output; + STags[1].ti_Data = handle; + STags[2].ti_Tag = (Tag) SYS_Asynch; + STags[2].ti_Data = TRUE; + STags[3].ti_Tag = (Tag) SYS_UserShell; + STags[3].ti_Data = TRUE; + STags[4].ti_Tag = TAG_DONE; +#else + STags[0].ti_Tag = SYS_Input; + STags[0].ti_Data = NULL; + STags[1].ti_Tag = SYS_Output; + STags[1].ti_Data = handle; + STags[2].ti_Tag = SYS_Asynch; + STags[2].ti_Data = TRUE; + STags[3].ti_Tag = SYS_UserShell; + STags[3].ti_Data = TRUE; + STags[4].ti_Tag = TAG_DONE; +#endif + if (System (command_line, STags) != 0) + perror_fatal ("diff not found"); + } + else + { +#ifdef KULTUR + STags[0].ti_Tag = (Tag) SYS_Asynch; + STags[0].ti_Data = FALSE; + STags[1].ti_Tag = (Tag) SYS_UserShell; + STags[1].ti_Data = TRUE; + STags[2].ti_Tag = TAG_DONE; +#else + STags[0].ti_Tag = SYS_Asynch; + STags[0].ti_Data = FALSE; + STags[1].ti_Tag = SYS_UserShell; + STags[1].ti_Data = TRUE; + STags[2].ti_Tag = TAG_DONE; +#endif + if (System (command_line, STags) != 0) + perror_fatal ("diff not found"); + exit (0); + } +} + +static void +construct_command_line (binname, argvec, com_line) + char *binname, **argvec, *com_line; +{ + int i; + strcpy (com_line, binname); + for (i = 1; argvec[i]; i++) + { + /* Enclose arguments in quotes */ + strcat (com_line, " \""); + strcat (com_line, argvec[i]); + strcat (com_line, "\""); + } +} + +static void +construct_pipe_name (pipe_name) + char *pipe_name; +{ + static long invocations = 0; + struct Task *Task; + Task = FindTask (NULL); + sprintf (pipe_name, "PIPE:%08lX_%ld", Task, invocations); +} +#endif /* !AMIGA */ + +#ifndef AMIGA /* Signal handling */ static int volatile ignore_signals; @@ -670,6 +973,7 @@ if (signal (*p, SIG_IGN) != SIG_IGN && signal (*p, catchsig) != SIG_IGN) fatal ("signal error"); } +#endif /* !AMIGA */ @@ -796,7 +1100,11 @@ suppress_common_flag = 0; break; case 'q': +#ifdef AMIGA + user_quit = 1; +#endif return 0; +#ifndef AMIGA case 'e': if (! tmpname && ! (tmpname = private_tempnam (0, "sdiff", 1, 0))) perror_fatal ("temporary file name"); @@ -864,11 +1172,72 @@ while ((size = ck_fread (buf, SDIFF_BUFSIZE, tmp)) != 0) ck_fwrite (buf, size, outfile); ck_fclose (tmp); - free (buf); } return 1; } +#else /* AMIGA */ + case 'e': + if (! tmpname && ! (tmpname = tmpnam (NULL))) + perror_fatal ("temporary file name"); + + tmpmade = 1; + + { + FILE *tmp; + + tmp = ck_fopen (tmpname, "w"); + + if (cmd1 == 'l' || cmd1 == 'b') + lf_copy (left, lenl, tmp); + else + lf_skip (left, lenl); + + if (cmd1 == 'r' || cmd1 == 'b') + lf_copy (right, lenr, tmp); + else + lf_skip (right, lenr); + + ck_fclose (tmp); + + { + struct TagItem STags[3]; + + sprintf (command_line, "%s \"%s\"", edbin, tmpname); +#ifdef KULTUR + STags[0].ti_Tag = (Tag) SYS_Asynch; + STags[0].ti_Data = FALSE; + STags[1].ti_Tag = (Tag) SYS_UserShell; + STags[1].ti_Data = TRUE; + STags[2].ti_Tag = TAG_DONE; +#else + STags[0].ti_Tag = SYS_Asynch; + STags[0].ti_Data = FALSE; + STags[1].ti_Tag = SYS_UserShell; + STags[1].ti_Data = TRUE; + STags[2].ti_Tag = TAG_DONE; +#endif + if (System (command_line, STags) != 0) + perror_fatal ("Subsidiary editor failed"); + } + + + { + static char *buf; + size_t size; + + tmp = ck_fopen (tmpname, "r"); + + buf = xmalloc (SDIFF_BUFSIZE * sizeof (char)); + while ((size = ck_fread (buf, SDIFF_BUFSIZE, tmp)) != 0) + ck_fwrite (buf, size, outfile); + free (buf); + + ck_fclose (tmp); + } + return 1; + } +#endif /* !AMIGA */ default: give_help (); break; @@ -947,7 +1316,7 @@ const char *dir; { struct stat buf; - return stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode); + return stat ((char *) dir, &buf) == 0 && S_ISDIR (buf.st_mode); } /* Return nonzero if FILE exists. */ @@ -956,9 +1325,11 @@ const char *file; { struct stat buf; - return stat (file, &buf) == 0; + return stat ((char *) file, &buf) == 0; } +#ifndef AMIGA + /* These are the characters used in temporary filenames. */ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; @@ -1065,3 +1436,5 @@ *lenptr = len; return buf; } + +#endif /* AMIGA */ --- Diff22:normal.c Tue Jul 07 01:23:06 1992 +++ normal.c Sun Apr 04 19:39:50 1993 @@ -20,10 +20,14 @@ #include "diff.h" +#ifdef KULTUR +static void print_normal_hunk (struct change *hunk); +#else int change_letter (); void print_normal_hunk (); void print_number_range (); struct change *find_change (); +#endif /* Print the edit-script SCRIPT as a normal diff. INF points to an array of descriptions of the two files. */ @@ -39,7 +43,7 @@ This is a contiguous portion of a complete edit script, describing changes in consecutive lines. */ -void +static void print_normal_hunk (hunk) struct change *hunk; { --- Diff22:io.c Mon Nov 23 12:44:32 1992 +++ io.c Sun Apr 04 19:39:46 1993 @@ -26,7 +26,13 @@ /* Given a hash value and a new character, return a new hash value. */ #define HASH(h, c) ((c) + ROL (h, 7)) +#ifdef KULTUR +static void find_and_hash_each_line (struct file_data *); +static void find_identical_ends (struct file_data []); +static void prepare_text_end (struct file_data *); +#else int line_cmp (); +#endif /* Guess remaining number of lines from number N of lines so far, size S so far, and total size T. */ @@ -326,7 +332,7 @@ /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */ alloc_lines = 2 * alloc_lines - linbuf_base; cureqs = (int *) xrealloc (cureqs, alloc_lines * sizeof (*cureqs)); - linbuf = (const char **) xrealloc (linbuf + linbuf_base, + linbuf = (const char **) xrealloc ((VOID *) (linbuf + linbuf_base), (alloc_lines - linbuf_base) * sizeof (*linbuf)) - linbuf_base; @@ -347,7 +353,7 @@ { /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */ alloc_lines = 2 * alloc_lines - linbuf_base; - linbuf = (const char **) xrealloc (linbuf + linbuf_base, + linbuf = (const char **) xrealloc ((VOID *)(linbuf + linbuf_base), (alloc_lines - linbuf_base) * sizeof (*linbuf)) - linbuf_base; @@ -573,7 +579,7 @@ { int l = lines++ & prefix_mask; if (l == alloc_lines0) - linbuf0 = (const char **) xrealloc (linbuf0, (alloc_lines0 *= 2) + linbuf0 = (const char **) xrealloc ((VOID *)linbuf0, (alloc_lines0 *= 2) * sizeof(*linbuf0)); linbuf0[l] = p0; while (*p0++ != '\n')