mirror of
https://github.com/anope/anope.git
synced 2026-07-10 14:43:13 +02:00
Move getstring() and getstring2() from macros to functions. This fixes a bunch of warnings, and means they are actually *readable*, as well as type-safe and const.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1975 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+4
-8
@@ -533,14 +533,10 @@ E char *langnames[NUM_LANGS];
|
||||
E int langlist[NUM_LANGS];
|
||||
|
||||
E void lang_init();
|
||||
#define getstring(na,index) \
|
||||
(langtexts[((na) && (static_cast<NickAlias *>(na))->nc && !((static_cast<NickAlias *>(na))->status & NS_FORBIDDEN) ? (static_cast<NickAlias *>(na))->nc->language : NSDefLanguage)][(index)])
|
||||
#define getstring2(nc,index) \
|
||||
(langtexts[((nc) ? (static_cast<NickCore *>(nc))->language : NSDefLanguage)][(index)])
|
||||
E int strftime_lang(char *buf, int size, User * u, int format,
|
||||
struct tm *tm);
|
||||
E void syntax_error(char *service, User * u, const char *command,
|
||||
int msgnum);
|
||||
E int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm);
|
||||
E void syntax_error(char *service, User * u, const char *command, int msgnum);
|
||||
E const char *getstring(NickAlias *na, int index);
|
||||
E const char *getstring2(NickCore *nc, int index);
|
||||
|
||||
|
||||
/**** log.c ****/
|
||||
|
||||
@@ -306,4 +306,29 @@ void syntax_error(char *service, User * u, const char *command, int msgnum)
|
||||
notice_lang(service, u, MORE_INFO, service, command);
|
||||
}
|
||||
|
||||
const char *getstring(NickAlias *na, int index)
|
||||
{
|
||||
// Default to config
|
||||
int langidx = NSDefLanguage;
|
||||
|
||||
// If they are registered (na->nc), and NOT forbidden
|
||||
if (na->nc && !na->status & NS_FORBIDDEN)
|
||||
langidx = na->nc->language; // set language to their nickcore's language
|
||||
|
||||
return langtexts[langidx][index];
|
||||
}
|
||||
|
||||
const char *getstring2(NickCore *nc, int index)
|
||||
{
|
||||
// Default to config
|
||||
int langidx = NSDefLanguage;
|
||||
|
||||
if (nc)
|
||||
{
|
||||
langidx = nc->language;
|
||||
}
|
||||
|
||||
return langtexts[langidx][index];
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
+1
-1
@@ -423,7 +423,7 @@ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds)
|
||||
int need_comma = 0;
|
||||
|
||||
char buf2[64], *end;
|
||||
char *comma = getstring(na, COMMA_SPACE);
|
||||
const char *comma = getstring(na, COMMA_SPACE);
|
||||
|
||||
/* We first calculate everything */
|
||||
days = seconds / 86400;
|
||||
|
||||
Reference in New Issue
Block a user