[mw-devel] [Git][arthur/mw][master] 2 commits: Give some query result variables a better name

Andrew Price welshbyte at sucs.org
Sat Nov 10 23:50:44 GMT 2018


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
667ef92b by Andrew Price at 2018-11-10T21:59:56+00:00
Give some query result variables a better name

- - - - -
613df476 by Andrew Price at 2018-11-10T22:05:34+00:00
Whitespace fixup

- - - - -


2 changed files:

- src/rooms.h
- src/sqlite.c


Changes:

=====================================
src/rooms.h
=====================================
--- a/src/rooms.h
+++ b/src/rooms.h
@@ -5,13 +5,13 @@
 
 struct room
 {
-	int32_t num;				/* room number */
-	char *name;				/* room name */
-	char *desc;				/* description */
-	char *prompt;				/* alternate prompt */
-	int32_t hidden;				/* cant find room using 'room' command */
-	int32_t sproof;				/* soundproof? */
-	int32_t locked;				/* locked? */
+	int32_t num;     /* room number */
+	char *name;      /* room name */
+	char *desc;      /* description */
+	char *prompt;    /* alternate prompt */
+	int32_t hidden;  /* cant find room using 'room' command */
+	int32_t sproof;  /* soundproof? */
+	int32_t locked;  /* locked? */
 };
 
 void RoomInit(struct room *room);


=====================================
src/sqlite.c
=====================================
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -189,32 +189,30 @@ void db_free(struct db_result *result)
 
 char * db_room_get(int room, const char *opt)
 {
-	struct db_result *old;
+	struct db_result *qres;
 	char *value;
 	char *out = NULL;
-
 	char *query = sqlite3_mprintf("SELECT * from "USERDB_ROOMS" WHERE room=%d AND opt=%Q", room, opt);
-	old  = db_query(USERSQL, query, 1);
+	qres = db_query(USERSQL, query, 1);
 	sqlite3_free(query);
 
-	if (old == NULL) return NULL;
-	if (db_numrows(old) < 1) goto out_dbfree;
+	if (qres == NULL) return NULL;
+	if (db_numrows(qres) < 1) goto out_dbfree;
 
-	if ((value = db_item(old, 0, "arg"))==NULL)
+	if ((value = db_item(qres, 0, "arg"))==NULL)
 		goto out_dbfree;
 
 	out = strdup(value);
 out_dbfree:
-	db_free(old);
+	db_free(qres);
 	return out;
 }
 
 void db_room_set(int room, const char *opt, const char *arg)
 {
-	struct db_result *old;
-
+	struct db_result *qres;
 	char *query = sqlite3_mprintf("SELECT * from "USERDB_ROOMS" WHERE room=%d AND opt=%Q", room, opt);
-	old  = db_query(USERSQL, query, 1);
+	qres = db_query(USERSQL, query, 1);
 	sqlite3_free(query);
 
 	/* set a new value */
@@ -224,7 +222,7 @@ void db_room_set(int room, const char *opt, const char *arg)
 		db_free(db_query(USERSQL, q, 1));
 		sqlite3_free(q);
 	}else
-	if (old != NULL && old->rows > 0) {
+	if (qres != NULL && qres->rows > 0) {
 		char *q= sqlite3_mprintf("UPDATE "USERDB_ROOMS" SET arg=%Q WHERE room=%d AND opt=%Q", arg, room, opt);
 		db_free(db_query(USERSQL, q, 1));
 		sqlite3_free(q);
@@ -244,5 +242,5 @@ void db_room_set(int room, const char *opt, const char *arg)
 		db_free(res);
 		sqlite3_free(q);
 	}
-	db_free(old);
+	db_free(qres);
 }



View it on GitLab: https://projects.sucs.org/arthur/mw/compare/04d73cbad5c3c5dfbe27f487aef5b18ba08300ab...613df4762c4ecd35c4353aac64128a7a9dcddb47

-- 
View it on GitLab: https://projects.sucs.org/arthur/mw/compare/04d73cbad5c3c5dfbe27f487aef5b18ba08300ab...613df4762c4ecd35c4353aac64128a7a9dcddb47
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20181110/8d263195/attachment-0001.html>


More information about the mw-devel mailing list