diff options
author | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-10-03 03:17:37 -0700 |
---|---|---|
committer | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-10-03 03:17:37 -0700 |
commit | 21d38a6bfc3bcfa8c115df26847b7c2b4d986565 (patch) | |
tree | 15d18b7f41ca16ff0f728369a5aa43e5608f3e4f /src/map/tmw.c | |
parent | ba5d9bec7ce5330062481643905a6fd60126002c (diff) | |
download | tmwa-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.c | 24 |
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'; +} |