summaryrefslogtreecommitdiff
path: root/src/map/tmw.c
diff options
context:
space:
mode:
authorremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-10-03 03:17:37 -0700
committerremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-10-03 03:17:37 -0700
commit21d38a6bfc3bcfa8c115df26847b7c2b4d986565 (patch)
tree15d18b7f41ca16ff0f728369a5aa43e5608f3e4f /src/map/tmw.c
parentba5d9bec7ce5330062481643905a6fd60126002c (diff)
downloadtmwa-21d38a6bfc3bcfa8c115df26847b7c2b4d986565.tar.gz
tmwa-21d38a6bfc3bcfa8c115df26847b7c2b4d986565.tar.bz2
tmwa-21d38a6bfc3bcfa8c115df26847b7c2b4d986565.tar.xz
tmwa-21d38a6bfc3bcfa8c115df26847b7c2b4d986565.zip
Do not allow empty/whitespace-only party/guild names
Also makes minor style adjustments and cleans up comments.
Diffstat (limited to 'src/map/tmw.c')
-rw-r--r--src/map/tmw.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/map/tmw.c b/src/map/tmw.c
index 783875a..a71c93c 100644
--- a/src/map/tmw.c
+++ b/src/map/tmw.c
@@ -162,3 +162,27 @@ void tmw_GmHackMsg (const char *fmt, ...)
battle_config.hack_info_GM_level, outbuf,
strlen (outbuf) + 1);
}
+
+/* Remove leading and trailing spaces from a string, modifying in place. */
+void tmw_TrimStr (char *str)
+{
+ char *l;
+ char *a;
+ char *e;
+
+ if (!*str)
+ return;
+
+ e = str + strlen (str) - 1;
+
+ /* Skip all leading spaces. */
+ for (l = str; *l && isspace (*l); ++l)
+ ;
+
+ /* Find the end of the string, or the start of trailing spaces. */
+ for (a = e; *a && a > l && isspace (*a); --a)
+ ;
+
+ memmove (str, l, a - l + 1);
+ str[a - l + 1] = '\0';
+}