/contrib/cvs/diff/util.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 849 lines · 607 code · 107 blank · 135 comment · 142 complexity · b3add3c3ae6215eb840f95ad82c7de93 MD5 · raw file

  1. /* Support routines for GNU DIFF.
  2. Copyright (C) 1988, 1989, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of GNU DIFF.
  4. GNU DIFF is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU DIFF is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. */
  13. #include "diff.h"
  14. #if __STDC__
  15. #include <stdarg.h>
  16. #else
  17. #include <varargs.h>
  18. #endif
  19. #ifndef strerror
  20. extern char *strerror ();
  21. #endif
  22. /* Queue up one-line messages to be printed at the end,
  23. when -l is specified. Each message is recorded with a `struct msg'. */
  24. struct msg
  25. {
  26. struct msg *next;
  27. char const *format;
  28. char const *arg1;
  29. char const *arg2;
  30. char const *arg3;
  31. char const *arg4;
  32. };
  33. /* Head of the chain of queues messages. */
  34. static struct msg *msg_chain;
  35. /* Tail of the chain of queues messages. */
  36. static struct msg **msg_chain_end = &msg_chain;
  37. /* Use when a system call returns non-zero status.
  38. TEXT should normally be the file name. */
  39. void
  40. perror_with_name (text)
  41. char const *text;
  42. {
  43. int e = errno;
  44. if (callbacks && callbacks->error)
  45. (*callbacks->error) ("%s: %s", text, strerror (e));
  46. else
  47. {
  48. fprintf (stderr, "%s: ", diff_program_name);
  49. errno = e;
  50. perror (text);
  51. }
  52. }
  53. /* Use when a system call returns non-zero status and that is fatal. */
  54. void
  55. pfatal_with_name (text)
  56. char const *text;
  57. {
  58. int e = errno;
  59. print_message_queue ();
  60. if (callbacks && callbacks->error)
  61. (*callbacks->error) ("%s: %s", text, strerror (e));
  62. else
  63. {
  64. fprintf (stderr, "%s: ", diff_program_name);
  65. errno = e;
  66. perror (text);
  67. }
  68. DIFF_ABORT (2);
  69. }
  70. /* Print an error message from the format-string FORMAT
  71. with args ARG1 and ARG2. */
  72. void
  73. diff_error (format, arg, arg1)
  74. char const *format, *arg, *arg1;
  75. {
  76. if (callbacks && callbacks->error)
  77. (*callbacks->error) (format, arg, arg1);
  78. else
  79. {
  80. fprintf (stderr, "%s: ", diff_program_name);
  81. fprintf (stderr, format, arg, arg1);
  82. fprintf (stderr, "\n");
  83. }
  84. }
  85. /* Print an error message containing the string TEXT, then exit. */
  86. void
  87. fatal (m)
  88. char const *m;
  89. {
  90. print_message_queue ();
  91. diff_error ("%s", m, 0);
  92. DIFF_ABORT (2);
  93. }
  94. /* Like printf, except if -l in effect then save the message and print later.
  95. This is used for things like "binary files differ" and "Only in ...". */
  96. void
  97. message (format, arg1, arg2)
  98. char const *format, *arg1, *arg2;
  99. {
  100. message5 (format, arg1, arg2, 0, 0);
  101. }
  102. void
  103. message5 (format, arg1, arg2, arg3, arg4)
  104. char const *format, *arg1, *arg2, *arg3, *arg4;
  105. {
  106. if (paginate_flag)
  107. {
  108. struct msg *new = (struct msg *) xmalloc (sizeof (struct msg));
  109. new->format = format;
  110. new->arg1 = concat (arg1, "", "");
  111. new->arg2 = concat (arg2, "", "");
  112. new->arg3 = arg3 ? concat (arg3, "", "") : 0;
  113. new->arg4 = arg4 ? concat (arg4, "", "") : 0;
  114. new->next = 0;
  115. *msg_chain_end = new;
  116. msg_chain_end = &new->next;
  117. }
  118. else
  119. {
  120. if (sdiff_help_sdiff)
  121. write_output (" ", 1);
  122. printf_output (format, arg1, arg2, arg3, arg4);
  123. }
  124. }
  125. /* Output all the messages that were saved up by calls to `message'. */
  126. void
  127. print_message_queue ()
  128. {
  129. struct msg *m;
  130. for (m = msg_chain; m; m = m->next)
  131. printf_output (m->format, m->arg1, m->arg2, m->arg3, m->arg4);
  132. }
  133. /* Call before outputting the results of comparing files NAME0 and NAME1
  134. to set up OUTFILE, the stdio stream for the output to go to.
  135. Usually, OUTFILE is just stdout. But when -l was specified
  136. we fork off a `pr' and make OUTFILE a pipe to it.
  137. `pr' then outputs to our stdout. */
  138. static char const *current_name0;
  139. static char const *current_name1;
  140. static int current_depth;
  141. static int output_in_progress = 0;
  142. void
  143. setup_output (name0, name1, depth)
  144. char const *name0, *name1;
  145. int depth;
  146. {
  147. current_name0 = name0;
  148. current_name1 = name1;
  149. current_depth = depth;
  150. }
  151. #if HAVE_FORK && defined (PR_PROGRAM)
  152. static pid_t pr_pid;
  153. #endif
  154. void
  155. begin_output ()
  156. {
  157. char *name;
  158. if (output_in_progress)
  159. return;
  160. output_in_progress = 1;
  161. /* Construct the header of this piece of diff. */
  162. name = xmalloc (strlen (current_name0) + strlen (current_name1)
  163. + strlen (switch_string) + 7);
  164. /* Posix.2 section 4.17.6.1.1 specifies this format. But there is a
  165. bug in the first printing (IEEE Std 1003.2-1992 p 251 l 3304):
  166. it says that we must print only the last component of the pathnames.
  167. This requirement is silly and does not match historical practice. */
  168. sprintf (name, "diff%s %s %s", switch_string, current_name0, current_name1);
  169. if (paginate_flag && callbacks && callbacks->write_output)
  170. fatal ("can't paginate when using library callbacks");
  171. if (paginate_flag)
  172. {
  173. /* Make OUTFILE a pipe to a subsidiary `pr'. */
  174. #ifdef PR_PROGRAM
  175. # if HAVE_FORK
  176. int pipes[2];
  177. if (pipe (pipes) != 0)
  178. pfatal_with_name ("pipe");
  179. fflush (stdout);
  180. pr_pid = vfork ();
  181. if (pr_pid < 0)
  182. pfatal_with_name ("vfork");
  183. if (pr_pid == 0)
  184. {
  185. close (pipes[1]);
  186. if (pipes[0] != STDIN_FILENO)
  187. {
  188. if (dup2 (pipes[0], STDIN_FILENO) < 0)
  189. pfatal_with_name ("dup2");
  190. close (pipes[0]);
  191. }
  192. execl (PR_PROGRAM, PR_PROGRAM, "-f", "-h", name, 0);
  193. pfatal_with_name (PR_PROGRAM);
  194. }
  195. else
  196. {
  197. close (pipes[0]);
  198. outfile = fdopen (pipes[1], "w");
  199. if (!outfile)
  200. pfatal_with_name ("fdopen");
  201. }
  202. # else /* ! HAVE_FORK */
  203. char *command = xmalloc (4 * strlen (name) + strlen (PR_PROGRAM) + 10);
  204. char *p;
  205. char const *a = name;
  206. sprintf (command, "%s -f -h ", PR_PROGRAM);
  207. p = command + strlen (command);
  208. SYSTEM_QUOTE_ARG (p, a);
  209. *p = 0;
  210. outfile = popen (command, "w");
  211. if (!outfile)
  212. pfatal_with_name (command);
  213. free (command);
  214. # endif /* ! HAVE_FORK */
  215. #else
  216. fatal ("This port does not support the --paginate option to diff.");
  217. #endif
  218. }
  219. else
  220. {
  221. /* If -l was not specified, output the diff straight to `stdout'. */
  222. /* If handling multiple files (because scanning a directory),
  223. print which files the following output is about. */
  224. if (current_depth > 0)
  225. printf_output ("%s\n", name);
  226. }
  227. free (name);
  228. /* A special header is needed at the beginning of context output. */
  229. switch (output_style)
  230. {
  231. case OUTPUT_CONTEXT:
  232. print_context_header (files, 0);
  233. break;
  234. case OUTPUT_UNIFIED:
  235. print_context_header (files, 1);
  236. break;
  237. default:
  238. break;
  239. }
  240. }
  241. /* Call after the end of output of diffs for one file.
  242. If -l was given, close OUTFILE and get rid of the `pr' subfork. */
  243. void
  244. finish_output ()
  245. {
  246. if (paginate_flag && outfile != 0 && outfile != stdout)
  247. {
  248. #ifdef PR_PROGRAM
  249. int wstatus, w;
  250. if (ferror (outfile))
  251. fatal ("write error");
  252. # if ! HAVE_FORK
  253. wstatus = pclose (outfile);
  254. # else /* HAVE_FORK */
  255. if (fclose (outfile) != 0)
  256. pfatal_with_name ("write error");
  257. while ((w = waitpid (pr_pid, &wstatus, 0)) < 0 && errno == EINTR)
  258. ;
  259. if (w < 0)
  260. pfatal_with_name ("waitpid");
  261. # endif /* HAVE_FORK */
  262. if (wstatus != 0)
  263. fatal ("subsidiary pr failed");
  264. #else
  265. fatal ("internal error in finish_output");
  266. #endif
  267. }
  268. output_in_progress = 0;
  269. }
  270. /* Write something to the output file. */
  271. void
  272. write_output (text, len)
  273. char const *text;
  274. size_t len;
  275. {
  276. if (callbacks && callbacks->write_output)
  277. (*callbacks->write_output) (text, len);
  278. else if (len == 1)
  279. putc (*text, outfile);
  280. else
  281. fwrite (text, sizeof (char), len, outfile);
  282. }
  283. /* Printf something to the output file. */
  284. #if __STDC__
  285. #define VA_START(args, lastarg) va_start(args, lastarg)
  286. #else /* ! __STDC__ */
  287. #define VA_START(args, lastarg) va_start(args)
  288. #endif /* __STDC__ */
  289. void
  290. #if __STDC__
  291. printf_output (const char *format, ...)
  292. #else
  293. printf_output (format, va_alist)
  294. char const *format;
  295. va_dcl
  296. #endif
  297. {
  298. va_list args;
  299. VA_START (args, format);
  300. if (callbacks && callbacks->write_output)
  301. {
  302. /* We implement our own limited printf-like functionality (%s, %d,
  303. and %c only). Callers who want something fancier can use
  304. sprintf. */
  305. const char *p = format;
  306. char *q;
  307. char *str;
  308. int num;
  309. int ch;
  310. char buf[100];
  311. while ((q = strchr (p, '%')) != NULL)
  312. {
  313. static const char msg[] =
  314. "\ninternal error: bad % in printf_output\n";
  315. (*callbacks->write_output) (p, q - p);
  316. switch (q[1])
  317. {
  318. case 's':
  319. str = va_arg (args, char *);
  320. (*callbacks->write_output) (str, strlen (str));
  321. break;
  322. case 'd':
  323. num = va_arg (args, int);
  324. sprintf (buf, "%d", num);
  325. (*callbacks->write_output) (buf, strlen (buf));
  326. break;
  327. case 'c':
  328. ch = va_arg (args, int);
  329. buf[0] = ch;
  330. (*callbacks->write_output) (buf, 1);
  331. break;
  332. default:
  333. (*callbacks->write_output) (msg, sizeof (msg) - 1);
  334. /* Don't just keep going, because q + 1 might point to the
  335. terminating '\0'. */
  336. goto out;
  337. }
  338. p = q + 2;
  339. }
  340. (*callbacks->write_output) (p, strlen (p));
  341. }
  342. else
  343. vfprintf (outfile, format, args);
  344. out:
  345. va_end (args);
  346. }
  347. /* Flush the output file. */
  348. void
  349. flush_output ()
  350. {
  351. if (callbacks && callbacks->flush_output)
  352. (*callbacks->flush_output) ();
  353. else
  354. fflush (outfile);
  355. }
  356. /* Compare two lines (typically one from each input file)
  357. according to the command line options.
  358. For efficiency, this is invoked only when the lines do not match exactly
  359. but an option like -i might cause us to ignore the difference.
  360. Return nonzero if the lines differ. */
  361. int
  362. line_cmp (s1, s2)
  363. char const *s1, *s2;
  364. {
  365. register unsigned char const *t1 = (unsigned char const *) s1;
  366. register unsigned char const *t2 = (unsigned char const *) s2;
  367. while (1)
  368. {
  369. register unsigned char c1 = *t1++;
  370. register unsigned char c2 = *t2++;
  371. /* Test for exact char equality first, since it's a common case. */
  372. if (c1 != c2)
  373. {
  374. /* Ignore horizontal white space if -b or -w is specified. */
  375. if (ignore_all_space_flag)
  376. {
  377. /* For -w, just skip past any white space. */
  378. while (ISSPACE (c1) && c1 != '\n') c1 = *t1++;
  379. while (ISSPACE (c2) && c2 != '\n') c2 = *t2++;
  380. }
  381. else if (ignore_space_change_flag)
  382. {
  383. /* For -b, advance past any sequence of white space in line 1
  384. and consider it just one Space, or nothing at all
  385. if it is at the end of the line. */
  386. if (ISSPACE (c1))
  387. {
  388. while (c1 != '\n')
  389. {
  390. c1 = *t1++;
  391. if (! ISSPACE (c1))
  392. {
  393. --t1;
  394. c1 = ' ';
  395. break;
  396. }
  397. }
  398. }
  399. /* Likewise for line 2. */
  400. if (ISSPACE (c2))
  401. {
  402. while (c2 != '\n')
  403. {
  404. c2 = *t2++;
  405. if (! ISSPACE (c2))
  406. {
  407. --t2;
  408. c2 = ' ';
  409. break;
  410. }
  411. }
  412. }
  413. if (c1 != c2)
  414. {
  415. /* If we went too far when doing the simple test
  416. for equality, go back to the first non-white-space
  417. character in both sides and try again. */
  418. if (c2 == ' ' && c1 != '\n'
  419. && (unsigned char const *) s1 + 1 < t1
  420. && ISSPACE(t1[-2]))
  421. {
  422. --t1;
  423. continue;
  424. }
  425. if (c1 == ' ' && c2 != '\n'
  426. && (unsigned char const *) s2 + 1 < t2
  427. && ISSPACE(t2[-2]))
  428. {
  429. --t2;
  430. continue;
  431. }
  432. }
  433. }
  434. /* Lowercase all letters if -i is specified. */
  435. if (ignore_case_flag)
  436. {
  437. if (ISUPPER (c1))
  438. c1 = tolower (c1);
  439. if (ISUPPER (c2))
  440. c2 = tolower (c2);
  441. }
  442. if (c1 != c2)
  443. break;
  444. }
  445. if (c1 == '\n')
  446. return 0;
  447. }
  448. return (1);
  449. }
  450. /* Find the consecutive changes at the start of the script START.
  451. Return the last link before the first gap. */
  452. struct change *
  453. find_change (start)
  454. struct change *start;
  455. {
  456. return start;
  457. }
  458. struct change *
  459. find_reverse_change (start)
  460. struct change *start;
  461. {
  462. return start;
  463. }
  464. /* Divide SCRIPT into pieces by calling HUNKFUN and
  465. print each piece with PRINTFUN.
  466. Both functions take one arg, an edit script.
  467. HUNKFUN is called with the tail of the script
  468. and returns the last link that belongs together with the start
  469. of the tail.
  470. PRINTFUN takes a subscript which belongs together (with a null
  471. link at the end) and prints it. */
  472. void
  473. print_script (script, hunkfun, printfun)
  474. struct change *script;
  475. struct change * (*hunkfun) PARAMS((struct change *));
  476. void (*printfun) PARAMS((struct change *));
  477. {
  478. struct change *next = script;
  479. while (next)
  480. {
  481. struct change *this, *end;
  482. /* Find a set of changes that belong together. */
  483. this = next;
  484. end = (*hunkfun) (next);
  485. /* Disconnect them from the rest of the changes,
  486. making them a hunk, and remember the rest for next iteration. */
  487. next = end->link;
  488. end->link = 0;
  489. #ifdef DEBUG
  490. debug_script (this);
  491. #endif
  492. /* Print this hunk. */
  493. (*printfun) (this);
  494. /* Reconnect the script so it will all be freed properly. */
  495. end->link = next;
  496. }
  497. }
  498. /* Print the text of a single line LINE,
  499. flagging it with the characters in LINE_FLAG (which say whether
  500. the line is inserted, deleted, changed, etc.). */
  501. void
  502. print_1_line (line_flag, line)
  503. char const *line_flag;
  504. char const * const *line;
  505. {
  506. char const *text = line[0], *limit = line[1]; /* Help the compiler. */
  507. char const *flag_format = 0;
  508. /* If -T was specified, use a Tab between the line-flag and the text.
  509. Otherwise use a Space (as Unix diff does).
  510. Print neither space nor tab if line-flags are empty. */
  511. if (line_flag && *line_flag)
  512. {
  513. flag_format = tab_align_flag ? "%s\t" : "%s ";
  514. printf_output (flag_format, line_flag);
  515. }
  516. output_1_line (text, limit, flag_format, line_flag);
  517. if ((!line_flag || line_flag[0]) && limit[-1] != '\n')
  518. printf_output ("\n\\ No newline at end of file\n");
  519. }
  520. /* Output a line from TEXT up to LIMIT. Without -t, output verbatim.
  521. With -t, expand white space characters to spaces, and if FLAG_FORMAT
  522. is nonzero, output it with argument LINE_FLAG after every
  523. internal carriage return, so that tab stops continue to line up. */
  524. void
  525. output_1_line (text, limit, flag_format, line_flag)
  526. char const *text, *limit, *flag_format, *line_flag;
  527. {
  528. if (!tab_expand_flag)
  529. write_output (text, limit - text);
  530. else
  531. {
  532. register unsigned char c;
  533. register char const *t = text;
  534. register unsigned column = 0;
  535. /* CC is used to avoid taking the address of the register
  536. variable C. */
  537. char cc;
  538. while (t < limit)
  539. switch ((c = *t++))
  540. {
  541. case '\t':
  542. {
  543. unsigned spaces = TAB_WIDTH - column % TAB_WIDTH;
  544. column += spaces;
  545. do
  546. write_output (" ", 1);
  547. while (--spaces);
  548. }
  549. break;
  550. case '\r':
  551. write_output ("\r", 1);
  552. if (flag_format && t < limit && *t != '\n')
  553. printf_output (flag_format, line_flag);
  554. column = 0;
  555. break;
  556. case '\b':
  557. if (column == 0)
  558. continue;
  559. column--;
  560. write_output ("\b", 1);
  561. break;
  562. default:
  563. if (ISPRINT (c))
  564. column++;
  565. cc = c;
  566. write_output (&cc, 1);
  567. break;
  568. }
  569. }
  570. }
  571. int
  572. change_letter (inserts, deletes)
  573. int inserts, deletes;
  574. {
  575. if (!inserts)
  576. return 'd';
  577. else if (!deletes)
  578. return 'a';
  579. else
  580. return 'c';
  581. }
  582. /* Translate an internal line number (an index into diff's table of lines)
  583. into an actual line number in the input file.
  584. The internal line number is LNUM. FILE points to the data on the file.
  585. Internal line numbers count from 0 starting after the prefix.
  586. Actual line numbers count from 1 within the entire file. */
  587. int
  588. translate_line_number (file, lnum)
  589. struct file_data const *file;
  590. int lnum;
  591. {
  592. return lnum + file->prefix_lines + 1;
  593. }
  594. void
  595. translate_range (file, a, b, aptr, bptr)
  596. struct file_data const *file;
  597. int a, b;
  598. int *aptr, *bptr;
  599. {
  600. *aptr = translate_line_number (file, a - 1) + 1;
  601. *bptr = translate_line_number (file, b + 1) - 1;
  602. }
  603. /* Print a pair of line numbers with SEPCHAR, translated for file FILE.
  604. If the two numbers are identical, print just one number.
  605. Args A and B are internal line numbers.
  606. We print the translated (real) line numbers. */
  607. void
  608. print_number_range (sepchar, file, a, b)
  609. int sepchar;
  610. struct file_data *file;
  611. int a, b;
  612. {
  613. int trans_a, trans_b;
  614. translate_range (file, a, b, &trans_a, &trans_b);
  615. /* Note: we can have B < A in the case of a range of no lines.
  616. In this case, we should print the line number before the range,
  617. which is B. */
  618. if (trans_b > trans_a)
  619. printf_output ("%d%c%d", trans_a, sepchar, trans_b);
  620. else
  621. printf_output ("%d", trans_b);
  622. }
  623. /* Look at a hunk of edit script and report the range of lines in each file
  624. that it applies to. HUNK is the start of the hunk, which is a chain
  625. of `struct change'. The first and last line numbers of file 0 are stored in
  626. *FIRST0 and *LAST0, and likewise for file 1 in *FIRST1 and *LAST1.
  627. Note that these are internal line numbers that count from 0.
  628. If no lines from file 0 are deleted, then FIRST0 is LAST0+1.
  629. Also set *DELETES nonzero if any lines of file 0 are deleted
  630. and set *INSERTS nonzero if any lines of file 1 are inserted.
  631. If only ignorable lines are inserted or deleted, both are
  632. set to 0. */
  633. void
  634. analyze_hunk (hunk, first0, last0, first1, last1, deletes, inserts)
  635. struct change *hunk;
  636. int *first0, *last0, *first1, *last1;
  637. int *deletes, *inserts;
  638. {
  639. int l0, l1, show_from, show_to;
  640. int i;
  641. int trivial = ignore_blank_lines_flag || ignore_regexp_list;
  642. struct change *next;
  643. show_from = show_to = 0;
  644. *first0 = hunk->line0;
  645. *first1 = hunk->line1;
  646. next = hunk;
  647. do
  648. {
  649. l0 = next->line0 + next->deleted - 1;
  650. l1 = next->line1 + next->inserted - 1;
  651. show_from += next->deleted;
  652. show_to += next->inserted;
  653. for (i = next->line0; i <= l0 && trivial; i++)
  654. if (!ignore_blank_lines_flag || files[0].linbuf[i][0] != '\n')
  655. {
  656. struct regexp_list *r;
  657. char const *line = files[0].linbuf[i];
  658. int len = files[0].linbuf[i + 1] - line;
  659. for (r = ignore_regexp_list; r; r = r->next)
  660. if (0 <= re_search (&r->buf, line, len, 0, len, 0))
  661. break; /* Found a match. Ignore this line. */
  662. /* If we got all the way through the regexp list without
  663. finding a match, then it's nontrivial. */
  664. if (!r)
  665. trivial = 0;
  666. }
  667. for (i = next->line1; i <= l1 && trivial; i++)
  668. if (!ignore_blank_lines_flag || files[1].linbuf[i][0] != '\n')
  669. {
  670. struct regexp_list *r;
  671. char const *line = files[1].linbuf[i];
  672. int len = files[1].linbuf[i + 1] - line;
  673. for (r = ignore_regexp_list; r; r = r->next)
  674. if (0 <= re_search (&r->buf, line, len, 0, len, 0))
  675. break; /* Found a match. Ignore this line. */
  676. /* If we got all the way through the regexp list without
  677. finding a match, then it's nontrivial. */
  678. if (!r)
  679. trivial = 0;
  680. }
  681. }
  682. while ((next = next->link) != 0);
  683. *last0 = l0;
  684. *last1 = l1;
  685. /* If all inserted or deleted lines are ignorable,
  686. tell the caller to ignore this hunk. */
  687. if (trivial)
  688. show_from = show_to = 0;
  689. *deletes = show_from;
  690. *inserts = show_to;
  691. }
  692. /* Concatenate three strings, returning a newly malloc'd string. */
  693. char *
  694. concat (s1, s2, s3)
  695. char const *s1, *s2, *s3;
  696. {
  697. size_t len = strlen (s1) + strlen (s2) + strlen (s3);
  698. char *new = xmalloc (len + 1);
  699. sprintf (new, "%s%s%s", s1, s2, s3);
  700. return new;
  701. }
  702. /* Yield the newly malloc'd pathname
  703. of the file in DIR whose filename is FILE. */
  704. char *
  705. dir_file_pathname (dir, file)
  706. char const *dir, *file;
  707. {
  708. char const *p = filename_lastdirchar (dir);
  709. return concat (dir, "/" + (p && !p[1]), file);
  710. }
  711. void
  712. debug_script (sp)
  713. struct change *sp;
  714. {
  715. fflush (stdout);
  716. for (; sp; sp = sp->link)
  717. fprintf (stderr, "%3d %3d delete %d insert %d\n",
  718. sp->line0, sp->line1, sp->deleted, sp->inserted);
  719. fflush (stderr);
  720. }