2004-04-09  Juan M. Guerrero  <st001906@hrz1.hrz.tu-darmstadt.de>

	* doc/indent.texinfo: Add DJGPP specific info about the indent
	profile file indent.pro, the HOME environment variable and the
	availability of numbered backups under Win9X.

	* src/backup.c (max_version) [IS_SLASH]: Use new macro to check
	for OS specific directory separator characters.
	(generate_backup_filename) [HAVE_LONG_FILENAMES]: Use new macro
	to decide at runtime if simple backup file names must be used or
	numbered  backup file names can be used.

	* src/indent.c (indent_multiple_files) [IS_DIRECTORY]: Skip file
	name if it is a directory (DJGPP specific).

	* src/sys.h [IS_SLASH]: Macro checks for `/' as dir separator
	character on POSIX-like OS.
	[HAVE_LONG_FILENAMES]: Macro defaults to long file names support.
	[__MSDOS__] [IS_SLASH]: Macro checks for `:', `/' and `\' as dir
	separator characters.
	[__MSDOS__] [__DJGPP__] [HAVE_LONG_FILENAMES]: DJGPP checks at
	runtime if OS supports the use of long file names (Win9X) or not
	(plain DOS).
	[__MSDOS__] [__DJGPP__] [IS_DIRECTORY]: Skip file name if it is
	a directory.
	[__MSDOS__] [IS_DIRECTORY]: NO-OP.
	[!__MSDOS__] [IS_DIRECTORY]: NO-OP.



diff -apruNU3 indent-2.2.9.orig/doc/indent.texinfo indent-2.2.9.djgpp/doc/indent.texinfo
--- indent-2.2.9.orig/doc/indent.texinfo	2002-11-10 21:02:48.000000000 +0000
+++ indent-2.2.9.djgpp/doc/indent.texinfo	2004-04-09 02:26:40.000000000 +0000
@@ -275,6 +275,14 @@ they would appear on the command line, s
 spaces, and newlines).  Options in @file{.indent.pro} may be surrounded by C
 or C++ comments, in which case they are ignored.
 
+Note that on MS-DOS and MS-Windows, the profile file is called
+@file{indent.pro}, without a leading dot, because these systems don't
+allow more than one dot in a filename.  Also, since users do not
+generally have special home directories on these systems, you will need
+to set the @code{HOME} environment variable to point to a directory
+where your default @file{indent.pro} file is stored, if you want
+@code{indent} to find it in a directory other than the current.
+
 Command line switches are handled @emph{after} processing
 @file{.indent.pro}.  Options specified later override arguments
 specified earlier, with one exception: Explicitly specified options
@@ -320,6 +328,13 @@ otherwise, a simple backup is made.  If 
 set, then @command{indent} assumes the behaviour of
 @samp{numbered-existing}.
 
+The MS-DOS/MS-Windows version of @code{indent} supports numbered backups
+only on Windows 9x, where filenames are allowed to have more than a
+single dot.  On other MS platforms, setting @code{VERSION_CONTROL} to
+@samp{numbered} has no effect, and @code{indent} will always produce
+either a simple-style backup file or no backups at all (if you set
+@code{VERSION_CONTROL} to @samp{never}).
+
 Other versions of @command{indent} use the suffix @file{.BAK} in naming
 backup files.  This behaviour can be emulated by setting
 @env{SIMPLE_BACKUP_SUFFIX} to @samp{.BAK}.
diff -apruNU3 indent-2.2.9.orig/src/backup.c indent-2.2.9.djgpp/src/backup.c
--- indent-2.2.9.orig/src/backup.c	2002-08-04 17:08:40.000000000 +0000
+++ indent-2.2.9.djgpp/src/backup.c	2004-04-09 02:26:40.000000000 +0000
@@ -251,12 +251,12 @@ static int max_version (
 
     p = pathname + pathlen - 1;
     
-    while ((p > pathname) && (*p != '/'))
+    while ((p > pathname) && !IS_SLASH(*p))
     {
         p--;
     }
 
-    if (*p == '/')
+    if (IS_SLASH(*p))
     {
         int dirlen = p - pathname;
         char *dirname;
@@ -286,6 +286,11 @@ static char * generate_backup_filename (
     int last_numbered_version;
     char *backup_name;
 
+    if (!HAVE_LONG_FILENAMES(pathname))
+    {
+        return simple_backup_name (pathname);
+    }
+
     if (version_control == none)
     {
         return 0;
diff -apruNU3 indent-2.2.9.orig/src/indent.c indent-2.2.9.djgpp/src/indent.c
--- indent-2.2.9.orig/src/indent.c	2002-10-28 20:00:56.000000000 +0000
+++ indent-2.2.9.djgpp/src/indent.c	2004-04-09 02:46:36.000000000 +0000
@@ -2946,6 +2946,12 @@ static exit_values_ty indent_multiple_fi
 
         in_name = in_file_names[i];
         out_name = in_file_names[i];
+
+        if (IS_DIRECTORY(in_file_names[i], file_stats))
+        {
+            continue;
+        }
+
         current_input = read_file(in_file_names[i], &file_stats);
 
         open_output(out_name, "r+");
diff -apruNU3 indent-2.2.9.orig/src/sys.h indent-2.2.9.djgpp/src/sys.h
--- indent-2.2.9.orig/src/sys.h	2002-03-15 07:48:46.000000000 +0000
+++ indent-2.2.9.djgpp/src/sys.h	2004-04-09 02:49:12.000000000 +0000
@@ -72,7 +72,24 @@ extern int debug;
 
 #ifdef __MSDOS__
 # define ONE_DOT_PER_FILENAME 1
-#endif /* __MSDOS__ */
+# define IS_SLASH(c)          ((c) == '/' || (c) == '\\' || (c) == ':')
+# ifdef __DJGPP__
+   /* Check if it is a directory. Skip, if so. */
+#  define IS_DIRECTORY(name, st_buf) ((stat((name), &(st_buf)) == -1) || S_ISDIR((st_buf.st_mode)))
+   /*
+    * DJGPP determinates at runtime if the running OS
+    * supports long file names (Win9x) or not (plain DOS).
+    */
+#  define HAVE_LONG_FILENAMES(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+# else  /* !__DJGPP__ */
+#  define IS_DIRECTORY(name, st_buf) (0)          /* NO-OP */
+#  define HAVE_LONG_FILENAMES(name)  (1)          /* Assume that OS supports the use of long file names */
+# endif /* !__DJGPP__ */
+#else /* !__MSDOS__ */
+# define IS_SLASH(c)                 ((c) == '/') /* Directory separator for POSIX and POSIX-like systems */
+# define IS_DIRECTORY(name, st_buf)  (0)          /* NO-OP */
+# define HAVE_LONG_FILENAMES(name)   (1)          /* Assume that OS supports the use of long file names */
+#endif /* !__MSDOS__ */
 
 #if defined(HAVE_UTIME) && (defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H))
 #define PRESERVE_MTIME 1
