[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/makeinfo makeinfo.c,1.21,1.22
From: |
dirt |
Subject: |
texinfo/makeinfo makeinfo.c,1.21,1.22 |
Date: |
Fri, 2 Jan 2004 13:40:40 +0100 |
Update of /cvsroot/texinfo/texinfo/makeinfo
In directory sheep:/tmp/cvs-serv9786/makeinfo
Modified Files:
makeinfo.c
Log Message:
2004-01-02 Alper Ersoy <address@hidden>
* makeinfo/makeinfo.c (create_html_directory): new function.
(insert_toplevel_subdirectory): moved common if blocks to
create_html_directory. Adjusted checks to reuse existing
directories, and remove existing <output>.html files, when
falling back to suffices.
Index: makeinfo.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** makeinfo.c 2003/12/31 10:08:01 1.21
--- makeinfo.c 2004/01/02 12:40:38 1.22
***************
*** 1419,1422 ****
--- 1419,1452 ----
}
+ int
+ create_html_directory (dir, can_remove_file)
+ char *dir;
+ int can_remove_file;
+ {
+ struct stat st;
+
+ /* Already exists. */
+ if (stat (dir, &st) == 0)
+ {
+ /* And it's a directory, so silently reuse it. */
+ if (S_ISDIR (st.st_mode))
+ return 1;
+ /* Not a directory, so move it out of the way if we are allowed. */
+ else if (can_remove_file)
+ {
+ if (unlink (dir) != 0)
+ return 0;
+ }
+ else
+ return 0;
+ }
+
+ if (mkdir (dir, 0777) == 0)
+ /* Success! */
+ return 1;
+ else
+ return 0;
+ }
+
/* Given OUTPUT_FILENAME == ``/foo/bar/baz.html'', return
"/foo/bar/baz/baz.html". This routine is called only if html && splitting.
***************
*** 1437,1441 ****
char *dir, *subdir, *base, *basename, *p;
char buf[PATH_MAX];
- struct stat st;
const int index_len = sizeof (index_name) - 1;
--- 1467,1470 ----
***************
*** 1467,1497 ****
strcat (output_filename, "/");
strcat (output_filename, subdir);
! if ((mkdir (output_filename, 0777) == -1 && errno != EEXIST)
! /* output_filename might exist, but be a non-directory. */
! || (stat (output_filename, &st) == 0 && !S_ISDIR (st.st_mode)))
! { /* that failed, try subdir name with .html */
strcpy (output_filename, dir);
if (strlen (dir))
strcat (output_filename, "/");
strcat (output_filename, basename);
- if (mkdir (output_filename, 0777) == -1)
- {
- const char *errmsg = strerror (errno);
! if ((errno == EEXIST
! #ifdef __MSDOS__
! || errno == EACCES
! #endif
! )
! && (stat (output_filename, &st) == 0 && !S_ISDIR (st.st_mode)))
! errmsg = _("File exists, but is not a directory");
line_error (_("Can't create directory `%s': %s"),
! output_filename, errmsg);
xexit (1);
}
- strcat (output_filename, "/");
}
! else if (strlen (subdir))
! strcat (output_filename, "/");
strcat (output_filename, index_name);
return output_filename;
--- 1496,1520 ----
strcat (output_filename, "/");
strcat (output_filename, subdir);
!
! /* First try, do not remove existing file. */
! if (!create_html_directory (output_filename, 0))
! {
! /* That failed, try subdir name with .html.
! Remove it if it exists. */
strcpy (output_filename, dir);
if (strlen (dir))
strcat (output_filename, "/");
strcat (output_filename, basename);
! if (!create_html_directory (output_filename, 1))
! {
! /* Last try failed too :-\ */
line_error (_("Can't create directory `%s': %s"),
! output_filename, strerror (errno));
xexit (1);
}
}
!
! strcat (output_filename, "/");
strcat (output_filename, index_name);
return output_filename;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/makeinfo makeinfo.c,1.21,1.22,
dirt <=