home *** CD-ROM | disk | FTP | other *** search
- diff -cr ram:indent-1.7/args.c dh1:indent-1.7/args.c
- *** ram:indent-1.7/args.c Mon Feb 08 23:41:08 1993
- --- dh1:indent-1.7/args.c Sat Feb 13 18:13:37 1993
- ***************
- *** 772,777 ****
- --- 772,797 ----
- static char prof[] = INDENT_PROFILE;
- char *homedir;
-
- + #ifdef AMIGA
- + if ((f = fopen (prof, "r")) != NULL)
- + {
- + scan_profile (f);
- + (void) fclose (f);
- + fname = xmalloc (sizeof prof);
- + strcpy (fname, prof);
- + return fname;
- + }
- +
- + fname = xmalloc (sizeof prof + 5);
- + sprintf (fname, "S:%s", prof);
- +
- + if ((f = fopen (fname, "r")) != NULL)
- + {
- + scan_profile (f);
- + (void) fclose (f);
- + return fname;
- + }
- + #else /* !AMIGA */
- if ((f = fopen (INDENT_PROFILE, "r")) != NULL)
- {
- int len = strlen (INDENT_PROFILE) + 3;
- ***************
- *** 801,806 ****
- --- 821,827 ----
-
- free (fname);
- }
- + #endif /* !AMIGA */
-
- return 0;
- }
- diff -cr ram:indent-1.7/backup.c dh1:indent-1.7/backup.c
- *** ram:indent-1.7/backup.c Mon Feb 08 15:07:28 1993
- --- dh1:indent-1.7/backup.c Sat Feb 13 18:16:42 1993
- ***************
- *** 74,79 ****
- --- 74,82 ----
- #endif /* !SYSNDIR */
- #else /* !USG */
- #include <sys/dir.h>
- + #ifdef AMIGA
- + #define dirent direct
- + #endif /* AMIGA */
- #endif /* !USG */
- #endif /* !DIRENT */
-
- ***************
- *** 94,100 ****
- --- 97,107 ----
- #endif /* NODIR */
-
- /* Default backup file suffix to use */
- + #ifdef AMIGA
- + char *simple_backup_suffix = "!";
- + #else /* !AMIGA */
- char *simple_backup_suffix = "~";
- + #endif /* !AMIGA */
-
- /* What kinds of backup files to make -- see
- table `version_control_values' below. */
- ***************
- *** 135,141 ****
- --- 142,152 ----
- {
- for (p = &direntry[base_length + 2]; ISDIGIT (*p); ++p)
- version = version * 10 + *p - '0';
- + #ifdef AMIGA
- + if (p[0] != '!' || p[1])
- + #else /* !AMIGA */
- if (p[0] != '~' || p[1])
- + #endif /* !AMIGA */
- version = 0;
- }
-
- ***************
- *** 191,196 ****
- --- 202,237 ----
- int version;
-
- p = pathname + pathlen - 1;
- + #ifdef AMIGA
- + while (p > pathname && *p != '/' && *p != ':')
- + p--;
- + if (*p == '/')
- + {
- + int dirlen = p - pathname;
- + register char *dirname;
- +
- + filename = p + 1;
- + dirname = xmalloc (dirlen + 1);
- + strncpy (dirname, pathname, (dirlen));
- + dirname[dirlen] = '\0';
- + version = highest_version (filename, dirname);
- + free (dirname);
- + return version;
- + }
- + else if (*p == ':')
- + {
- + int dirlen = p - pathname + 1;
- + register char *dirname;
- +
- + filename = p + 1;
- + dirname = xmalloc (dirlen + 1);
- + strncpy (dirname, pathname, (dirlen));
- + dirname[dirlen] = '\0';
- + version = highest_version (filename, dirname);
- + free (dirname);
- + return version;
- + }
- + #else /* !AMIGA */
- while (p > pathname && *p != '/')
- p--;
-
- ***************
- *** 207,215 ****
- --- 248,261 ----
- free (dirname);
- return version;
- }
- + #endif /* !AMIGA */
-
- filename = pathname;
- + #ifdef AMIGA
- + version = highest_version (filename, "");
- + #else /* !AMIGA */
- version = highest_version (filename, ".");
- + #endif /* !AMIGA */
- return version;
- }
-
- ***************
- *** 241,248 ****
- --- 287,299 ----
- if (!backup_name)
- return 0;
-
- + #ifdef AMIGA
- + sprintf (backup_name, "%s.!%d!", pathname,
- + (int) last_numbered_version);
- + #else /* !AMIGA */
- sprintf (backup_name, "%s.~%d~", pathname,
- (int) last_numbered_version);
- + #endif /* !AMIGA */
- return backup_name;
- }
-
- ***************
- *** 326,336 ****
- --- 377,406 ----
- char *new_backup_name;
-
- backup_filename = generate_backup_filename (version_control, file->name);
- + #ifdef AMIGA
- + /* The original code contains a bug here. generate_backup_filename sets
- + the return value to NULL if version_control == none. Just do nothing
- + in this case. */
- + if (! backup_filename)
- + {
- + if (version_control != none)
- + {
- + fprintf (stderr, "indent: Can't make backup filename of %s\n", file->name);
- + exit (1);
- + }
- + else
- + {
- + free (backup_filename);
- + return;
- + }
- + }
- + #else /* !AMIGA */
- if (!backup_filename)
- {
- fprintf (stderr, "indent: Can't make backup filename of %s", file->name);
- exit (1);
- }
- + #endif /* !AMIGA */
-
- fd = creat (backup_filename, 0666);
- if (fd < 0)
- diff -cr ram:indent-1.7/indent.c dh1:indent-1.7/indent.c
- *** ram:indent-1.7/indent.c Thu Feb 11 01:24:06 1993
- --- dh1:indent-1.7/indent.c Sat Feb 13 18:17:07 1993
- ***************
- *** 21,26 ****
- --- 21,41 ----
- #include "indent.h"
- #include <ctype.h>
-
- + #ifdef AMIGA
- + #include <exec/types.h>
- + #include <dos/dos.h>
- + #include <dos/dosextens.h>
- + #include <dos/dosasl.h>
- + #include <proto/dos.h>
- +
- + #define MAXPATH 200
- + #define MAXARGS 256
- +
- + extern struct DosLibrary *DOSBase;
- +
- + int expand_args ();
- + #endif /* AMIGA */
- +
- void
- usage ()
- {
- ***************
- *** 1637,1648 ****
- --- 1652,1691 ----
- struct file_buffer *current_input;
- char *profile_pathname = 0;
- int using_stdin = false;
- + #ifdef AMIGA
- + int ex_err;
- + #endif /* AMIGA */
-
- #ifdef DEBUG
- if (debug)
- debug_init ();
- #endif
-
- + #ifdef AMIGA
- + if (DOSBase->dl_lib.lib_Version < 37)
- + {
- + fprintf (stderr, "You must have Kickstart 2.0 (V37) or higher!\n");
- + exit (20);
- + }
- +
- + if (argc == 2 && stricmp (argv[1],"-h") == 0)
- + {
- + usage ();
- + exit (0);
- + }
- +
- + if ((ex_err = expand_args (&argc, &argv)) == 0)
- + {
- + fprintf (stderr, "Couldn't expand wildcards\n");
- + exit (20);
- + }
- + if (ex_err == 2)
- + {
- + fprintf (stderr, "Wildcards didn't match a file\n");
- + exit (5);
- + }
- + #endif /* AMIGA */
- +
- init_parser ();
- initialize_backups ();
-
- ***************
- *** 1745,1752 ****
- --- 1788,1803 ----
-
- for (i = 0; input_files; i++, input_files--)
- {
- + #ifdef AMIGA
- + /* Reset line- and comment-count */
- + out_lines = out_coms = 0;
- + #endif /* AMIGA */
- current_input = read_file (in_file_names[i]);
- in_name = out_name = in_file_names[i];
- + #ifdef AMIGA
- + if (verbose)
- + printf ("\n%s:\n", out_name);
- + #endif /* AMIGA */
- output = fopen (out_name, "w");
- if (output == 0)
- {
- ***************
- *** 1778,1783 ****
- --- 1829,1838 ----
- if (!out_name && !use_stdout)
- {
- out_name = in_file_names[0];
- + #ifdef AMIGA
- + if (verbose)
- + printf ("\n%s:\n", out_name);
- + #endif /* AMIGA */
- make_backup (current_input);
- }
- }
- ***************
- *** 1803,1805 ****
- --- 1858,1981 ----
-
- exit (0);
- }
- +
- +
- + #ifdef AMIGA
- + char *expand_next_file (pattern)
- + char *pattern;
- + {
- + long err;
- + char *pathname;
- + static struct AnchorPath *an = NULL;
- +
- + pathname = NULL;
- + if (pattern == NULL)
- + err = -1;
- + else
- + do
- + {
- + if (an == NULL)
- + {
- + an = malloc (sizeof (struct AnchorPath) + MAXPATH);
- + memset (an, 0, sizeof (struct AnchorPath) + MAXPATH);
- + an->ap_BreakBits = SIGBREAKF_CTRL_C;
- + an->ap_Strlen = MAXPATH;
- + an->ap_Flags = APF_DOWILD;
- + err = MatchFirst (pattern, an);
- + }
- + else
- + err = MatchNext (an);
- +
- + /* Expand only files */
- + if (an->ap_Info.fib_DirEntryType < 0)
- + pathname = an->ap_Buf;
- + } while (err == 0 && pathname == NULL);
- +
- + if (err)
- + {
- + MatchEnd (an);
- + free (an);
- + an = NULL;
- + return NULL;
- + }
- + else
- + return pathname;
- + }
- +
- +
- + int
- + in_prev_args (arg, argv, argc)
- + char *arg, **argv;
- + int argc;
- + {
- + int i, is_in_args;
- +
- + is_in_args = 0;
- + for (i = 1; i < argc - 1; i++)
- + if (strcmp (arg, argv[i]) == 0)
- + is_in_args = 1;
- + return is_in_args;
- + }
- +
- +
- + int
- + expand_args (oargc, oargv)
- + int *oargc;
- + char ***oargv;
- + {
- + int i;
- + char *str, **argv, buf[MAXPATH];
- + int argc, no_match_at_all, num_matches, contains_wildcards;
- +
- + no_match_at_all = 1;
- + contains_wildcards = 0;
- + argc = 0;
- + argv = malloc (MAXARGS * sizeof (char *));
- + if (argv == NULL)
- + return 0;
- +
- + argv[argc++] = (*oargv)[0];
- + for (i = 1; i < *oargc; i++)
- + {
- + if (ParsePattern ((*oargv)[i], buf, MAXPATH))
- + {
- + contains_wildcards = 1;
- + num_matches = 0;
- + while (str = expand_next_file ((*oargv)[i]))
- + if (argc >= MAXARGS)
- + {
- + expand_next_file (NULL);
- + return 0;
- + }
- + else
- + {
- + /* Avoid duplicate entries */
- + if (!in_prev_args (str, argv, argc))
- + {
- + argv[argc++] = strdup (str);
- + num_matches++;
- + }
- + }
- + if (num_matches != 0)
- + no_match_at_all = 0;
- + }
- + else
- + if (argc >= MAXARGS)
- + return 0;
- + else
- + {
- + if ((*oargv)[i][0] != '-' && (*oargv)[i][0] != '+')
- + /* Found a file with no wildcards */
- + no_match_at_all = 0;
- + if (!in_prev_args ((*oargv)[i], argv, argc))
- + argv[argc++] = (*oargv)[i];
- + }
- + }
- + *oargc = argc;
- + *oargv = argv;
- + if (no_match_at_all && contains_wildcards)
- + return 2;
- + else
- + return 1;
- + }
- + #endif /* AMIGA */
- diff -cr ram:indent-1.7/io.c dh1:indent-1.7/io.c
- *** ram:indent-1.7/io.c Wed Feb 10 22:03:16 1993
- --- dh1:indent-1.7/io.c Sat Feb 13 18:17:11 1993
- ***************
- *** 26,33 ****
- --- 26,39 ----
- <sys/fcntl.h> or <sys/file.h> instead. */
- #include <fcntl.h>
-
- + #ifdef AMIGA
- + #include <exec/types.h>
- + #include <dos/dos.h>
- + #include <proto/dos.h>
- + #else /* !AMIGA */
- #include <sys/types.h>
- #include <sys/stat.h>
- + #endif /* !AMIGA */
-
- /* number of levels a label is placed to left of code */
- #define LABEL_OFFSET 2
- ***************
- *** 477,485 ****
- --- 483,516 ----
- char *filename;
- {
- int fd;
- + #ifndef AMIGA
- struct stat file_stats;
- + #endif /* !AMIGA */
- int namelen = strlen (filename);
- + #ifdef AMIGA
- + BPTR in_fh;
- + struct FileInfoBlock __aligned in_fib;
- + #endif
- +
- + #ifdef AMIGA
- + in_fh = Lock (filename, SHARED_LOCK);
- + if (in_fh == 0)
- + sys_error (filename);
- +
- + if (Examine (in_fh, &in_fib) == 0)
- + sys_error (filename);
- +
- + if (fileptr.data != 0)
- + free (fileptr.data);
- + fileptr.size = in_fib.fib_Size;
- + fileptr.data = (char *) xmalloc (fileptr.size + 3);
-
- + UnLock (in_fh);
- +
- + fd = open (filename, O_RDONLY, 0777);
- + if (fd < 0)
- + sys_error (filename);
- + #else /* !AMIGA */
- fd = open (filename, O_RDONLY, 0777);
- if (fd < 0)
- sys_error (filename);
- ***************
- *** 491,496 ****
- --- 522,528 ----
- free (fileptr.data);
- fileptr.size = file_stats.st_size;
- fileptr.data = (char *) xmalloc (file_stats.st_size + 1);
- + #endif /* !AMIGA */
-
- if (read (fd, fileptr.data, fileptr.size) < 0)
- sys_error (filename);
- ***************
- *** 523,532 ****
- --- 555,599 ----
- unsigned int size = 15 * BUFSIZ;
- int ch;
- register char *p;
- + #ifdef AMIGA
- + char *in_prog;
- + int in_prog_size;
- + #endif /* AMIGA */
-
- if (stdinptr.data != 0)
- free (stdinptr.data);
-
- + /* The following code had to be changed, because you can't assume, that
- + xrealloc() always returns the original pointer. By the way: the original
- + code violates the GNU coding standards!!! */
- +
- + #ifdef AMIGA
- + in_prog = (char *) xmalloc (size + 1);
- + in_prog_size = 0;
- + do
- + {
- + for (; in_prog_size < size; in_prog_size++)
- + {
- + ch = getc (stdin);
- + if (ch == EOF)
- + break;
- + in_prog[in_prog_size] = ch;
- + }
- +
- + if (ch != EOF)
- + {
- + size += (2 * BUFSIZ);
- + in_prog = xrealloc (in_prog, size);
- + }
- + }
- + while (ch != EOF);
- +
- + stdinptr.data = in_prog;
- + stdinptr.size = in_prog_size;
- + stdinptr.name = "Standard Input";
- +
- + stdinptr.data[stdinptr.size] = '\0';
- + #else /* !AMIGA */
- stdinptr.data = (char *) xmalloc (size + 1);
- stdinptr.size = 0;
- p = stdinptr.data;
- ***************
- *** 554,559 ****
- --- 621,627 ----
- stdinptr.name = "Standard Input";
-
- stdinptr.data[stdinptr.size] = '\0';
- + #endif /* !AMIGA */
-
- return &stdinptr;
- }
- diff -cr ram:indent-1.7/sys.h dh1:indent-1.7/sys.h
- *** ram:indent-1.7/sys.h Wed Feb 10 21:39:58 1993
- --- dh1:indent-1.7/sys.h Sat Feb 13 18:20:49 1993
- ***************
- *** 8,13 ****
- --- 8,18 ----
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
-
- #include <stdio.h>
- + #ifdef AMIGA
- + /* For malloc, etc... */
- + #include <stdlib.h>
- + #include <string.h>
- + #endif /* AMIGA */
-
- /* Values of special characters. */
- #define TAB '\t'
- ***************
- *** 26,34 ****
- --- 31,41 ----
-
- /* configure defines USG if it can't find bcopy */
-
- + #ifndef AMIGA
- #ifndef USG
- #define memcpy(dest,src,len) bcopy((src),(dest),len)
- #endif
- + #endif /* !AMIGA */
-
- struct file_buffer
- {
- ***************
- *** 40,47 ****
- --- 47,56 ----
- extern struct file_buffer *read_file (), *read_stdin ();
-
- /* Standard memory allocation routines. */
- + #ifndef AMIGA
- char *malloc ();
- char *realloc ();
- + #endif /* !AMIGA */
-
- /* Similar, but abort with an error if out of memory (see globs.c). */
- char *xmalloc ();
-