tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: style change: explicitly permit braces for single statements



	if (ch == t.c_cc[VINTR]) {
		...do INTR processing...
	} else {
		if (ch == t.c_cc[VQUIT]) {
			...do QUIT processing...
		} else {
			if (ch == t.c_cc[VKILL]) {
				...do KILL processing...
			} else {
				...etc
			}
		}
	}

For this, I would prefer

	if (ch == t.c_cc[VINTR]) {
		...do INTR processing...
	} else if (ch == t.c_cc[VQUIT]) {
		...do QUIT processing...
	} else if (ch == t.c_cc[VKILL]) {
		...do KILL processing...
	} else {
		...etc
	}

In this case, perhaps even a switch might better, assuming that all of the t_c.cc[] are unique:

	switch (ch) {
	case t.c_cc[VINTR]) {
		...do INTR processing...
		break;
	};
	case t.c_cc[VQUIT]) {
		...do QUIT processing...
		break;
	}
	case t.c_cc[VKILL]) {
		...do KILL processing...
		break;
	}
	...etc


+--------------------+--------------------------+-----------------------+
| Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
| (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost     |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost   |
+--------------------+--------------------------+-----------------------+


Home | Main Index | Thread Index | Old Index