aboutsummaryrefslogtreecommitdiff
path: root/src/xz/main.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-02-13 17:29:02 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-02-13 17:29:02 +0200
commit96c46df7deb231ea68a03d8d1da9de4c774e36d8 (patch)
tree6788af6a63bd9bdc77f318b7581b43e859e1a44c /src/xz/main.c
parentRemove dead directories from .gitignore. (diff)
downloadxz-96c46df7deb231ea68a03d8d1da9de4c774e36d8.tar.xz
Improve support for DOS-like systems.
Here DOS-like means DOS, Windows, and OS/2.
Diffstat (limited to '')
-rw-r--r--src/xz/main.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/xz/main.c b/src/xz/main.c
index 6c21cd2a..8e707fb0 100644
--- a/src/xz/main.c
+++ b/src/xz/main.c
@@ -164,6 +164,29 @@ main(int argc, char **argv)
// that stdin, stdout, and stderr are something valid.
io_init();
+#ifdef DOSLIKE
+ // Adjust argv[0] to make it look nicer in messages, and also to
+ // help the code in args.c.
+ {
+ // Strip the leading path.
+ char *p = argv[0] + strlen(argv[0]);
+ while (argv[0] < p && p[-1] != '/' && p[-1] != '\\')
+ --p;
+
+ argv[0] = p;
+
+ // Strip the .exe suffix.
+ p = strrchr(p, '.');
+ if (p != NULL)
+ *p = '\0';
+
+ // Make it lowercase.
+ for (p = argv[0]; *p != '\0'; ++p)
+ if (*p >= 'A' && *p <= 'Z')
+ *p = *p - 'A' + 'a';
+ }
+#endif
+
// Set up the locale.
setlocale(LC_ALL, "");