Only in dh2:indent-1.4: Makefile.amiga Only in dh2:indent-1.4: README.Amiga diff -c -r ram:indent-1.4-orig/args.c dh2:indent-1.4/args.c *** ram:indent-1.4-orig/args.c Fri Jun 12 02:31:38 1992 --- dh2:indent-1.4/args.c Wed Jun 24 20:02:48 1992 *************** *** 716,721 **** --- 716,741 ---- 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 if ((f = fopen (INDENT_PROFILE, "r")) != NULL) { int len = strlen (INDENT_PROFILE) + 3; *************** *** 745,750 **** --- 765,771 ---- free (fname); } + #endif return 0; } diff -c -r ram:indent-1.4-orig/backup.c dh2:indent-1.4/backup.c *** ram:indent-1.4-orig/backup.c Fri Jun 05 19:56:42 1992 --- dh2:indent-1.4/backup.c Wed Jun 24 21:02:09 1992 *************** *** 75,80 **** --- 75,83 ---- #else /* !USG */ #ifdef SYSDIR #include + #ifdef AMIGA + #define dirent direct + #endif #endif /* SYSDIR */ #endif /* !USG */ #endif /* !DIRENT */ *************** *** 92,98 **** --- 95,105 ---- #endif /* NODIR */ /* Default backup file suffix to use */ + #ifdef AMIGA + char *simple_backup_suffix = "!"; + #else char *simple_backup_suffix = "~"; + #endif /* What kinds of backup files to make -- see table `version_control_values' below. */ *************** *** 133,139 **** --- 140,150 ---- { for (p = &direntry[base_length + 2]; ISDIGIT (*p); ++p) version = version * 10 + *p - '0'; + #ifdef AMIGA + if (p[0] != '!' || p[1]) + #else if (p[0] != '~' || p[1]) + #endif version = 0; } *************** *** 189,194 **** --- 200,235 ---- 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 while (p > pathname && *p != '/') p--; *************** *** 205,213 **** --- 246,259 ---- free (dirname); return version; } + #endif filename = pathname; + #ifdef AMIGA + version = highest_version (filename, ""); + #else version = highest_version (filename, "."); + #endif return version; } *************** *** 239,245 **** --- 285,295 ---- if (! backup_name) return 0; + #ifdef AMIGA + sprintf (backup_name, "%s.!%d!", pathname, last_numbered_version); + #else sprintf (backup_name, "%s.~%d~", pathname, last_numbered_version); + #endif return backup_name; } #endif /* !NODIR */ *************** *** 322,332 **** --- 372,401 ---- 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 + if (! backup_filename) + { fprintf (stderr, "indent: Can't make backup filename of %s", file->name); exit (1); } + #endif fd = creat (backup_filename, 0666); if (fd < 0) Only in dh2:indent-1.4: dirent_def.h Only in dh2:indent-1.4: indent diff -c -r ram:indent-1.4-orig/indent.c dh2:indent-1.4/indent.c *** ram:indent-1.4-orig/indent.c Fri Jun 12 02:30:28 1992 --- dh2:indent-1.4/indent.c Wed Jun 24 20:24:15 1992 *************** *** 21,26 **** --- 21,41 ---- #include "indent.h" #include + #ifdef AMIGA + #include + #include + #include + #include + #include + + #define MAXPATH 200 + #define MAXARGS 256 + + extern struct DosLibrary *DOSBase; + + int expand_args (); + #endif + void usage () { *************** *** 1514,1519 **** --- 1529,1537 ---- struct file_buffer *current_input; char *profile_pathname = 0; int using_stdin = false; + #ifdef AMIGA + int ex_err; + #endif #ifdef DEBUG if (debug) *************** *** 1520,1525 **** --- 1538,1568 ---- 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 + init_parser (); initialize_backups (); *************** *** 1620,1627 **** --- 1663,1678 ---- for (i = 0; input_files; i++, input_files--) { + #ifdef AMIGA + /* Reset line- and comment-count */ + out_lines = out_coms = 0; + #endif 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 output = fopen (out_name, "w"); if (output == 0) { *************** *** 1652,1657 **** --- 1703,1712 ---- if (! out_name && ! use_stdout) { out_name = in_file_names[0]; + #ifdef AMIGA + if (verbose) + printf ("\n%s:\n", out_name); + #endif make_backup (current_input); } } *************** *** 1677,1679 **** --- 1732,1855 ---- 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 diff -c -r ram:indent-1.4-orig/io.c dh2:indent-1.4/io.c *** ram:indent-1.4-orig/io.c Fri Jun 12 20:44:46 1992 --- dh2:indent-1.4/io.c Wed Jun 24 20:30:58 1992 *************** *** 26,33 **** --- 26,40 ---- or instead. */ #include + #ifdef AMIGA + #include + #include + #include + #define bcopy(s,d,l) memcpy(d,s,l) + #else #include #include + #endif /* number of levels a label is placed to left of code */ #define LABEL_OFFSET 2 *************** *** 431,439 **** --- 438,471 ---- char *filename; { int fd; + #ifndef AMIGA struct stat file_stats; + #endif 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 fd = open (filename, O_RDONLY, 0777); if (fd < 0) sys_error (filename); *************** *** 445,450 **** --- 477,483 ---- free (fileptr.data); fileptr.size = file_stats.st_size; fileptr.data = (char *) xmalloc (file_stats.st_size + 3); + #endif if (read (fd, fileptr.data, fileptr.size) < 0) sys_error (filename); *************** *** 479,488 **** --- 512,558 ---- unsigned int size = 15 * BUFSIZ; int ch; register char *p; + #ifdef AMIGA + char *in_prog; + int in_prog_size; + #endif 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 + 3); + 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] = ' '; + stdinptr.data[stdinptr.size + 1] = '\n'; + stdinptr.data[stdinptr.size + 2] = '\0'; + #else stdinptr.data = (char *) xmalloc (size + 3); stdinptr.size = 0; p = stdinptr.data; *************** *** 511,516 **** --- 581,587 ---- stdinptr.data[stdinptr.size] = ' '; stdinptr.data[stdinptr.size + 1] = '\n'; stdinptr.data[stdinptr.size + 2] = '\0'; + #endif return &stdinptr; } diff -c -r ram:indent-1.4-orig/sys.h dh2:indent-1.4/sys.h *** ram:indent-1.4-orig/sys.h Fri Jun 12 21:31:08 1992 --- dh2:indent-1.4/sys.h Wed Jun 24 20:34:05 1992 *************** *** 8,13 **** --- 8,18 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include + #ifdef AMIGA + /* For malloc, etc... */ + #include + #include + #endif #ifdef DEBUG extern int debug; *************** *** 23,30 **** --- 28,37 ---- extern struct file_buffer *read_file (), *read_stdin (); /* Standard memory allocation routines. */ + #ifndef AMIGA char *malloc (); char *realloc (); + #endif /* Similar, but abort with an error if out of memory (see globs.c). */ char *xmalloc (); *************** *** 45,48 **** --- 52,61 ---- #define mymemcpy(to,from,len) bcopy ((from),(to),(len)) #endif + #ifdef AMIGA + #define mymemcpy(from,to,len) (void) memcpy ((from),(to),(len)) + #endif + + #ifndef AMIGA char *mymemcpy (); + #endif