Commit Diff


commit - cc9bbf6125fec1aaa9a7a1a06574a537fc3c3b29
commit + 7f40f3f51cc79bec922438a9fdfd147dac32d08d
blob - dd9c4e796cfe63fa782d616578cb3033971b34cd
blob + 1e0cc5bbda20cee39f9eab689a18afab750eeb4d
--- adventure.c
+++ adventure.c
@@ -1,9 +1,9 @@
+#include "adventure.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "adventure.h"
-
 int
 main()
 {
blob - 77a11f7e7236ff90b70630acebcebb3bb20193bb
blob + ca1f2eddf1325baf4c86dc8dfc289159f74f338a
--- inventory.c
+++ inventory.c
@@ -14,7 +14,8 @@ move_object(struct param *par, struct object *from, st
 	else if (to == NULL)
 		printf("There is nobody here to give that to.\n");
 	else if (obj == to)
-		printf("What's the meaning of putting a %s inside itself?\n", obj->tags[0]);
+		printf("What's the meaning of putting a %s inside itself?\n",
+			obj->tags[0]);
 	else if (from != obj->location) {
 		/* give the appropriate error message */
 		switch (dist) {
@@ -36,8 +37,7 @@ move_object(struct param *par, struct object *from, st
 				printf("You have no %s.\n", par->tag);
 			else
 				printf("Sorry, %s has no %s.\n",
-					from->description,
-					par->tag);
+					from->description, par->tag);
 			break;
 
 		case dist_held_contained:
blob - f66b92f00ef5d3a6a19907bf40e89aa58af648d4
blob + 462d55921e82c84339ab2341dfb69a4165df4dac
--- io.c
+++ io.c
@@ -1,11 +1,10 @@
 #include "adventure.h"
 
 /* this in only needed for readline */
+#include <readline/history.h>
+#include <readline/readline.h>
 #include <stdio.h>
 
-#include <readline/readline.h>
-#include <readline/history.h>
-
 char *line = NULL;
 
 int
@@ -16,4 +15,3 @@ getinput()
 		add_history(line);
 	return line != NULL;
 }
-
blob - 0da6cc66ddcfc9ad148e6596be1aea80aef3b4d7
blob + 8f5a24bb769ef01e8cfb280592930f28dfa20851
--- match.c
+++ match.c
@@ -1,8 +1,8 @@
-#include "adventure.h"
-
 #include <ctype.h>
 #include <string.h>
 
+#include "adventure.h"
+
 struct param params[MAX_PARAMS];
 
 static const char *
@@ -24,9 +24,7 @@ match_terminal(const char *src, char terminal)
 {
 	return terminal == ' '
 		? match_spaces(src)
-		: tolower(*src) == tolower(terminal)
-			? src + 1
-			: NULL;
+		: tolower(*src) == tolower(terminal) ? src + 1 : NULL;
 }
 
 static const char *
@@ -55,16 +53,20 @@ match_param(const char *src, struct param *par, int lo
 	const char *rest_of_src = loose ? src + strlen(src) : NULL;
 
 	par->tag = src;
-	par->distance = *src == '\0' ? dist_no_obj_specified : dist_unknown_obj;
+	par->distance
+		= *src == '\0' ? dist_no_obj_specified : dist_unknown_obj;
 
-	foreach_obj (obj) {
+	foreach_obj(obj)
+	{
 		const char **tag;
 		enum distance dist = distance_to(obj);
 		for (tag = obj->tags; *tag != NULL; ++tag) {
 			const char *behind_match = match_tag(src, *tag);
-			if (behind_match != NULL &&
-					compare_with_param(*tag, dist, par) > 0 &&
-					(!loose || *skip_spaces(behind_match) == '\0')) {
+			if (behind_match != NULL
+				&& compare_with_param(*tag, dist, par) > 0
+				&& (!loose
+					|| *skip_spaces(behind_match)
+						== '\0')) {
 				par->tag = *tag;
 				par->object = obj;
 				par->distance = dist;
@@ -90,13 +92,13 @@ match_command(const char *src, const char *pattern)
 	}
 
 	/* actual parsing */
-	for (src = skip_spaces(src); src != NULL && *pattern != '\0'; ++pattern) {
+	for (src = skip_spaces(src); src != NULL && *pattern != '\0';
+		++pattern) {
 		src = isupper(*pattern)
 			? match_param(src, param_by_letter(*pattern),
-						pattern[1] == '?')
-			: *pattern == '?'
-				? src
-				: match_terminal(src, *pattern);
+				pattern[1] == '?')
+			: *pattern == '?' ? src
+					  : match_terminal(src, *pattern);
 	}
 
 	return src != NULL && *skip_spaces(src) == '\0';
blob - e00c37883127490644c8326a178aacfdc73c2646
blob + 91af5911f3dd08ccc9bc4ecf13e7edfd17d2569e
--- misc.c
+++ misc.c
@@ -9,7 +9,8 @@ list_objs_at_loc(struct object *location)
 	size_t count = 0;
 	struct object *obj;
 
-	foreach_obj (obj) {
+	foreach_obj(obj)
+	{
 		if (obj != player && obj->location == location) {
 			if (count++ == 0)
 				printf("%s:\n", location->contents);
@@ -25,7 +26,8 @@ person_here(void)
 {
 	struct object *obj;
 
-	foreach_obj (obj) {
+	foreach_obj(obj)
+	{
 		if (distance_to(obj) == dist_here && obj->health > 0)
 			return obj;
 	}
@@ -38,9 +40,10 @@ get_passage_to(struct object *target)
 {
 	struct object *obj;
 
-	foreach_obj (obj) {
-		if (obj->location == player->location &&
-				obj->prospect == target)
+	foreach_obj(obj)
+	{
+		if (obj->location == player->location
+			&& obj->prospect == target)
 			return obj;
 	}
 
@@ -50,17 +53,26 @@ get_passage_to(struct object *target)
 enum distance
 distance_to(struct object *obj)
 {
-	return
-		!valid_obj(obj)					? dist_unknown_obj :
-		obj == player					? dist_player :
-		obj == player->location				? dist_location :
-		obj->location == player				? dist_held :
-		obj->location == player->location		? dist_here :
-		get_passage_to(obj) != NULL			? dist_overthere :
-		!valid_obj(obj->location)			? dist_not_here :
-		obj->location->location == player		? dist_held_contained :
-		obj->location->location == player->location	? dist_here_contained :
-								  dist_not_here;
+	return !valid_obj(obj) ? dist_unknown_obj
+			       : obj == player
+			? dist_player
+			: obj == player->location ? dist_location
+						  : obj->location == player
+					? dist_held
+					: obj->location == player->location
+						? dist_here
+						: get_passage_to(obj) != NULL
+							? dist_overthere
+							: !valid_obj(
+								  obj->location)
+								? dist_not_here
+								: obj->location->location
+										== player
+									? dist_held_contained
+									: obj->location->location
+											== player->location
+										? dist_here_contained
+										: dist_not_here;
 }
 
 void
@@ -80,7 +92,8 @@ weight_of_contents(struct object *container)
 	int sum = 0;
 	struct object *obj;
 
-	foreach_obj (obj) {
+	foreach_obj(obj)
+	{
 		if (obj->location == container)
 			sum += obj->weight;
 	}
blob - a85a81d1d2f614c61f3e32515811ffecd7c5ef12
blob + 7024675111095183a845c5f5d7dd90c267278553
--- parseexec.c
+++ parseexec.c
@@ -1,7 +1,7 @@
-#include "adventure.h"
-
 #include <stdio.h>
 
+#include "adventure.h"
+
 int
 exec_quit(void)
 {
@@ -38,7 +38,8 @@ exec_look(void)
 	else if (dist == dist_not_here)
 		printf("You don't see any %s here.\n", par->tag);
 	else if (dist == dist_overthere)
-		printf("You squeeze your eyes, but %s is too far away.\n", par->tag);
+		printf("You squeeze your eyes, but %s is too far away.\n",
+			par->tag);
 	else if (dist == dist_here_contained)
 		printf("Hard to see, try to get it first.\n");
 	else {
@@ -75,7 +76,8 @@ exec_go(void)
 int
 exec_get_from(void)
 {
-	return move_object(param_by_letter('A'), param_by_letter('B')->object, player);
+	return move_object(
+		param_by_letter('A'), param_by_letter('B')->object, player);
 }
 
 int
@@ -105,7 +107,8 @@ exec_ask(void)
 int
 exec_put_in(void)
 {
-	return move_object(param_by_letter('A'), player, param_by_letter('B')->object);
+	return move_object(
+		param_by_letter('A'), player, param_by_letter('B')->object);
 }
 
 int
@@ -156,34 +159,35 @@ int
 parseexec(const char *input)
 {
 	static const struct command commands[] = {
-		{&exec_quit,		"quit"},
-		{&exec_look_around,	"look"},
-		{&exec_look_around,	"look around"},
-		{&exec_look,		"look at A?"},
-		{&exec_look,		"look A?"},
-		{&exec_go,		"go to the A?"},
-		{&exec_go,		"go to A?"},
-		{&exec_go,		"go A?"},
-		{&exec_get_from,	"get A from B?"},
-		{&exec_get,		"get the A?"},
-		{&exec_get,		"get A?"},
-		{&exec_get,		"pick up the A?"},
-		{&exec_get,		"pick up a A?"},
-		{&exec_get,		"pick up A?"},
-		{&exec_get,		"pick the A?"},
-		{&exec_get,		"pick a A?"},
-		{&exec_get,		"pick A?"},
-		{&exec_put_in,		"put A in B?"},
-		{&exec_put_in,		"drop A in B?"},
-		{&exec_drop,		"drop A?"},
-		{&exec_give,		"give A?"},
-		{&exec_ask,		"ask A?"},
-		{&exec_inventory,	"inventory"},
-		{&exec_open,		"open A?"},
-		{&exec_close,		"close A?"},
-		{&exec_lock,		"lock A?"},
-		{&exec_unlock,		"unlock A?"},
-		{&exec_no_match,	"A?"},
+		{ &exec_quit, "quit" },
+		{ &exec_quit, "bye" },
+		{ &exec_look_around, "look" },
+		{ &exec_look_around, "look around" },
+		{ &exec_look, "look at A?" },
+		{ &exec_look, "look A?" },
+		{ &exec_go, "go to the A?" },
+		{ &exec_go, "go to A?" },
+		{ &exec_go, "go A?" },
+		{ &exec_get_from, "get A from B?" },
+		{ &exec_get, "get the A?" },
+		{ &exec_get, "get A?" },
+		{ &exec_get, "pick up the A?" },
+		{ &exec_get, "pick up a A?" },
+		{ &exec_get, "pick up A?" },
+		{ &exec_get, "pick the A?" },
+		{ &exec_get, "pick a A?" },
+		{ &exec_get, "pick A?" },
+		{ &exec_put_in, "put A in B?" },
+		{ &exec_put_in, "drop A in B?" },
+		{ &exec_drop, "drop A?" },
+		{ &exec_give, "give A?" },
+		{ &exec_ask, "ask A?" },
+		{ &exec_inventory, "inventory" },
+		{ &exec_open, "open A?" },
+		{ &exec_close, "close A?" },
+		{ &exec_lock, "lock A?" },
+		{ &exec_unlock, "unlock A?" },
+		{ &exec_no_match, "A?" },
 	};
 
 	const struct command *cmd;
blob - b058a863c858125593a005c6c08423a24f67b742
blob + 3c0a6f3e79d7f5ec6fa1d49aee1028b8424fff35
--- toggle.c
+++ toggle.c
@@ -97,6 +97,7 @@ toggle_box_lock(struct object *o)
 		swap_locations(closed_box, locked_box);
 		return "OK.";
 	} else {
-		return "You try really hard, but the closed box won't open without a key.";
+		return "You try really hard, but the closed box won't open "
+		       "without a key.";
 	}
 }