chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Describe custom interface.
[mLib]
/
traceopt.c
diff --git
a/traceopt.c
b/traceopt.c
index 08cdd578d9756e187606d9bd67091217aa1aefeb..e1c26241b3537080951c82f23c9020f2542f6e07 100644
(file)
--- a/
traceopt.c
+++ b/
traceopt.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: traceopt.c,v 1.
1 1999/10/22 22:40:08
mdw Exp $
+ * $Id: traceopt.c,v 1.
2 2001/02/03 16:25:43
mdw Exp $
*
* Parsing tracing options
*
*
* Parsing tracing options
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: traceopt.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: traceopt.c,v $
+ * Revision 1.2 2001/02/03 16:25:43 mdw
+ * Various bug fixes: understand requests for help properly, and fix the
+ * logic for flag letters with `bad' flags.
+ *
* Revision 1.1 1999/10/22 22:40:08 mdw
* Separate function for parsing user trace specs.
*
* Revision 1.1 1999/10/22 22:40:08 mdw
* Separate function for parsing user trace specs.
*
@@
-48,7
+52,7
@@
/* --- @traceopt@ --- *
*
/* --- @traceopt@ --- *
*
- * Arguments: @trace_opt *t@ = pointer to trace options table
+ * Arguments: @
const
trace_opt *t@ = pointer to trace options table
* @const char *p@ = option string supplied by user
* @unsigned f@ = initial tracing flags
* @unsigned bad@ = forbidden tracing flags
* @const char *p@ = option string supplied by user
* @unsigned f@ = initial tracing flags
* @unsigned bad@ = forbidden tracing flags
@@
-60,18
+64,20
@@
* `?' character, a help message is displayed.
*/
* `?' character, a help message is displayed.
*/
-unsigned traceopt(trace_opt *t, const char *p, unsigned f, unsigned bad)
+unsigned traceopt(const trace_opt *t, const char *p,
+ unsigned f, unsigned bad)
{
unsigned sense = 1;
/* --- Dump out help text --- */
{
unsigned sense = 1;
/* --- Dump out help text --- */
- if (!p || strcmp(p, "?")) {
+ if (!p || !strcmp(p, "?")) {
+ const trace_opt *tt;
puts("Trace options:");
puts("Trace options:");
-
while (t->ch
) {
- if (
t->f & bad || !
t->help)
+
for (tt = t; tt->ch; tt++
) {
+ if (
!(tt->f & ~bad) || !t
t->help)
continue;
continue;
- printf(" `%c': %s\n", t
->ch,
t->help);
+ printf(" `%c': %s\n", t
t->ch, t
t->help);
}
return (f);
}
}
return (f);
}
@@
-88,17
+94,17
@@
unsigned traceopt(trace_opt *t, const char *p, unsigned f, unsigned bad)
sense = 0;
break;
default: {
sense = 0;
break;
default: {
- trace_opt *tt;
+
const
trace_opt *tt;
for (tt = t; tt->ch; tt++) {
for (tt = t; tt->ch; tt++) {
- if (
tt->f & bad
)
+ if (
!(tt->f & ~bad)
)
continue;
if (tt->ch == *p) {
if (sense)
f |= (tt->f & ~bad);
else
f &= ~(tt->f & ~bad);
continue;
if (tt->ch == *p) {
if (sense)
f |= (tt->f & ~bad);
else
f &= ~(tt->f & ~bad);
+ goto ok;
}
}
- goto ok;
}
moan("unknown trace option `%c'", *p);
ok:;
}
moan("unknown trace option `%c'", *p);
ok:;