chiark
/
gitweb
/
~mdw
/
xtoys
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a1bcaff
)
xscsize.c: Publish the output-format flags globally.
author
Mark Wooding
<mdw@distorted.org.uk>
Thu, 21 Apr 2016 16:18:01 +0000
(17:18 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Thu, 21 Apr 2016 16:18:01 +0000
(17:18 +0100)
xscsize.c
patch
|
blob
|
blame
|
history
diff --git
a/xscsize.c
b/xscsize.c
index 19e5ccac775e4540e603e1a2e46aac4bab8b54ba..0cd4cbd1996e50c1ac021933c4f5b47edfe2a16f 100644
(file)
--- a/
xscsize.c
+++ b/
xscsize.c
@@
-35,6
+35,14
@@
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
+/*----- Static variables --------------------------------------------------*/
+
+static unsigned int flags = 0;
+#define F_SH 1u
+#define F_CSH 2u
+#define F_SHELL 3u
+#define F_EXPORT 4u
+
/*----- Main code ---------------------------------------------------------*/
static void version(FILE *fp)
/*----- Main code ---------------------------------------------------------*/
static void version(FILE *fp)
@@
-75,11
+83,7
@@
int main(int argc, char *argv[])
unsigned long wd, ht;
int sc;
unsigned long wd, ht;
int sc;
-#define f_sh 1u
-#define f_csh 2u
-#define f_shell 3u
-#define f_export 4u
-#define f_bogus 8u
+#define f_bogus 1u
/* --- Parse command line options --- */
/* --- Parse command line options --- */
@@
-104,9
+108,9
@@
int main(int argc, char *argv[])
case 'u': usage(stdout); exit(0); break;
case 'v': version(stdout); exit(0); break;
case 'd': display = optarg; break;
case 'u': usage(stdout); exit(0); break;
case 'v': version(stdout); exit(0); break;
case 'd': display = optarg; break;
- case 'b': f
|= f_sh
; break;
- case 'c': f
|= f_csh
; break;
- case 'x': f
|= f_export
; break;
+ case 'b': f
lags |= F_SH
; break;
+ case 'c': f
lags |= F_CSH
; break;
+ case 'x': f
lags |= F_EXPORT
; break;
default: f |= f_bogus; break;
}
}
default: f |= f_bogus; break;
}
}
@@
-120,17
+124,14
@@
int main(int argc, char *argv[])
* Otherwise assume it's Bourne. This seems to work in practice.
*/
* Otherwise assume it's Bourne. This seems to work in practice.
*/
- if (!(f
& f_shell
)) {
+ if (!(f
lags & F_SHELL
)) {
s = getenv("SHELL");
s = getenv("SHELL");
- if (!s)
- f |= f_sh;
- if (strstr(s, "csh"))
- f |= f_csh;
- else
- f |= f_sh;
+ if (!s) flags |= F_SH;
+ if (strstr(s, "csh")) flags |= F_CSH;
+ else flags |= F_SH;
}
}
- if ((f
& f_sh) && (f & f_csh
)) {
+ if ((f
lags & F_SH) && (flags & F_CSH
)) {
fprintf(stderr, "xscsize: make your mind up about your shell type\n");
exit(EXIT_FAILURE);
}
fprintf(stderr, "xscsize: make your mind up about your shell type\n");
exit(EXIT_FAILURE);
}