Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/utils/ChangeLog8
-rw-r--r--winsup/utils/cygpath.cc38
-rw-r--r--winsup/utils/utils.sgml1
3 files changed, 41 insertions, 6 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 943666cee..c6f1d9e50 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,11 @@
+2004-02-24 Christopher Faylor <cgf@redhat.com>
+
+ * cygpath.cc (long_options): Add "mode" option.
+ (options): Ditto.
+ (usage): Report on new option.
+ (report_mode): New function.
+ (main): Implement -M option.
+
2004-02-20 Christopher Faylor <cgf@redhat.com>
* Makefile.in (build_dumper): Detect missing iconv library.
diff --git a/winsup/utils/cygpath.cc b/winsup/utils/cygpath.cc
index cb6491642..fe727dfb8 100644
--- a/winsup/utils/cygpath.cc
+++ b/winsup/utils/cygpath.cc
@@ -41,6 +41,7 @@ static struct option long_options[] = {
{(char *) "ignore", no_argument, NULL, 'i'},
{(char *) "long-name", no_argument, NULL, 'l'},
{(char *) "mixed", no_argument, NULL, 'm'},
+ {(char *) "mode", no_argument, NULL, 'M'},
{(char *) "option", no_argument, NULL, 'o'},
{(char *) "path", no_argument, NULL, 'p'},
{(char *) "short-name", no_argument, NULL, 's'},
@@ -57,7 +58,7 @@ static struct option long_options[] = {
{0, no_argument, 0, 0}
};
-static char options[] = "ac:df:hilmopst:uvwADHPSW";
+static char options[] = "ac:df:hilmMopst:uvwADHPSW";
static void
usage (FILE * stream, int status)
@@ -71,6 +72,7 @@ Convert Unix and Windows format paths, or output system path information\n\
Output type options:\n\
-d, --dos print DOS (short) form of NAME (C:\\PROGRA~1\\)\n\
-m, --mixed like --windows, but with regular slashes (C:/WINNT)\n\
+ -M, --mode report on mode of file (binmode or textmode)\n\
-u, --unix (default) print Unix form of NAME (/cygdrive/c/winnt)\n\
-w, --windows print Windows form of NAME (C:\\WINNT)\n\
-t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows'\n\
@@ -410,6 +412,24 @@ dowin (char option)
}
static void
+report_mode (char *filename)
+{
+ switch (cygwin_internal (CW_GET_BINMODE, filename))
+ {
+ case O_BINARY:
+ printf ("%s: binary\n", filename);
+ break;
+ case O_TEXT:
+ printf ("%s: text\n", filename);
+ break;
+ default:
+ fprintf (stderr, "%s: file '%s' - %s\n", prog_name, filename,
+ strerror (errno));
+ break;
+ }
+}
+
+static void
doit (char *filename)
{
char *buf;
@@ -522,7 +542,7 @@ main (int argc, char **argv)
{
int c, o = 0;
int options_from_file_flag;
- char *filename;
+ int mode_flag;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
@@ -542,6 +562,7 @@ main (int argc, char **argv)
options_from_file_flag = 0;
allusers_flag = 0;
output_flag = 0;
+ mode_flag = 0;
while ((c = getopt_long (argc, argv, options,
long_options, (int *) NULL)) != EOF)
{
@@ -567,6 +588,10 @@ main (int argc, char **argv)
file_arg = optarg;
break;
+ case 'M':
+ mode_flag = 1;
+ break;
+
case 'o':
options_from_file_flag = 1;
break;
@@ -690,10 +715,11 @@ main (int argc, char **argv)
if (optind > argc - 1)
usage (stderr, 1);
- for (int i=optind; argv[i]; i++) {
- filename = argv[i];
- doit (filename);
- }
+ for (int i = optind; argv[i]; i++)
+ if (mode_flag)
+ report_mode (argv[i]);
+ else
+ doit (argv[i]);
}
else
{
diff --git a/winsup/utils/utils.sgml b/winsup/utils/utils.sgml
index 86c8bd491..87522b3d8 100644
--- a/winsup/utils/utils.sgml
+++ b/winsup/utils/utils.sgml
@@ -119,6 +119,7 @@ Convert Unix and Windows format paths, or output system path information
Output type options:
-d, --dos print DOS (short) form of NAME (C:\PROGRA~1\)
-m, --mixed like --windows, but with regular slashes (C:/WINNT)
+ -M, --mode report on mode of file (currently binmode or textmode)
-u, --unix (default) print Unix form of NAME (/cygdrive/c/winnt)
-w, --windows print Windows form of NAME (C:\WINNT)
-t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows'