4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-03-04 14:06:13 +08:00

* cygpath.cc: Reformat.

* cygpath.cc (print_version): New function.
(main): Accommodate new version function.  Initialize 'o' to prevent warning.
* cygcheck.cc (main): Eliminate non-GNU formatting glitch.
This commit is contained in:
Christopher Faylor 2002-03-07 03:00:14 +00:00
parent 9420d2b833
commit 6a34460970
2 changed files with 186 additions and 144 deletions

View File

@ -1,3 +1,17 @@
2002-03-06 Christopher Faylor <cgf@redhat.com>
* cygpath.cc: Reformat.
2002-02-27 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* cygpath.cc (print_version): New function.
(main): Accommodate new version function. Initialize 'o' to prevent
warning.
2002-02-27 Christopher Faylor <cgf@redhat.com>
* cygcheck.cc (main): Eliminate non-GNU formatting glitch.
2002-02-27 Christopher Faylor <cgf@redhat.com> 2002-02-27 Christopher Faylor <cgf@redhat.com>
* ssp.c (help_desk): Fix compiler warning. * ssp.c (help_desk): Fix compiler warning.

View File

@ -21,14 +21,15 @@ details. */
#include <sys/cygwin.h> #include <sys/cygwin.h>
#include <ctype.h> #include <ctype.h>
static const char version[] = "$Revision$";
static char *prog_name; static char *prog_name;
static char *file_arg; static char *file_arg;
static char *close_arg; static char *close_arg;
static int path_flag, unix_flag, windows_flag, absolute_flag; static int path_flag, unix_flag, windows_flag, absolute_flag;
static int shortname_flag, ignore_flag, allusers_flag, output_flag; static int shortname_flag, ignore_flag, allusers_flag, output_flag;
static struct option long_options[] = static struct option long_options[] = {
{
{(char *) "help", no_argument, NULL, 'h'}, {(char *) "help", no_argument, NULL, 'h'},
{(char *) "absolute", no_argument, NULL, 'a'}, {(char *) "absolute", no_argument, NULL, 'a'},
{(char *) "option", no_argument, NULL, 'o'}, {(char *) "option", no_argument, NULL, 'o'},
@ -67,8 +68,7 @@ Usage: %s [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename\n\
-D|--desktop output `Desktop' directory and exit\n\ -D|--desktop output `Desktop' directory and exit\n\
-P|--smprograms output Start Menu `Programs' directory and exit\n\ -P|--smprograms output Start Menu `Programs' directory and exit\n\
-S|--sysdir output system directory and exit\n\ -S|--sysdir output system directory and exit\n\
-W|--windir output `Windows' directory and exit\n", -W|--windir output `Windows' directory and exit\n", prog_name);
prog_name);
exit (ignore_flag ? 0 : status); exit (ignore_flag ? 0 : status);
} }
@ -92,7 +92,8 @@ get_short_paths (char *path)
len = GetShortPathName (next, NULL, 0); len = GetShortPathName (next, NULL, 0);
if (len == ERROR_INVALID_PARAMETER) if (len == ERROR_INVALID_PARAMETER)
{ {
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name, next); fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
next);
exit (2); exit (2);
} }
acc += len + 1; acc += len + 1;
@ -108,7 +109,8 @@ get_short_paths (char *path)
{ {
if (GetShortPathName (ptr, sptr, acc) == ERROR_INVALID_PARAMETER) if (GetShortPathName (ptr, sptr, acc) == ERROR_INVALID_PARAMETER)
{ {
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name, ptr); fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
ptr);
exit (2); exit (2);
} }
@ -129,7 +131,8 @@ get_short_name (const char *filename)
DWORD len = GetShortPathName (filename, NULL, 0); DWORD len = GetShortPathName (filename, NULL, 0);
if (len == ERROR_INVALID_PARAMETER) if (len == ERROR_INVALID_PARAMETER)
{ {
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name, filename); fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
filename);
exit (2); exit (2);
} }
sbuf = (char *) malloc (++len); sbuf = (char *) malloc (++len);
@ -140,7 +143,8 @@ get_short_name (const char *filename)
} }
if (GetShortPathName (filename, sbuf, len) == ERROR_INVALID_PARAMETER) if (GetShortPathName (filename, sbuf, len) == ERROR_INVALID_PARAMETER)
{ {
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name, filename); fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
filename);
exit (2); exit (2);
} }
return sbuf; return sbuf;
@ -156,9 +160,7 @@ doit (char *filename)
if (path_flag) if (path_flag)
{ {
if (cygwin_posix_path_list_p (filename) if (cygwin_posix_path_list_p (filename) ? unix_flag : windows_flag)
? unix_flag
: windows_flag)
{ {
/* The path is already in the right format. */ /* The path is already in the right format. */
puts (filename); puts (filename);
@ -231,10 +233,32 @@ doit (char *filename)
puts (buf); puts (buf);
} }
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
cygpath (cygwin) %.*s\n\
Path Conversion Utility\n\
Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
Compiled on %s", len, v, __DATE__);
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int c, o; int c, o = 0;
int options_from_file_flag; int options_from_file_flag;
char *filename; char *filename;
char buf[MAX_PATH], buf2[MAX_PATH]; char buf[MAX_PATH], buf2[MAX_PATH];
@ -257,8 +281,9 @@ main (int argc, char **argv)
options_from_file_flag = 0; options_from_file_flag = 0;
allusers_flag = 0; allusers_flag = 0;
output_flag = 0; output_flag = 0;
while ((c = getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA", long_options, (int *) NULL)) while ((c =
!= EOF) getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA",
long_options, (int *) NULL)) != EOF)
{ {
switch (c) switch (c)
{ {
@ -341,8 +366,7 @@ main (int argc, char **argv)
break; break;
case 'v': case 'v':
printf ("Cygwin path conversion version 1.2\n"); print_version ();
printf ("Copyright 1998-2002 Red Hat, Inc.\n");
exit (0); exit (0);
default: default:
@ -354,15 +378,18 @@ main (int argc, char **argv)
if (output_flag) if (output_flag)
{ {
switch(o) { switch (o)
{
case 'D': case 'D':
if (!allusers_flag) if (!allusers_flag)
SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id); SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);
else else
SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_DESKTOPDIRECTORY,&id); SHGetSpecialFolderLocation (NULL, CSIDL_COMMON_DESKTOPDIRECTORY,
&id);
SHGetPathFromIDList (id, buf); SHGetPathFromIDList (id, buf);
/* This if clause is a Fix for Win95 without any "All Users" */ /* This if clause is a Fix for Win95 without any "All Users" */
if ( strlen(buf) == 0 ) { if (strlen (buf) == 0)
{
SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id); SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);
SHGetPathFromIDList (id, buf); SHGetPathFromIDList (id, buf);
} }
@ -380,7 +407,8 @@ main (int argc, char **argv)
SHGetSpecialFolderLocation (NULL, CSIDL_COMMON_PROGRAMS, &id); SHGetSpecialFolderLocation (NULL, CSIDL_COMMON_PROGRAMS, &id);
SHGetPathFromIDList (id, buf); SHGetPathFromIDList (id, buf);
/* This if clause is a Fix for Win95 without any "All Users" */ /* This if clause is a Fix for Win95 without any "All Users" */
if ( strlen(buf) == 0 ) { if (strlen (buf) == 0)
{
SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id); SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);
SHGetPathFromIDList (id, buf); SHGetPathFromIDList (id, buf);
} }