diff -cr ram:indent-1.8/args.c dh1:indent-1.8/args.c *** ram:indent-1.8/args.c Tue Jun 15 19:45:36 1993 --- dh1:indent-1.8/args.c Thu Jun 24 17:52:12 1993 *************** *** 775,780 **** --- 775,801 ---- register FILE *f; char *fname; static char prof[] = INDENT_PROFILE; + #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 */ char *homedir; if ((f = fopen (INDENT_PROFILE, "r")) != NULL) *************** *** 806,811 **** --- 827,833 ---- free (fname); } + #endif /* !AMIGA */ return 0; } diff -cr ram:indent-1.8/backup.c dh1:indent-1.8/backup.c *** ram:indent-1.8/backup.c Tue Jun 15 19:29:42 1993 --- dh1:indent-1.8/backup.c Thu Jun 24 19:40:34 1993 *************** *** 75,80 **** --- 75,83 ---- #include #endif /* !USG */ #endif /* !DIRENT */ + #ifdef AMIGA + #define direct dirent + #endif /* AMIGA */ #if defined (HAVE_UNISTD_H) #include *************** *** 92,97 **** --- 95,107 ---- #define generate_backup_filename(v,f) simple_backup_name((f)) #endif /* NODIR */ + #ifdef AMIGA + #define SYS_BACKUP_SUFFIX "!" + #define BACKUP_SUFFIX_STR "!" + #define BACKUP_SUFFIX_CHAR '!' + #define BACKUP_SUFFIX_FORMAT "%s.!%d!" + #endif /* AMIGA */ + #ifndef SYS_BACKUP_SUFFIX #define SYS_BACKUP_SUFFIX "~" #endif *************** *** 207,212 **** --- 217,252 ---- 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--; *************** *** 223,231 **** --- 263,276 ---- free (dirname); return version; } + #endif /* !AMIGA */ filename = pathname; + #ifdef AMIGA + version = highest_version (filename, ""); + #else /* !AMIGA */ version = highest_version (filename, "."); + #endif /* !AMIGA */ return version; } *************** *** 257,263 **** if (!backup_name) return 0; ! sprintf (backup_name, BACKUP_SUFFIX_STR, pathname, (int) last_numbered_version); return backup_name; } --- 302,308 ---- if (!backup_name) return 0; ! sprintf (backup_name, BACKUP_SUFFIX_FORMAT, pathname, (int) last_numbered_version); return backup_name; } *************** *** 337,352 **** --- 382,420 ---- struct file_buffer *file; { int fd; + #ifndef AMIGA register char *p = file->name + strlen (file->name) - 1; + #endif char *backup_filename; + #ifndef AMIGA char *new_backup_name; + #endif 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.8/indent.c dh1:indent-1.8/indent.c *** ram:indent-1.8/indent.c Tue Jun 15 02:50:18 1993 --- dh1:indent-1.8/indent.c Thu Jun 24 20:10:07 1993 *************** *** 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 /* AMIGA */ + void usage () { *************** *** 207,213 **** #if 0 if (col > ind_size) parser_state_tos->ind_level = parser_state_tos->i_l_follow = col; ! #endif/ } if (troff) --- 222,228 ---- #if 0 if (col > ind_size) parser_state_tos->ind_level = parser_state_tos->i_l_follow = col; ! #endif } if (troff) *************** *** 409,418 **** if (verbose) { ! printf ("There were %d output lines and %d comments\n", (int) out_lines, (int) out_coms); ! printf ("(Lines with comments)/(Lines with code): %6.3f\n", ! (1.0 * com_lines) / code_lines); } fflush (output); if (found_err) --- 424,433 ---- if (verbose) { ! fprintf (stderr, "There were %d output lines and %d comments\n", (int) out_lines, (int) out_coms); ! fprintf (stderr, "(Lines with comments)/(Lines with code): %6.3f\n", ! (1.0 * com_lines) / (code_lines > 0 ? code_lines : 1) ); } fflush (output); if (found_err) *************** *** 1647,1658 **** --- 1662,1701 ---- 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 (); *************** *** 1755,1762 **** --- 1798,1813 ---- 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) + fprintf (stderr, "\n%s:\n", out_name); + #endif /* AMIGA */ output = fopen (out_name, "w"); if (output == 0) { *************** *** 1788,1793 **** --- 1839,1848 ---- if (!out_name && !use_stdout) { out_name = in_file_names[0]; + #ifdef AMIGA + if (verbose) + fprintf (stderr, "\n%s:\n", out_name); + #endif /* AMIGA */ make_backup (current_input); } } *************** *** 1813,1815 **** --- 1868,1991 ---- 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.8/io.c dh1:indent-1.8/io.c *** ram:indent-1.8/io.c Tue Jun 15 19:53:26 1993 --- dh1:indent-1.8/io.c Thu Jun 24 19:10:08 1993 *************** *** 271,277 **** --- 271,281 ---- if (e_lab[-1] == EOL) e_lab--; do + #ifdef AMIGA + fputc (*s++, output); + #else /* !AMIGA */ putc (*s++, output); + #endif /* !AMIGA */ while (s < e_lab && 'a' <= *s && *s <= 'z'); while ((*s == ' ' || *s == TAB) && s < e_lab) s++; *************** *** 417,425 **** --- 421,435 ---- comment_open = 1 + parser_state_tos->box_com; while (*p) { + #ifdef AMIGA if (*p == BACKSLASH) + fputc (BACKSLASH, output); + fputc (*p++, output); + #else /* !AMIGA */ + if (*p == BACKSLASH) putc (BACKSLASH, output); putc (*p++, output); + #endif /* !AMIGA */ } } else *************** *** 726,732 **** --- 736,746 ---- { p = buf_ptr; while (p < buf_end) + #ifdef AMIGA + fputc (*p++, output); + #else /* !AMIGA */ putc (*p++, output); + #endif /* !AMIGA */ if (inhibit_formatting == 2) { inhibit_formatting = 0; diff -cr ram:indent-1.8/sys.h dh1:indent-1.8/sys.h *** ram:indent-1.8/sys.h Tue Jun 15 19:47:52 1993 --- dh1:indent-1.8/sys.h Thu Jun 24 17:18:32 1993 *************** *** 8,13 **** --- 8,18 ---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include + #ifdef AMIGA + /* For malloc, etc... */ + #include + #include + #endif /* AMIGA */ /* Values of special characters. */ #define TAB '\t' *************** *** 45,53 **** --- 50,60 ---- /* 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 { *************** *** 59,66 **** --- 66,75 ---- 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 ();