files.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. /* files.c -- file-related functions for makeinfo.
  2. $Id: files.c,v 1.8 2007-07-01 21:20:32 karl Exp $
  3. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
  4. Free Software Foundation, Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "system.h"
  16. #include "files.h"
  17. #include "html.h"
  18. #include "index.h"
  19. #include "macro.h"
  20. #include "makeinfo.h"
  21. #include "node.h"
  22. FSTACK *filestack = NULL;
  23. static int node_filename_stack_index = 0;
  24. static int node_filename_stack_size = 0;
  25. static char **node_filename_stack = NULL;
  26. /* Looking for include files. */
  27. /* Given a string containing units of information separated by colons,
  28. return the next one pointed to by INDEX, or NULL if there are no more.
  29. Advance INDEX to the character after the colon. */
  30. static char *
  31. extract_colon_unit (char *string, int *index)
  32. {
  33. int start;
  34. int path_sep_char = PATH_SEP[0];
  35. int i = *index;
  36. if (!string || (i >= strlen (string)))
  37. return NULL;
  38. /* Each call to this routine leaves the index pointing at a colon if
  39. there is more to the path. If i > 0, then increment past the
  40. `:'. If i == 0, then the path has a leading colon. Trailing colons
  41. are handled OK by the `else' part of the if statement; an empty
  42. string is returned in that case. */
  43. if (i && string[i] == path_sep_char)
  44. i++;
  45. start = i;
  46. while (string[i] && string[i] != path_sep_char) i++;
  47. *index = i;
  48. if (i == start)
  49. {
  50. if (string[i])
  51. (*index)++;
  52. /* Return "" in the case of a trailing `:'. */
  53. return xstrdup ("");
  54. }
  55. else
  56. {
  57. char *value;
  58. value = xmalloc (1 + (i - start));
  59. memcpy (value, &string[start], (i - start));
  60. value [i - start] = 0;
  61. return value;
  62. }
  63. }
  64. /* Return the full pathname for FILENAME by searching along PATH.
  65. When found, return the stat () info for FILENAME in FINFO.
  66. If PATH is NULL, only the current directory is searched.
  67. If the file could not be found, return a NULL pointer. */
  68. char *
  69. get_file_info_in_path (char *filename, char *path, struct stat *finfo)
  70. {
  71. char *dir;
  72. int result, index = 0;
  73. if (path == NULL)
  74. path = ".";
  75. /* Handle absolute pathnames. */
  76. if (IS_ABSOLUTE (filename)
  77. || (*filename == '.'
  78. && (IS_SLASH (filename[1])
  79. || (filename[1] == '.' && IS_SLASH (filename[2])))))
  80. {
  81. if (stat (filename, finfo) == 0)
  82. return xstrdup (filename);
  83. else
  84. return NULL;
  85. }
  86. while ((dir = extract_colon_unit (path, &index)))
  87. {
  88. char *fullpath;
  89. if (!*dir)
  90. {
  91. free (dir);
  92. dir = xstrdup (".");
  93. }
  94. fullpath = xmalloc (2 + strlen (dir) + strlen (filename));
  95. sprintf (fullpath, "%s/%s", dir, filename);
  96. free (dir);
  97. result = stat (fullpath, finfo);
  98. if (result == 0)
  99. return fullpath;
  100. else
  101. free (fullpath);
  102. }
  103. return NULL;
  104. }
  105. /* Prepend and append new paths to include_files_path. */
  106. void
  107. prepend_to_include_path (char *path)
  108. {
  109. if (!include_files_path)
  110. {
  111. include_files_path = xstrdup (path);
  112. include_files_path = xrealloc (include_files_path,
  113. strlen (include_files_path) + 3); /* 3 for ":.\0" */
  114. strcat (strcat (include_files_path, PATH_SEP), ".");
  115. }
  116. else
  117. {
  118. char *tmp = xstrdup (include_files_path);
  119. include_files_path = xrealloc (include_files_path,
  120. strlen (include_files_path) + strlen (path) + 2); /* 2 for ":\0" */
  121. strcpy (include_files_path, path);
  122. strcat (include_files_path, PATH_SEP);
  123. strcat (include_files_path, tmp);
  124. free (tmp);
  125. }
  126. }
  127. void
  128. append_to_include_path (char *path)
  129. {
  130. if (!include_files_path)
  131. include_files_path = xstrdup (".");
  132. include_files_path = (char *) xrealloc (include_files_path,
  133. 2 + strlen (include_files_path) + strlen (path));
  134. strcat (include_files_path, PATH_SEP);
  135. strcat (include_files_path, path);
  136. }
  137. /* Remove the first path from the include_files_path. */
  138. void
  139. pop_path_from_include_path (void)
  140. {
  141. int i = 0;
  142. char *tmp;
  143. if (include_files_path)
  144. for (i = 0; i < strlen (include_files_path)
  145. && include_files_path[i] != ':'; i++);
  146. /* Advance include_files_path to the next char from ':' */
  147. tmp = (char *) xmalloc (strlen (include_files_path) - i);
  148. strcpy (tmp, (char *) include_files_path + i + 1);
  149. free (include_files_path);
  150. include_files_path = tmp;
  151. }
  152. /* Find and load the file named FILENAME. Return a pointer to
  153. the loaded file, or NULL if it can't be loaded. If USE_PATH is zero,
  154. just look for the given file (this is used in handle_delayed_writes),
  155. else search along include_files_path. */
  156. char *
  157. find_and_load (char *filename, int use_path)
  158. {
  159. struct stat fileinfo;
  160. long file_size;
  161. int file = -1, count = 0;
  162. char *fullpath, *result;
  163. int n, bytes_to_read;
  164. result = fullpath = NULL;
  165. fullpath
  166. = get_file_info_in_path (filename, use_path ? include_files_path : NULL,
  167. &fileinfo);
  168. if (!fullpath)
  169. goto error_exit;
  170. filename = fullpath;
  171. file_size = (long) fileinfo.st_size;
  172. file = open (filename, O_RDONLY);
  173. if (file < 0)
  174. goto error_exit;
  175. /* Load the file, with enough room for a newline and a null. */
  176. result = xmalloc (file_size + 2);
  177. /* VMS stat lies about the st_size value. The actual number of
  178. readable bytes is always less than this value. The arcane
  179. mysteries of VMS/RMS are too much to probe, so this hack
  180. suffices to make things work. It's also needed on Cygwin. And so
  181. we might as well use it everywhere. */
  182. bytes_to_read = file_size;
  183. while ((n = read (file, result + count, bytes_to_read)) > 0)
  184. {
  185. count += n;
  186. bytes_to_read -= n;
  187. }
  188. if (0 < count && count < file_size)
  189. result = xrealloc (result, count + 2); /* why waste the slack? */
  190. else if (n == -1)
  191. error_exit:
  192. {
  193. if (result)
  194. free (result);
  195. if (fullpath)
  196. free (fullpath);
  197. if (file != -1)
  198. close (file);
  199. return NULL;
  200. }
  201. close (file);
  202. /* Set the globals to the new file. */
  203. input_text = result;
  204. input_text_length = count;
  205. input_filename = fullpath;
  206. node_filename = xstrdup (fullpath);
  207. input_text_offset = 0;
  208. line_number = 1;
  209. /* Not strictly necessary. This magic prevents read_token () from doing
  210. extra unnecessary work each time it is called (that is a lot of times).
  211. INPUT_TEXT_LENGTH is one past the actual end of the text. */
  212. input_text[input_text_length] = '\n';
  213. /* This, on the other hand, is always necessary. */
  214. input_text[input_text_length+1] = 0;
  215. return result;
  216. }
  217. /* Pushing and popping files. */
  218. static void
  219. push_node_filename (void)
  220. {
  221. if (node_filename_stack_index + 1 > node_filename_stack_size)
  222. node_filename_stack = xrealloc
  223. (node_filename_stack, (node_filename_stack_size += 10) * sizeof (char *));
  224. node_filename_stack[node_filename_stack_index] = node_filename;
  225. node_filename_stack_index++;
  226. }
  227. static void
  228. pop_node_filename (void)
  229. {
  230. node_filename = node_filename_stack[--node_filename_stack_index];
  231. }
  232. /* Save the state of the current input file. */
  233. void
  234. pushfile (void)
  235. {
  236. FSTACK *newstack = xmalloc (sizeof (FSTACK));
  237. newstack->filename = input_filename;
  238. newstack->text = input_text;
  239. newstack->size = input_text_length;
  240. newstack->offset = input_text_offset;
  241. newstack->line_number = line_number;
  242. newstack->next = filestack;
  243. filestack = newstack;
  244. push_node_filename ();
  245. }
  246. /* Make the current file globals be what is on top of the file stack. */
  247. void
  248. popfile (void)
  249. {
  250. FSTACK *tos = filestack;
  251. if (!tos)
  252. abort (); /* My fault. I wonder what I did? */
  253. if (macro_expansion_output_stream)
  254. {
  255. maybe_write_itext (input_text, input_text_offset);
  256. forget_itext (input_text);
  257. }
  258. /* Pop the stack. */
  259. filestack = filestack->next;
  260. /* Make sure that commands with braces have been satisfied. */
  261. if (!executing_string && !me_executing_string)
  262. discard_braces ();
  263. /* Get the top of the stack into the globals. */
  264. input_filename = tos->filename;
  265. input_text = tos->text;
  266. input_text_length = tos->size;
  267. input_text_offset = tos->offset;
  268. line_number = tos->line_number;
  269. free (tos);
  270. /* Go back to the (now) current node. */
  271. pop_node_filename ();
  272. }
  273. /* Flush all open files on the file stack. */
  274. void
  275. flush_file_stack (void)
  276. {
  277. while (filestack)
  278. {
  279. char *fname = input_filename;
  280. char *text = input_text;
  281. popfile ();
  282. free (fname);
  283. free (text);
  284. }
  285. }
  286. /* Return the index of the first character in the filename
  287. which is past all the leading directory characters. */
  288. static int
  289. skip_directory_part (char *filename)
  290. {
  291. int i = strlen (filename) - 1;
  292. while (i && !IS_SLASH (filename[i]))
  293. i--;
  294. if (IS_SLASH (filename[i]))
  295. i++;
  296. else if (filename[i] && HAVE_DRIVE (filename))
  297. i = 2;
  298. return i;
  299. }
  300. static char *
  301. filename_non_directory (char *name)
  302. {
  303. return xstrdup (name + skip_directory_part (name));
  304. }
  305. /* Return just the simple part of the filename; i.e. the
  306. filename without the path information, or extensions.
  307. This conses up a new string. */
  308. char *
  309. filename_part (char *filename)
  310. {
  311. char *basename = filename_non_directory (filename);
  312. #ifdef REMOVE_OUTPUT_EXTENSIONS
  313. /* See if there is an extension to remove. If so, remove it. */
  314. {
  315. char *temp = strrchr (basename, '.');
  316. if (temp)
  317. *temp = 0;
  318. }
  319. #endif /* REMOVE_OUTPUT_EXTENSIONS */
  320. return basename;
  321. }
  322. /* Return the pathname part of filename. This can be NULL. */
  323. char *
  324. pathname_part (char *filename)
  325. {
  326. char *result = NULL;
  327. int i;
  328. filename = expand_filename (filename, "");
  329. i = skip_directory_part (filename);
  330. if (i)
  331. {
  332. result = xmalloc (1 + i);
  333. strncpy (result, filename, i);
  334. result[i] = 0;
  335. }
  336. free (filename);
  337. return result;
  338. }
  339. /* Return the full path to FILENAME. */
  340. static char *
  341. full_pathname (char *filename)
  342. {
  343. int initial_character;
  344. char *result;
  345. /* No filename given? */
  346. if (!filename || !*filename)
  347. return xstrdup ("");
  348. /* Already absolute? */
  349. if (IS_ABSOLUTE (filename) ||
  350. (*filename == '.' &&
  351. (IS_SLASH (filename[1]) ||
  352. (filename[1] == '.' && IS_SLASH (filename[2])))))
  353. return xstrdup (filename);
  354. initial_character = *filename;
  355. if (initial_character != '~')
  356. {
  357. char *localdir = xmalloc (1025);
  358. #ifdef HAVE_GETCWD
  359. if (!getcwd (localdir, 1024))
  360. #else
  361. if (!getwd (localdir))
  362. #endif
  363. {
  364. fprintf (stderr, _("%s: getwd: %s, %s\n"),
  365. progname, filename, localdir);
  366. xexit (1);
  367. }
  368. strcat (localdir, "/");
  369. strcat (localdir, filename);
  370. result = xstrdup (localdir);
  371. free (localdir);
  372. }
  373. else
  374. { /* Does anybody know why WIN32 doesn't want to support $HOME?
  375. If the reason is they don't have getpwnam, they should
  376. only disable the else clause below. */
  377. #ifndef WIN32
  378. if (IS_SLASH (filename[1]))
  379. {
  380. /* Return the concatenation of the environment variable HOME
  381. and the rest of the string. */
  382. char *temp_home;
  383. temp_home = (char *) getenv ("HOME");
  384. result = xmalloc (strlen (&filename[1])
  385. + 1
  386. + temp_home ? strlen (temp_home)
  387. : 0);
  388. *result = 0;
  389. if (temp_home)
  390. strcpy (result, temp_home);
  391. strcat (result, &filename[1]);
  392. }
  393. else
  394. {
  395. struct passwd *user_entry;
  396. int i, c;
  397. char *username = xmalloc (257);
  398. for (i = 1; (c = filename[i]); i++)
  399. {
  400. if (IS_SLASH (c))
  401. break;
  402. else
  403. username[i - 1] = c;
  404. }
  405. if (c)
  406. username[i - 1] = 0;
  407. user_entry = getpwnam (username);
  408. if (!user_entry)
  409. return xstrdup (filename);
  410. result = xmalloc (1 + strlen (user_entry->pw_dir)
  411. + strlen (&filename[i]));
  412. strcpy (result, user_entry->pw_dir);
  413. strcat (result, &filename[i]);
  414. }
  415. #endif /* not WIN32 */
  416. }
  417. return result;
  418. }
  419. /* Return the expansion of FILENAME. */
  420. char *
  421. expand_filename (char *filename, char *input_name)
  422. {
  423. int i;
  424. if (filename)
  425. {
  426. filename = full_pathname (filename);
  427. if (IS_ABSOLUTE (filename)
  428. || (*filename == '.' &&
  429. (IS_SLASH (filename[1]) ||
  430. (filename[1] == '.' && IS_SLASH (filename[2])))))
  431. return filename;
  432. }
  433. else
  434. {
  435. filename = filename_non_directory (input_name);
  436. if (!*filename)
  437. {
  438. free (filename);
  439. filename = xstrdup ("noname.texi");
  440. }
  441. for (i = strlen (filename) - 1; i; i--)
  442. if (filename[i] == '.')
  443. break;
  444. if (!i)
  445. i = strlen (filename);
  446. if (i + 6 > (strlen (filename)))
  447. filename = xrealloc (filename, i + 6);
  448. strcpy (filename + i, html ? ".html" : ".info");
  449. return filename;
  450. }
  451. if (IS_ABSOLUTE (input_name))
  452. {
  453. /* Make it so that relative names work. */
  454. char *result;
  455. i = strlen (input_name) - 1;
  456. result = xmalloc (1 + strlen (input_name) + strlen (filename));
  457. strcpy (result, input_name);
  458. while (!IS_SLASH (result[i]) && i)
  459. i--;
  460. if (IS_SLASH (result[i]))
  461. i++;
  462. strcpy (&result[i], filename);
  463. free (filename);
  464. return result;
  465. }
  466. return filename;
  467. }
  468. char *
  469. output_name_from_input_name (char *name)
  470. {
  471. return expand_filename (NULL, name);
  472. }
  473. /* Modify the file name FNAME so that it fits the limitations of the
  474. underlying filesystem. In particular, truncate the file name as it
  475. would be truncated by the filesystem. We assume the result can
  476. never be longer than the original, otherwise we couldn't be sure we
  477. have enough space in the original string to modify it in place. */
  478. char *
  479. normalize_filename (char *fname)
  480. {
  481. int maxlen;
  482. char orig[PATH_MAX + 1];
  483. int i;
  484. char *lastdot, *p;
  485. #ifdef _PC_NAME_MAX
  486. maxlen = pathconf (fname, _PC_NAME_MAX);
  487. if (maxlen < 1)
  488. #endif
  489. maxlen = PATH_MAX;
  490. i = skip_directory_part (fname);
  491. if (fname[i] == '\0')
  492. return fname; /* only a directory name -- don't modify */
  493. strcpy (orig, fname + i);
  494. switch (maxlen)
  495. {
  496. case 12: /* MS-DOS 8+3 filesystem */
  497. if (orig[0] == '.') /* leading dots are not allowed */
  498. orig[0] = '_';
  499. lastdot = strrchr (orig, '.');
  500. if (!lastdot)
  501. lastdot = orig + strlen (orig);
  502. strncpy (fname + i, orig, lastdot - orig);
  503. for (p = fname + i;
  504. p < fname + i + (lastdot - orig) && p < fname + i + 8;
  505. p++)
  506. if (*p == '.')
  507. *p = '_';
  508. *p = '\0';
  509. if (*lastdot == '.')
  510. strncat (fname + i, lastdot, 4);
  511. break;
  512. case 14: /* old Unix systems with 14-char limitation */
  513. strcpy (fname + i, orig);
  514. if (strlen (fname + i) > 14)
  515. fname[i + 14] = '\0';
  516. break;
  517. default:
  518. strcpy (fname + i, orig);
  519. if (strlen (fname) > maxlen - 1)
  520. fname[maxlen - 1] = '\0';
  521. break;
  522. }
  523. return fname;
  524. }
  525. /* Delayed writing functions. A few of the commands
  526. needs to be handled at the end, namely @contents,
  527. @shortcontents, @printindex and @listoffloats.
  528. These functions take care of that. */
  529. static DELAYED_WRITE *delayed_writes = NULL;
  530. int handling_delayed_writes = 0;
  531. void
  532. register_delayed_write (char *delayed_command)
  533. {
  534. DELAYED_WRITE *new;
  535. if (!current_output_filename || !*current_output_filename)
  536. {
  537. /* Cannot register if we don't know what the output file is. */
  538. warning (_("`%s' omitted before output filename"), delayed_command);
  539. return;
  540. }
  541. if (STREQ (current_output_filename, "-"))
  542. {
  543. /* Do not register a new write if the output file is not seekable.
  544. Let the user know about it first, though. */
  545. warning (_("`%s' omitted since writing to stdout"), delayed_command);
  546. return;
  547. }
  548. /* Don't complain if the user is writing /dev/null, since surely they
  549. don't care, but don't register the delayed write, either. */
  550. if (FILENAME_CMP (current_output_filename, NULL_DEVICE) == 0
  551. || FILENAME_CMP (current_output_filename, ALSO_NULL_DEVICE) == 0)
  552. return;
  553. /* We need the HTML header in the output,
  554. to get a proper output_position. */
  555. if (!executing_string && html)
  556. output_head ();
  557. /* Get output_position updated. */
  558. flush_output ();
  559. new = xmalloc (sizeof (DELAYED_WRITE));
  560. new->command = xstrdup (delayed_command);
  561. new->filename = xstrdup (current_output_filename);
  562. new->input_filename = xstrdup (input_filename);
  563. new->position = output_position;
  564. new->calling_line = line_number;
  565. new->node = current_node ? xstrdup (current_node): "";
  566. new->node_order = node_order;
  567. new->index_order = index_counter;
  568. new->next = delayed_writes;
  569. delayed_writes = new;
  570. }
  571. void
  572. handle_delayed_writes (void)
  573. {
  574. DELAYED_WRITE *temp = (DELAYED_WRITE *) reverse_list
  575. ((GENERIC_LIST *) delayed_writes);
  576. int position_shift_amount, line_number_shift_amount;
  577. char *delayed_buf;
  578. handling_delayed_writes = 1;
  579. while (temp)
  580. {
  581. delayed_buf = find_and_load (temp->filename, 0);
  582. if (output_paragraph_offset > 0)
  583. {
  584. error (_("Output buffer not empty."));
  585. return;
  586. }
  587. if (!delayed_buf)
  588. {
  589. fs_error (temp->filename);
  590. return;
  591. }
  592. output_stream = fopen (temp->filename, "w");
  593. if (!output_stream)
  594. {
  595. fs_error (temp->filename);
  596. return;
  597. }
  598. if (fwrite (delayed_buf, 1, temp->position, output_stream) != temp->position)
  599. {
  600. fs_error (temp->filename);
  601. return;
  602. }
  603. {
  604. int output_position_at_start = output_position;
  605. int line_number_at_start = output_line_number;
  606. /* In order to make warnings and errors
  607. refer to the correct line number. */
  608. input_filename = temp->input_filename;
  609. line_number = temp->calling_line;
  610. execute_string ("%s", temp->command);
  611. flush_output ();
  612. /* Since the output file is modified, following delayed writes
  613. need to be updated by this amount. */
  614. position_shift_amount = output_position - output_position_at_start;
  615. line_number_shift_amount = output_line_number - line_number_at_start;
  616. }
  617. if (fwrite (delayed_buf + temp->position, 1,
  618. input_text_length - temp->position, output_stream)
  619. != input_text_length - temp->position
  620. || fclose (output_stream) != 0)
  621. fs_error (temp->filename);
  622. /* Done with the buffer. */
  623. free (delayed_buf);
  624. /* Update positions in tag table for nodes that are defined after
  625. the line this delayed write is registered. */
  626. if (!html && !xml)
  627. {
  628. TAG_ENTRY *node;
  629. for (node = tag_table; node; node = node->next_ent)
  630. if (node->order > temp->node_order)
  631. node->position += position_shift_amount;
  632. }
  633. /* Something similar for the line numbers in all of the defined
  634. indices. */
  635. {
  636. int i;
  637. for (i = 0; i < defined_indices; i++)
  638. if (name_index_alist[i])
  639. {
  640. char *name = ((INDEX_ALIST *) name_index_alist[i])->name;
  641. INDEX_ELT *index;
  642. for (index = index_list (name); index; index = index->next)
  643. if ((no_headers || STREQ (index->node, temp->node))
  644. && index->entry_number > temp->index_order)
  645. index->output_line += line_number_shift_amount;
  646. }
  647. }
  648. /* Shift remaining delayed positions
  649. by the length of this write. */
  650. {
  651. DELAYED_WRITE *future_write = temp->next;
  652. while (future_write)
  653. {
  654. if (STREQ (temp->filename, future_write->filename))
  655. future_write->position += position_shift_amount;
  656. future_write = future_write->next;
  657. }
  658. }
  659. temp = temp->next;
  660. }
  661. }