home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / indent.lha / Indent.lha / indent-1.4amiga.diffs next >
Encoding:
Text File  |  1992-06-24  |  13.4 KB  |  596 lines

  1. Only in dh2:indent-1.4: Makefile.amiga
  2. Only in dh2:indent-1.4: README.Amiga
  3. diff -c -r ram:indent-1.4-orig/args.c dh2:indent-1.4/args.c
  4. *** ram:indent-1.4-orig/args.c    Fri Jun 12 02:31:38 1992
  5. --- dh2:indent-1.4/args.c    Wed Jun 24 20:02:48 1992
  6. ***************
  7. *** 716,721 ****
  8. --- 716,741 ----
  9.     static char prof[]= INDENT_PROFILE;
  10.     char *homedir;
  11.   
  12. + #ifdef AMIGA
  13. +   if ((f = fopen (prof, "r")) != NULL)
  14. +     {
  15. +       scan_profile (f);
  16. +       (void) fclose (f);
  17. +       fname = xmalloc (sizeof prof);
  18. +       strcpy (fname, prof);
  19. +       return fname;
  20. +     }
  21. +   fname = xmalloc (sizeof prof + 5);
  22. +   sprintf (fname, "S:%s", prof);
  23. +   if ((f = fopen (fname, "r")) != NULL)
  24. +     {
  25. +       scan_profile (f);
  26. +       (void) fclose (f);
  27. +       return fname;
  28. +     }
  29. + #else
  30.     if ((f = fopen (INDENT_PROFILE, "r")) != NULL)
  31.       {
  32.         int len = strlen (INDENT_PROFILE) + 3;
  33. ***************
  34. *** 745,750 ****
  35. --- 765,771 ----
  36.   
  37.         free (fname);
  38.       }
  39. + #endif
  40.   
  41.     return 0;
  42.   }
  43. diff -c -r ram:indent-1.4-orig/backup.c dh2:indent-1.4/backup.c
  44. *** ram:indent-1.4-orig/backup.c    Fri Jun 05 19:56:42 1992
  45. --- dh2:indent-1.4/backup.c    Wed Jun 24 21:02:09 1992
  46. ***************
  47. *** 75,80 ****
  48. --- 75,83 ----
  49.   #else /* !USG */
  50.   #ifdef SYSDIR
  51.   #include <sys/dir.h>
  52. + #ifdef AMIGA
  53. + #define dirent direct
  54. + #endif
  55.   #endif /* SYSDIR */
  56.   #endif /* !USG */
  57.   #endif /* !DIRENT */
  58. ***************
  59. *** 92,98 ****
  60. --- 95,105 ----
  61.   #endif /* NODIR */
  62.   
  63.   /* Default backup file suffix to use */
  64. + #ifdef AMIGA
  65. + char *simple_backup_suffix = "!";
  66. + #else
  67.   char *simple_backup_suffix = "~";
  68. + #endif
  69.   
  70.   /* What kinds of backup files to make -- see
  71.      table `version_control_values' below. */
  72. ***************
  73. *** 133,139 ****
  74. --- 140,150 ----
  75.       {
  76.         for (p = &direntry[base_length + 2]; ISDIGIT (*p); ++p)
  77.       version = version * 10 + *p - '0';
  78. + #ifdef AMIGA
  79. +       if (p[0] != '!' || p[1])
  80. + #else
  81.         if (p[0] != '~' || p[1])
  82. + #endif
  83.       version = 0;
  84.       }
  85.   
  86. ***************
  87. *** 189,194 ****
  88. --- 200,235 ----
  89.     int version;
  90.   
  91.     p = pathname + pathlen - 1;
  92. + #ifdef AMIGA
  93. +   while (p > pathname && *p != '/' && *p != ':')
  94. +     p--;
  95. +   if (*p == '/')
  96. +     {
  97. +       int dirlen = p - pathname;
  98. +       register char *dirname;
  99. +       filename = p + 1;
  100. +       dirname = xmalloc (dirlen + 1);
  101. +       strncpy (dirname, pathname, (dirlen));
  102. +       dirname[dirlen] = '\0';
  103. +       version = highest_version (filename, dirname);
  104. +       free (dirname);
  105. +       return version;
  106. +     }
  107. +   else if (*p == ':')
  108. +     {
  109. +       int dirlen = p - pathname + 1;
  110. +       register char *dirname;
  111. +       filename = p + 1;
  112. +       dirname = xmalloc (dirlen + 1);
  113. +       strncpy (dirname, pathname, (dirlen));
  114. +       dirname[dirlen] = '\0';
  115. +       version = highest_version (filename, dirname);
  116. +       free (dirname);
  117. +       return version;
  118. +     }
  119. + #else
  120.     while (p > pathname && *p != '/')
  121.       p--;
  122.   
  123. ***************
  124. *** 205,213 ****
  125. --- 246,259 ----
  126.         free (dirname);
  127.         return version;
  128.       }
  129. + #endif
  130.   
  131.     filename = pathname;
  132. + #ifdef AMIGA
  133. +   version = highest_version (filename, "");
  134. + #else
  135.     version = highest_version (filename, ".");
  136. + #endif
  137.     return version;
  138.   }
  139.   
  140. ***************
  141. *** 239,245 ****
  142. --- 285,295 ----
  143.     if (! backup_name)
  144.       return 0;
  145.   
  146. + #ifdef AMIGA
  147. +   sprintf (backup_name, "%s.!%d!", pathname, last_numbered_version);
  148. + #else
  149.     sprintf (backup_name, "%s.~%d~", pathname, last_numbered_version);
  150. + #endif
  151.     return backup_name;
  152.   }
  153.   #endif /* !NODIR */
  154. ***************
  155. *** 322,332 ****
  156. --- 372,401 ----
  157.     char *new_backup_name;
  158.   
  159.     backup_filename = generate_backup_filename (version_control, file->name);
  160. + #ifdef AMIGA
  161. +   /* The original code contains a bug here. generate_backup_filename sets
  162. +      the return value to NULL if version_control == none. Just do nothing
  163. +      in this case. */
  164.     if (! backup_filename)
  165.       {
  166. +       if (version_control != none)
  167. +         {
  168. +           fprintf (stderr, "indent: Can't make backup filename of %s\n", file->name);
  169. +           exit (1);
  170. +         }
  171. +       else
  172. +         {
  173. +           free (backup_filename);
  174. +           return;
  175. +         }
  176. +     }
  177. + #else
  178. +   if (! backup_filename)
  179. +     {
  180.         fprintf (stderr, "indent: Can't make backup filename of %s", file->name);
  181.         exit (1);
  182.       }
  183. + #endif
  184.   
  185.     fd = creat (backup_filename, 0666);
  186.     if (fd < 0)
  187. Only in dh2:indent-1.4: dirent_def.h
  188. Only in dh2:indent-1.4: indent
  189. diff -c -r ram:indent-1.4-orig/indent.c dh2:indent-1.4/indent.c
  190. *** ram:indent-1.4-orig/indent.c    Fri Jun 12 02:30:28 1992
  191. --- dh2:indent-1.4/indent.c    Wed Jun 24 20:24:15 1992
  192. ***************
  193. *** 21,26 ****
  194. --- 21,41 ----
  195.   #include "indent.h"
  196.   #include <ctype.h>
  197.   
  198. + #ifdef AMIGA
  199. + #include <exec/types.h>
  200. + #include <dos/dos.h>
  201. + #include <dos/dosextens.h>
  202. + #include <dos/dosasl.h>
  203. + #include <proto/dos.h>
  204. + #define MAXPATH 200
  205. + #define MAXARGS 256
  206. + extern struct DosLibrary *DOSBase;
  207. + int expand_args ();
  208. + #endif
  209.   void
  210.   usage ()
  211.   {
  212. ***************
  213. *** 1514,1519 ****
  214. --- 1529,1537 ----
  215.     struct file_buffer *current_input;
  216.     char *profile_pathname = 0;
  217.     int using_stdin = false;
  218. + #ifdef AMIGA
  219. +   int ex_err;
  220. + #endif
  221.   
  222.   #ifdef DEBUG
  223.     if (debug)
  224. ***************
  225. *** 1520,1525 ****
  226. --- 1538,1568 ----
  227.       debug_init ();
  228.   #endif
  229.   
  230. + #ifdef AMIGA
  231. +   if (DOSBase->dl_lib.lib_Version < 37)
  232. +     {
  233. +       fprintf (stderr, "You must have Kickstart 2.0 (V37) or higher!\n");
  234. +       exit (20);
  235. +     }
  236. +   if (argc == 2 && stricmp (argv[1],"-h") == 0)
  237. +     {
  238. +       usage ();
  239. +       exit (0);
  240. +     }
  241. +   if ((ex_err = expand_args (&argc, &argv)) == 0)
  242. +     {
  243. +       fprintf (stderr, "Couldn't expand wildcards\n");
  244. +       exit (20);
  245. +     }
  246. +   if (ex_err == 2)
  247. +     {
  248. +       fprintf (stderr, "Wildcards didn't match a file\n");
  249. +       exit (5);
  250. +     }
  251. + #endif
  252.     init_parser ();
  253.     initialize_backups ();
  254.   
  255. ***************
  256. *** 1620,1627 ****
  257. --- 1663,1678 ----
  258.   
  259.         for (i = 0; input_files; i++, input_files--)
  260.       {
  261. + #ifdef AMIGA
  262. +           /* Reset line- and comment-count */
  263. +           out_lines = out_coms = 0;
  264. + #endif
  265.         current_input = read_file (in_file_names[i]);
  266.         in_name = out_name = in_file_names[i];
  267. + #ifdef AMIGA
  268. +           if (verbose)
  269. +             printf ("\n%s:\n", out_name);
  270. + #endif
  271.         output = fopen (out_name, "w");
  272.         if (output == 0)
  273.           {
  274. ***************
  275. *** 1652,1657 ****
  276. --- 1703,1712 ----
  277.         if (! out_name && ! use_stdout)
  278.           {
  279.             out_name = in_file_names[0];
  280. + #ifdef AMIGA
  281. +               if (verbose)
  282. +                 printf ("\n%s:\n", out_name);
  283. + #endif
  284.             make_backup (current_input);
  285.           }
  286.       }
  287. ***************
  288. *** 1677,1679 ****
  289. --- 1732,1855 ----
  290.   
  291.     exit (0);
  292.   }
  293. + #ifdef AMIGA
  294. + char *expand_next_file (pattern)
  295. +      char *pattern;
  296. + {
  297. +   long err;
  298. +   char *pathname;
  299. +   static struct AnchorPath *an = NULL;
  300. +   pathname = NULL;
  301. +   if (pattern == NULL)
  302. +     err = -1;
  303. +   else
  304. +     do
  305. +       {
  306. +         if (an == NULL)
  307. +           {
  308. +             an = malloc (sizeof (struct AnchorPath) + MAXPATH);
  309. +             memset (an, 0, sizeof (struct AnchorPath) + MAXPATH);
  310. +             an->ap_BreakBits = SIGBREAKF_CTRL_C;
  311. +             an->ap_Strlen = MAXPATH;
  312. +             an->ap_Flags = APF_DOWILD;
  313. +             err = MatchFirst (pattern, an);
  314. +           }
  315. +         else
  316. +           err = MatchNext (an);
  317. +         /* Expand only files */
  318. +         if (an->ap_Info.fib_DirEntryType < 0)
  319. +           pathname = an->ap_Buf;
  320. +       } while (err == 0 && pathname == NULL);
  321. +   if (err)
  322. +     {
  323. +       MatchEnd (an);
  324. +       free (an);
  325. +       an = NULL;
  326. +       return NULL;
  327. +     }
  328. +   else
  329. +     return pathname;
  330. + }
  331. + int
  332. + in_prev_args (arg, argv, argc)
  333. +      char *arg, **argv;
  334. +      int argc;
  335. + {
  336. +   int i, is_in_args;
  337. +   is_in_args = 0;
  338. +   for (i = 1; i < argc - 1; i++)
  339. +     if (strcmp (arg, argv[i]) == 0)
  340. +       is_in_args = 1;
  341. +   return is_in_args;
  342. + }
  343. + int
  344. + expand_args (oargc, oargv)
  345. +      int *oargc;
  346. +      char ***oargv;
  347. + {
  348. +   int i;
  349. +   char *str, **argv, buf[MAXPATH];
  350. +   int argc, no_match_at_all, num_matches, contains_wildcards;
  351. +   no_match_at_all = 1;
  352. +   contains_wildcards = 0;
  353. +   argc = 0;
  354. +   argv = malloc (MAXARGS * sizeof (char *));
  355. +   if (argv == NULL)
  356. +     return 0;
  357. +   argv[argc++] = (*oargv)[0];
  358. +   for (i = 1; i < *oargc; i++)
  359. +     {
  360. +       if (ParsePattern ((*oargv)[i], buf, MAXPATH))
  361. +         {
  362. +           contains_wildcards = 1;
  363. +           num_matches = 0;
  364. +           while (str = expand_next_file ((*oargv)[i]))
  365. +             if (argc >= MAXARGS)
  366. +               {
  367. +                 expand_next_file (NULL);
  368. +                 return 0;
  369. +               }
  370. +             else
  371. +               {
  372. +                 /* Avoid duplicate entries */
  373. +                 if (!in_prev_args (str, argv, argc))
  374. +                   {
  375. +                     argv[argc++] = strdup (str);
  376. +                     num_matches++;
  377. +                   }
  378. +               }
  379. +           if (num_matches != 0)
  380. +             no_match_at_all = 0;
  381. +         }
  382. +       else
  383. +         if (argc >= MAXARGS)
  384. +           return 0;
  385. +         else
  386. +           {
  387. +             if ((*oargv)[i][0] != '-' && (*oargv)[i][0] != '+')
  388. +               /* Found a file with no wildcards */
  389. +               no_match_at_all = 0;
  390. +             if (!in_prev_args ((*oargv)[i], argv, argc))
  391. +               argv[argc++] = (*oargv)[i];
  392. +           }
  393. +     }
  394. +   *oargc = argc;
  395. +   *oargv = argv;
  396. +   if (no_match_at_all && contains_wildcards)
  397. +     return 2;
  398. +   else
  399. +     return 1;
  400. + }
  401. + #endif
  402. diff -c -r ram:indent-1.4-orig/io.c dh2:indent-1.4/io.c
  403. *** ram:indent-1.4-orig/io.c    Fri Jun 12 20:44:46 1992
  404. --- dh2:indent-1.4/io.c    Wed Jun 24 20:30:58 1992
  405. ***************
  406. *** 26,33 ****
  407. --- 26,40 ----
  408.      <sys/fcntl.h> or <sys/file.h> instead.  */
  409.   #include <fcntl.h>
  410.   
  411. + #ifdef AMIGA
  412. + #include <exec/types.h>
  413. + #include <dos/dos.h>
  414. + #include <proto/dos.h>
  415. + #define bcopy(s,d,l) memcpy(d,s,l)
  416. + #else
  417.   #include <sys/types.h>
  418.   #include <sys/stat.h>
  419. + #endif
  420.   
  421.   /* number of levels a label is placed to left of code */ 
  422.   #define LABEL_OFFSET 2
  423. ***************
  424. *** 431,439 ****
  425. --- 438,471 ----
  426.        char *filename;
  427.   {
  428.     int fd;
  429. + #ifndef AMIGA
  430.     struct stat file_stats;
  431. + #endif
  432.     int namelen = strlen (filename);
  433. + #ifdef AMIGA
  434. +   BPTR in_fh;
  435. +   struct FileInfoBlock __aligned in_fib;
  436. + #endif
  437. + #ifdef AMIGA
  438. +   in_fh = Lock (filename, SHARED_LOCK);
  439. +   if (in_fh == 0)
  440. +     sys_error (filename);
  441. +   if (Examine (in_fh, &in_fib) == 0)
  442. +     sys_error (filename);
  443. +   if (fileptr.data != 0)
  444. +     free (fileptr.data);
  445. +   fileptr.size = in_fib.fib_Size;
  446. +   fileptr.data = (char *) xmalloc (fileptr.size + 3);
  447.   
  448. +   UnLock (in_fh);
  449. +   fd = open (filename, O_RDONLY, 0777);
  450. +   if (fd < 0)
  451. +     sys_error (filename);
  452. + #else
  453.     fd = open (filename, O_RDONLY, 0777);
  454.     if (fd < 0)
  455.       sys_error (filename);
  456. ***************
  457. *** 445,450 ****
  458. --- 477,483 ----
  459.       free (fileptr.data);
  460.     fileptr.size = file_stats.st_size;
  461.     fileptr.data = (char *) xmalloc (file_stats.st_size + 3);
  462. + #endif
  463.   
  464.     if (read (fd, fileptr.data, fileptr.size) < 0)
  465.       sys_error (filename);
  466. ***************
  467. *** 479,488 ****
  468. --- 512,558 ----
  469.     unsigned int size = 15 * BUFSIZ;
  470.     int ch;
  471.     register char *p;
  472. + #ifdef AMIGA
  473. +   char *in_prog;
  474. +   int in_prog_size;
  475. + #endif
  476.   
  477.     if (stdinptr.data != 0)
  478.       free (stdinptr.data);
  479.   
  480. + /* The following code had to be changed, because you can't assume, that
  481. +    xrealloc() always returns the original pointer. By the way: the original
  482. +    code violates the GNU coding standards!!! */
  483. + #ifdef AMIGA
  484. +   in_prog = (char *) xmalloc (size + 3);
  485. +   in_prog_size = 0;
  486. +   do
  487. +     {
  488. +       for (; in_prog_size < size; in_prog_size++)
  489. +     {
  490. +       ch = getc (stdin);
  491. +       if (ch == EOF)
  492. +         break;
  493. +       in_prog[in_prog_size] = ch;
  494. +     }
  495. +       if (ch != EOF)
  496. +     {
  497. +       size += (2 * BUFSIZ);
  498. +       in_prog = xrealloc (in_prog, size);
  499. +     }
  500. +     }
  501. +   while (ch != EOF);
  502. +   stdinptr.data = in_prog;
  503. +   stdinptr.size = in_prog_size;
  504. +   stdinptr.name = "Standard Input";
  505. +   stdinptr.data[stdinptr.size] = ' ';
  506. +   stdinptr.data[stdinptr.size + 1] = '\n';
  507. +   stdinptr.data[stdinptr.size + 2] = '\0';
  508. + #else
  509.     stdinptr.data = (char *) xmalloc (size + 3);
  510.     stdinptr.size = 0;
  511.     p = stdinptr.data;
  512. ***************
  513. *** 511,516 ****
  514. --- 581,587 ----
  515.     stdinptr.data[stdinptr.size] = ' ';
  516.     stdinptr.data[stdinptr.size + 1] = '\n';
  517.     stdinptr.data[stdinptr.size + 2] = '\0';
  518. + #endif
  519.   
  520.     return &stdinptr;
  521.   }
  522. diff -c -r ram:indent-1.4-orig/sys.h dh2:indent-1.4/sys.h
  523. *** ram:indent-1.4-orig/sys.h    Fri Jun 12 21:31:08 1992
  524. --- dh2:indent-1.4/sys.h    Wed Jun 24 20:34:05 1992
  525. ***************
  526. *** 8,13 ****
  527. --- 8,18 ----
  528.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  */
  529.   
  530.   #include <stdio.h>
  531. + #ifdef AMIGA
  532. + /* For malloc, etc... */
  533. + #include <stdlib.h>
  534. + #include <string.h>
  535. + #endif
  536.   
  537.   #ifdef DEBUG
  538.   extern int debug;
  539. ***************
  540. *** 23,30 ****
  541. --- 28,37 ----
  542.   extern struct file_buffer *read_file (), *read_stdin ();
  543.   
  544.   /* Standard memory allocation routines.  */
  545. + #ifndef AMIGA
  546.   char *malloc ();
  547.   char *realloc ();
  548. + #endif
  549.   
  550.   /* Similar, but abort with an error if out of memory (see globs.c).  */
  551.   char *xmalloc ();
  552. ***************
  553. *** 45,48 ****
  554. --- 52,61 ----
  555.   #define mymemcpy(to,from,len) bcopy ((from),(to),(len))
  556.   #endif
  557.   
  558. + #ifdef AMIGA
  559. + #define mymemcpy(from,to,len) (void) memcpy ((from),(to),(len))
  560. + #endif
  561. + #ifndef AMIGA
  562.   char *mymemcpy ();
  563. + #endif
  564.