Skip to content

Commit

Permalink
Make locale configurable.
Browse files Browse the repository at this point in the history
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@610 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
  • Loading branch information
paxed committed Oct 4, 2011
1 parent acf2705 commit 1d7ceb5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.l
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ watch_columns { return TYPE_WATCH_COLUMNS; }
commands { return TYPE_CMDQUEUE; }
postcommands { return TYPE_POSTCMDQUEUE; }
encoding { return TYPE_ENCODING; }
locale { return TYPE_LOCALE; }
yes { yylval.i = 1; return TYPE_BOOL; }
no { yylval.i = 0; return TYPE_BOOL; }
dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; }
Expand Down
9 changes: 8 additions & 1 deletion config.y
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int sortmode_number(const char *sortmode_name) {
%token TYPE_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR
%token TYPE_POSTCMDQUEUE
%token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE
%token TYPE_ENCODING
%token TYPE_ENCODING TYPE_LOCALE
%token <s> TYPE_VALUE
%token <i> TYPE_NUMBER TYPE_CMDQUEUENAME
%type <kt> KeyType
Expand Down Expand Up @@ -206,6 +206,11 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
globalconfig.passwd = strdup($3);
break;

case TYPE_LOCALE:
if (globalconfig.locale) free(globalconfig.locale);
globalconfig.locale = strdup($3);
break;

default:
fprintf(stderr, "%s:%d: token %s does not take a string, bailing out\n",
config, line, lookup_token($1));
Expand Down Expand Up @@ -622,6 +627,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
| TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; }
| TYPE_ENCODING { $$ = TYPE_ENCODING; }
| TYPE_LOCALE { $$ = TYPE_LOCALE; }
| TYPE_RC_FMT { $$ = TYPE_RC_FMT; }
| TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; }
| TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; }
Expand Down Expand Up @@ -657,6 +663,7 @@ const char* lookup_token (int t)
case TYPE_WATCH_SORTMODE: return "sortmode";
case TYPE_WATCH_COLUMNS: return "watch_columns";
case TYPE_SERVER_ID: return "server_id";
case TYPE_LOCALE: return "locale";
default: abort();
}
}
Expand Down
4 changes: 3 additions & 1 deletion dgamelaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,9 @@ main (int argc, char** argv)
}
}

setlocale(LC_CTYPE, "en_US.UTF-8");
if (globalconfig.locale) {
setlocale(LC_CTYPE, globalconfig.locale);
}

if (showplayers) {
inprogressdisplay(-1);
Expand Down
1 change: 1 addition & 0 deletions dgamelaunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ struct dg_globalconfig
int allow_registration; /* allow registering new nicks */
int sortmode; /* default watching-screen sortmode */
char *server_id; /* string for the server name or whatever */
char *locale;

struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];

Expand Down
1 change: 1 addition & 0 deletions dgl-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ create_config ()
if (!globalconfig.allow_registration) globalconfig.allow_registration = 1;
globalconfig.menulist = NULL;
globalconfig.server_id = NULL;
globalconfig.locale = NULL;

globalconfig.shed_uid = (uid_t)-1;
globalconfig.shed_gid = (gid_t)-1;
Expand Down
3 changes: 3 additions & 0 deletions examples/dgamelaunch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ banner = "/dgl-banner"
shed_uid = 5
shed_gid = 60

# Locale. Leaving this out, dgamelaunch will not explicitly set locale.
locale = "en_US.UTF-8"

# Maximum time in seconds user can idle in the dgamelaunch menus
# before dgl exits. Default value is 0, which disables the idling timer.
# Does not apply to external programs or config editors.
Expand Down

0 comments on commit 1d7ceb5

Please sign in to comment.