/contrib/cvs/diff/io.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 711 lines · 496 code · 87 blank · 128 comment · 155 complexity · 75e01589d75114397582972e937acc96 MD5 · raw file

  1. /* File I/O for GNU DIFF.
  2. Copyright (C) 1988, 1989, 1992, 1993, 1994 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. /* Rotate a value n bits to the left. */
  15. #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
  16. #define ROL(v, n) ((v) << (n) | (v) >> (UINT_BIT - (n)))
  17. /* Given a hash value and a new character, return a new hash value. */
  18. #define HASH(h, c) ((c) + ROL (h, 7))
  19. /* Guess remaining number of lines from number N of lines so far,
  20. size S so far, and total size T. */
  21. #define GUESS_LINES(n,s,t) (((t) - (s)) / ((n) < 10 ? 32 : (s) / ((n)-1)) + 5)
  22. /* Type used for fast prefix comparison in find_identical_ends. */
  23. #ifndef word
  24. #define word int
  25. #endif
  26. /* Lines are put into equivalence classes (of lines that match in line_cmp).
  27. Each equivalence class is represented by one of these structures,
  28. but only while the classes are being computed.
  29. Afterward, each class is represented by a number. */
  30. struct equivclass
  31. {
  32. int next; /* Next item in this bucket. */
  33. unsigned hash; /* Hash of lines in this class. */
  34. char const *line; /* A line that fits this class. */
  35. size_t length; /* That line's length, not counting its newline. */
  36. };
  37. /* Hash-table: array of buckets, each being a chain of equivalence classes.
  38. buckets[-1] is reserved for incomplete lines. */
  39. static int *buckets;
  40. /* Number of buckets in the hash table array, not counting buckets[-1]. */
  41. static int nbuckets;
  42. /* Array in which the equivalence classes are allocated.
  43. The bucket-chains go through the elements in this array.
  44. The number of an equivalence class is its index in this array. */
  45. static struct equivclass *equivs;
  46. /* Index of first free element in the array `equivs'. */
  47. static int equivs_index;
  48. /* Number of elements allocated in the array `equivs'. */
  49. static int equivs_alloc;
  50. static void find_and_hash_each_line PARAMS((struct file_data *));
  51. static void find_identical_ends PARAMS((struct file_data[]));
  52. static void prepare_text_end PARAMS((struct file_data *));
  53. /* Check for binary files and compare them for exact identity. */
  54. /* Return 1 if BUF contains a non text character.
  55. SIZE is the number of characters in BUF. */
  56. #define binary_file_p(buf, size) (memchr (buf, '\0', size) != 0)
  57. /* Get ready to read the current file.
  58. Return nonzero if SKIP_TEST is zero,
  59. and if it appears to be a binary file. */
  60. int
  61. sip (current, skip_test)
  62. struct file_data *current;
  63. int skip_test;
  64. {
  65. /* If we have a nonexistent file at this stage, treat it as empty. */
  66. if (current->desc < 0)
  67. {
  68. /* Leave room for a sentinel. */
  69. current->bufsize = sizeof (word);
  70. current->buffer = xmalloc (current->bufsize);
  71. }
  72. else
  73. {
  74. current->bufsize = STAT_BLOCKSIZE (current->stat);
  75. current->buffer = xmalloc (current->bufsize);
  76. if (! skip_test)
  77. {
  78. /* Check first part of file to see if it's a binary file. */
  79. #if HAVE_SETMODE
  80. int oldmode = setmode (current->desc, O_BINARY);
  81. #endif
  82. ssize_t n = read (current->desc, current->buffer, current->bufsize);
  83. if (n == -1)
  84. pfatal_with_name (current->name);
  85. current->buffered_chars = n;
  86. #if HAVE_SETMODE
  87. if (oldmode != O_BINARY)
  88. {
  89. if (lseek (current->desc, - (off_t) n, SEEK_CUR) == -1)
  90. pfatal_with_name (current->name);
  91. setmode (current->desc, oldmode);
  92. current->buffered_chars = 0;
  93. }
  94. #endif
  95. return binary_file_p (current->buffer, n);
  96. }
  97. }
  98. current->buffered_chars = 0;
  99. return 0;
  100. }
  101. /* Slurp the rest of the current file completely into memory. */
  102. void
  103. slurp (current)
  104. struct file_data *current;
  105. {
  106. ssize_t cc;
  107. if (current->desc < 0)
  108. /* The file is nonexistent. */
  109. ;
  110. else if (S_ISREG (current->stat.st_mode))
  111. {
  112. /* It's a regular file; slurp in the rest all at once. */
  113. /* Get the size out of the stat block.
  114. Allocate enough room for appended newline and sentinel. */
  115. cc = current->stat.st_size + 1 + sizeof (word);
  116. if (current->bufsize < cc)
  117. {
  118. current->bufsize = cc;
  119. current->buffer = xrealloc (current->buffer, cc);
  120. }
  121. if (current->buffered_chars < current->stat.st_size)
  122. {
  123. cc = read (current->desc,
  124. current->buffer + current->buffered_chars,
  125. current->stat.st_size - current->buffered_chars);
  126. if (cc == -1)
  127. pfatal_with_name (current->name);
  128. current->buffered_chars += cc;
  129. }
  130. }
  131. /* It's not a regular file; read it, growing the buffer as needed. */
  132. else if (always_text_flag || current->buffered_chars != 0)
  133. {
  134. for (;;)
  135. {
  136. if (current->buffered_chars == current->bufsize)
  137. {
  138. current->bufsize = current->bufsize * 2;
  139. current->buffer = xrealloc (current->buffer, current->bufsize);
  140. }
  141. cc = read (current->desc,
  142. current->buffer + current->buffered_chars,
  143. current->bufsize - current->buffered_chars);
  144. if (cc == 0)
  145. break;
  146. if (cc == -1)
  147. pfatal_with_name (current->name);
  148. current->buffered_chars += cc;
  149. }
  150. /* Allocate just enough room for appended newline and sentinel. */
  151. current->bufsize = current->buffered_chars + 1 + sizeof (word);
  152. current->buffer = xrealloc (current->buffer, current->bufsize);
  153. }
  154. }
  155. /* Split the file into lines, simultaneously computing the equivalence class for
  156. each line. */
  157. static void
  158. find_and_hash_each_line (current)
  159. struct file_data *current;
  160. {
  161. unsigned h;
  162. unsigned char const *p = (unsigned char const *) current->prefix_end;
  163. unsigned char c;
  164. int i, *bucket;
  165. size_t length;
  166. /* Cache often-used quantities in local variables to help the compiler. */
  167. char const **linbuf = current->linbuf;
  168. int alloc_lines = current->alloc_lines;
  169. int line = 0;
  170. int linbuf_base = current->linbuf_base;
  171. int *cureqs = (int *) xmalloc (alloc_lines * sizeof (int));
  172. struct equivclass *eqs = equivs;
  173. int eqs_index = equivs_index;
  174. int eqs_alloc = equivs_alloc;
  175. char const *suffix_begin = current->suffix_begin;
  176. char const *bufend = current->buffer + current->buffered_chars;
  177. int use_line_cmp = ignore_some_line_changes;
  178. while ((char const *) p < suffix_begin)
  179. {
  180. char const *ip = (char const *) p;
  181. /* Compute the equivalence class for this line. */
  182. h = 0;
  183. /* Hash this line until we find a newline. */
  184. if (ignore_case_flag)
  185. {
  186. if (ignore_all_space_flag)
  187. while ((c = *p++) != '\n')
  188. {
  189. if (! ISSPACE (c))
  190. h = HASH (h, ISUPPER (c) ? tolower (c) : c);
  191. }
  192. else if (ignore_space_change_flag)
  193. while ((c = *p++) != '\n')
  194. {
  195. if (ISSPACE (c))
  196. {
  197. for (;;)
  198. {
  199. c = *p++;
  200. if (!ISSPACE (c))
  201. break;
  202. if (c == '\n')
  203. goto hashing_done;
  204. }
  205. h = HASH (h, ' ');
  206. }
  207. /* C is now the first non-space. */
  208. h = HASH (h, ISUPPER (c) ? tolower (c) : c);
  209. }
  210. else
  211. while ((c = *p++) != '\n')
  212. h = HASH (h, ISUPPER (c) ? tolower (c) : c);
  213. }
  214. else
  215. {
  216. if (ignore_all_space_flag)
  217. while ((c = *p++) != '\n')
  218. {
  219. if (! ISSPACE (c))
  220. h = HASH (h, c);
  221. }
  222. else if (ignore_space_change_flag)
  223. while ((c = *p++) != '\n')
  224. {
  225. if (ISSPACE (c))
  226. {
  227. for (;;)
  228. {
  229. c = *p++;
  230. if (!ISSPACE (c))
  231. break;
  232. if (c == '\n')
  233. goto hashing_done;
  234. }
  235. h = HASH (h, ' ');
  236. }
  237. /* C is now the first non-space. */
  238. h = HASH (h, c);
  239. }
  240. else
  241. while ((c = *p++) != '\n')
  242. h = HASH (h, c);
  243. }
  244. hashing_done:;
  245. bucket = &buckets[h % nbuckets];
  246. length = (char const *) p - ip - 1;
  247. if ((char const *) p == bufend
  248. && current->missing_newline
  249. && ROBUST_OUTPUT_STYLE (output_style))
  250. {
  251. /* This line is incomplete. If this is significant,
  252. put the line into bucket[-1]. */
  253. if (! (ignore_space_change_flag | ignore_all_space_flag))
  254. bucket = &buckets[-1];
  255. /* Omit the inserted newline when computing linbuf later. */
  256. p--;
  257. bufend = suffix_begin = (char const *) p;
  258. }
  259. for (i = *bucket; ; i = eqs[i].next)
  260. if (!i)
  261. {
  262. /* Create a new equivalence class in this bucket. */
  263. i = eqs_index++;
  264. if (i == eqs_alloc)
  265. eqs = (struct equivclass *)
  266. xrealloc (eqs, (eqs_alloc*=2) * sizeof(*eqs));
  267. eqs[i].next = *bucket;
  268. eqs[i].hash = h;
  269. eqs[i].line = ip;
  270. eqs[i].length = length;
  271. *bucket = i;
  272. break;
  273. }
  274. else if (eqs[i].hash == h)
  275. {
  276. char const *eqline = eqs[i].line;
  277. /* Reuse existing equivalence class if the lines are identical.
  278. This detects the common case of exact identity
  279. faster than complete comparison would. */
  280. if (eqs[i].length == length && memcmp (eqline, ip, length) == 0)
  281. break;
  282. /* Reuse existing class if line_cmp reports the lines equal. */
  283. if (use_line_cmp && line_cmp (eqline, ip) == 0)
  284. break;
  285. }
  286. /* Maybe increase the size of the line table. */
  287. if (line == alloc_lines)
  288. {
  289. /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
  290. alloc_lines = 2 * alloc_lines - linbuf_base;
  291. cureqs = (int *) xrealloc (cureqs, alloc_lines * sizeof (*cureqs));
  292. linbuf = (char const **) xrealloc (linbuf + linbuf_base,
  293. (alloc_lines - linbuf_base)
  294. * sizeof (*linbuf))
  295. - linbuf_base;
  296. }
  297. linbuf[line] = ip;
  298. cureqs[line] = i;
  299. ++line;
  300. }
  301. current->buffered_lines = line;
  302. for (i = 0; ; i++)
  303. {
  304. /* Record the line start for lines in the suffix that we care about.
  305. Record one more line start than lines,
  306. so that we can compute the length of any buffered line. */
  307. if (line == alloc_lines)
  308. {
  309. /* Double (alloc_lines - linbuf_base) by adding to alloc_lines. */
  310. alloc_lines = 2 * alloc_lines - linbuf_base;
  311. linbuf = (char const **) xrealloc (linbuf + linbuf_base,
  312. (alloc_lines - linbuf_base)
  313. * sizeof (*linbuf))
  314. - linbuf_base;
  315. }
  316. linbuf[line] = (char const *) p;
  317. if ((char const *) p == bufend)
  318. break;
  319. if (context <= i && no_diff_means_no_output)
  320. break;
  321. line++;
  322. while (*p++ != '\n')
  323. ;
  324. }
  325. /* Done with cache in local variables. */
  326. current->linbuf = linbuf;
  327. current->valid_lines = line;
  328. current->alloc_lines = alloc_lines;
  329. current->equivs = cureqs;
  330. equivs = eqs;
  331. equivs_alloc = eqs_alloc;
  332. equivs_index = eqs_index;
  333. }
  334. /* Prepare the end of the text. Make sure it's initialized.
  335. Make sure text ends in a newline,
  336. but remember that we had to add one. */
  337. static void
  338. prepare_text_end (current)
  339. struct file_data *current;
  340. {
  341. size_t buffered_chars = current->buffered_chars;
  342. char *p = current->buffer;
  343. if (buffered_chars == 0 || p[buffered_chars - 1] == '\n')
  344. current->missing_newline = 0;
  345. else
  346. {
  347. p[buffered_chars++] = '\n';
  348. current->buffered_chars = buffered_chars;
  349. current->missing_newline = 1;
  350. }
  351. /* Don't use uninitialized storage when planting or using sentinels. */
  352. if (p)
  353. bzero (p + buffered_chars, sizeof (word));
  354. }
  355. /* Given a vector of two file_data objects, find the identical
  356. prefixes and suffixes of each object. */
  357. static void
  358. find_identical_ends (filevec)
  359. struct file_data filevec[];
  360. {
  361. word *w0, *w1;
  362. char *p0, *p1, *buffer0, *buffer1;
  363. char const *end0, *beg0;
  364. char const **linbuf0, **linbuf1;
  365. int i, lines;
  366. size_t n0, n1, tem;
  367. int alloc_lines0, alloc_lines1;
  368. int buffered_prefix, prefix_count, prefix_mask;
  369. slurp (&filevec[0]);
  370. if (filevec[0].desc != filevec[1].desc)
  371. slurp (&filevec[1]);
  372. else
  373. {
  374. filevec[1].buffer = filevec[0].buffer;
  375. filevec[1].bufsize = filevec[0].bufsize;
  376. filevec[1].buffered_chars = filevec[0].buffered_chars;
  377. }
  378. for (i = 0; i < 2; i++)
  379. prepare_text_end (&filevec[i]);
  380. /* Find identical prefix. */
  381. p0 = buffer0 = filevec[0].buffer;
  382. p1 = buffer1 = filevec[1].buffer;
  383. n0 = filevec[0].buffered_chars;
  384. n1 = filevec[1].buffered_chars;
  385. if (p0 == p1)
  386. /* The buffers are the same; sentinels won't work. */
  387. p0 = p1 += n1;
  388. else
  389. {
  390. /* Insert end sentinels, in this case characters that are guaranteed
  391. to make the equality test false, and thus terminate the loop. */
  392. if (n0 < n1)
  393. p0[n0] = ~p1[n0];
  394. else
  395. p1[n1] = ~p0[n1];
  396. /* Loop until first mismatch, or to the sentinel characters. */
  397. /* Compare a word at a time for speed. */
  398. w0 = (word *) p0;
  399. w1 = (word *) p1;
  400. while (*w0++ == *w1++)
  401. ;
  402. --w0, --w1;
  403. /* Do the last few bytes of comparison a byte at a time. */
  404. p0 = (char *) w0;
  405. p1 = (char *) w1;
  406. while (*p0++ == *p1++)
  407. ;
  408. --p0, --p1;
  409. /* Don't mistakenly count missing newline as part of prefix. */
  410. if (ROBUST_OUTPUT_STYLE (output_style)
  411. && (buffer0 + n0 - filevec[0].missing_newline < p0)
  412. !=
  413. (buffer1 + n1 - filevec[1].missing_newline < p1))
  414. --p0, --p1;
  415. }
  416. /* Now P0 and P1 point at the first nonmatching characters. */
  417. /* Skip back to last line-beginning in the prefix,
  418. and then discard up to HORIZON_LINES lines from the prefix. */
  419. i = horizon_lines;
  420. while (p0 != buffer0 && (p0[-1] != '\n' || i--))
  421. --p0, --p1;
  422. /* Record the prefix. */
  423. filevec[0].prefix_end = p0;
  424. filevec[1].prefix_end = p1;
  425. /* Find identical suffix. */
  426. /* P0 and P1 point beyond the last chars not yet compared. */
  427. p0 = buffer0 + n0;
  428. p1 = buffer1 + n1;
  429. if (! ROBUST_OUTPUT_STYLE (output_style)
  430. || filevec[0].missing_newline == filevec[1].missing_newline)
  431. {
  432. end0 = p0; /* Addr of last char in file 0. */
  433. /* Get value of P0 at which we should stop scanning backward:
  434. this is when either P0 or P1 points just past the last char
  435. of the identical prefix. */
  436. beg0 = filevec[0].prefix_end + (n0 < n1 ? 0 : n0 - n1);
  437. /* Scan back until chars don't match or we reach that point. */
  438. for (; p0 != beg0; p0--, p1--)
  439. if (*p0 != *p1)
  440. {
  441. /* Point at the first char of the matching suffix. */
  442. beg0 = p0;
  443. break;
  444. }
  445. /* Are we at a line-beginning in both files? If not, add the rest of
  446. this line to the main body. Discard up to HORIZON_LINES lines from
  447. the identical suffix. Also, discard one extra line,
  448. because shift_boundaries may need it. */
  449. i = horizon_lines + !((buffer0 == p0 || p0[-1] == '\n')
  450. &&
  451. (buffer1 == p1 || p1[-1] == '\n'));
  452. while (i-- && p0 != end0)
  453. while (*p0++ != '\n')
  454. ;
  455. p1 += p0 - beg0;
  456. }
  457. /* Record the suffix. */
  458. filevec[0].suffix_begin = p0;
  459. filevec[1].suffix_begin = p1;
  460. /* Calculate number of lines of prefix to save.
  461. prefix_count == 0 means save the whole prefix;
  462. we need this with for options like -D that output the whole file.
  463. We also need it for options like -F that output some preceding line;
  464. at least we will need to find the last few lines,
  465. but since we don't know how many, it's easiest to find them all.
  466. Otherwise, prefix_count != 0. Save just prefix_count lines at start
  467. of the line buffer; they'll be moved to the proper location later.
  468. Handle 1 more line than the context says (because we count 1 too many),
  469. rounded up to the next power of 2 to speed index computation. */
  470. if (no_diff_means_no_output && ! function_regexp_list)
  471. {
  472. for (prefix_count = 1; prefix_count < context + 1; prefix_count *= 2)
  473. ;
  474. prefix_mask = prefix_count - 1;
  475. alloc_lines0
  476. = prefix_count
  477. + GUESS_LINES (0, 0, p0 - filevec[0].prefix_end)
  478. + context;
  479. }
  480. else
  481. {
  482. prefix_count = 0;
  483. prefix_mask = ~0;
  484. alloc_lines0 = GUESS_LINES (0, 0, n0);
  485. }
  486. lines = 0;
  487. linbuf0 = (char const **) xmalloc (alloc_lines0 * sizeof (*linbuf0));
  488. /* If the prefix is needed, find the prefix lines. */
  489. if (! (no_diff_means_no_output
  490. && filevec[0].prefix_end == p0
  491. && filevec[1].prefix_end == p1))
  492. {
  493. p0 = buffer0;
  494. end0 = filevec[0].prefix_end;
  495. while (p0 != end0)
  496. {
  497. int l = lines++ & prefix_mask;
  498. if (l == alloc_lines0)
  499. linbuf0 = (char const **) xrealloc (linbuf0, (alloc_lines0 *= 2)
  500. * sizeof(*linbuf0));
  501. linbuf0[l] = p0;
  502. while (*p0++ != '\n')
  503. ;
  504. }
  505. }
  506. buffered_prefix = prefix_count && context < lines ? context : lines;
  507. /* Allocate line buffer 1. */
  508. tem = prefix_count ? filevec[1].suffix_begin - buffer1 : n1;
  509. alloc_lines1
  510. = (buffered_prefix
  511. + GUESS_LINES (lines, filevec[1].prefix_end - buffer1, tem)
  512. + context);
  513. linbuf1 = (char const **) xmalloc (alloc_lines1 * sizeof (*linbuf1));
  514. if (buffered_prefix != lines)
  515. {
  516. /* Rotate prefix lines to proper location. */
  517. for (i = 0; i < buffered_prefix; i++)
  518. linbuf1[i] = linbuf0[(lines - context + i) & prefix_mask];
  519. for (i = 0; i < buffered_prefix; i++)
  520. linbuf0[i] = linbuf1[i];
  521. }
  522. /* Initialize line buffer 1 from line buffer 0. */
  523. for (i = 0; i < buffered_prefix; i++)
  524. linbuf1[i] = linbuf0[i] - buffer0 + buffer1;
  525. /* Record the line buffer, adjusted so that
  526. linbuf*[0] points at the first differing line. */
  527. filevec[0].linbuf = linbuf0 + buffered_prefix;
  528. filevec[1].linbuf = linbuf1 + buffered_prefix;
  529. filevec[0].linbuf_base = filevec[1].linbuf_base = - buffered_prefix;
  530. filevec[0].alloc_lines = alloc_lines0 - buffered_prefix;
  531. filevec[1].alloc_lines = alloc_lines1 - buffered_prefix;
  532. filevec[0].prefix_lines = filevec[1].prefix_lines = lines;
  533. }
  534. /* Largest primes less than some power of two, for nbuckets. Values range
  535. from useful to preposterous. If one of these numbers isn't prime
  536. after all, don't blame it on me, blame it on primes (6) . . . */
  537. static int const primes[] =
  538. {
  539. 509,
  540. 1021,
  541. 2039,
  542. 4093,
  543. 8191,
  544. 16381,
  545. 32749,
  546. #if 32767 < INT_MAX
  547. 65521,
  548. 131071,
  549. 262139,
  550. 524287,
  551. 1048573,
  552. 2097143,
  553. 4194301,
  554. 8388593,
  555. 16777213,
  556. 33554393,
  557. 67108859, /* Preposterously large . . . */
  558. 134217689,
  559. 268435399,
  560. 536870909,
  561. 1073741789,
  562. 2147483647,
  563. #endif
  564. 0
  565. };
  566. /* Given a vector of two file_data objects, read the file associated
  567. with each one, and build the table of equivalence classes.
  568. Return 1 if either file appears to be a binary file.
  569. If PRETEND_BINARY is nonzero, pretend they are binary regardless. */
  570. int
  571. read_files (filevec, pretend_binary)
  572. struct file_data filevec[];
  573. int pretend_binary;
  574. {
  575. int i;
  576. int skip_test = always_text_flag | pretend_binary;
  577. int appears_binary = pretend_binary | sip (&filevec[0], skip_test);
  578. if (filevec[0].desc != filevec[1].desc)
  579. appears_binary |= sip (&filevec[1], skip_test | appears_binary);
  580. else
  581. {
  582. filevec[1].buffer = filevec[0].buffer;
  583. filevec[1].bufsize = filevec[0].bufsize;
  584. filevec[1].buffered_chars = filevec[0].buffered_chars;
  585. }
  586. if (appears_binary)
  587. {
  588. #if HAVE_SETMODE
  589. setmode (filevec[0].desc, O_BINARY);
  590. setmode (filevec[1].desc, O_BINARY);
  591. #endif
  592. return 1;
  593. }
  594. find_identical_ends (filevec);
  595. equivs_alloc = filevec[0].alloc_lines + filevec[1].alloc_lines + 1;
  596. equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
  597. /* Equivalence class 0 is permanently safe for lines that were not
  598. hashed. Real equivalence classes start at 1. */
  599. equivs_index = 1;
  600. for (i = 0; primes[i] < equivs_alloc / 3; i++)
  601. if (! primes[i])
  602. abort ();
  603. nbuckets = primes[i];
  604. buckets = (int *) xmalloc ((nbuckets + 1) * sizeof (*buckets));
  605. bzero (buckets++, (nbuckets + 1) * sizeof (*buckets));
  606. for (i = 0; i < 2; i++)
  607. find_and_hash_each_line (&filevec[i]);
  608. filevec[0].equiv_max = filevec[1].equiv_max = equivs_index;
  609. free (equivs);
  610. free (buckets - 1);
  611. return 0;
  612. }