Move locale support to "src/main.c"
This commit is contained in:
parent
d35c4c0844
commit
bc7eff3c4f
24
src/dwm.c
24
src/dwm.c
|
@ -10,7 +10,6 @@
|
|||
#include "unit.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -268,20 +267,20 @@ static void (*handler[LASTEvent])(XEvent*) = {
|
|||
|
||||
#include "config.h"
|
||||
|
||||
/****************************
|
||||
* function implementations *
|
||||
****************************/
|
||||
/************************************
|
||||
* Private function implementations *
|
||||
************************************/
|
||||
|
||||
#include "dwm/handlers.c"
|
||||
#include "dwm/layouts.c"
|
||||
#include "dwm/xerror.c"
|
||||
|
||||
/***********************************
|
||||
* Public function implementations *
|
||||
***********************************/
|
||||
|
||||
int dwm_main()
|
||||
{
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) {
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
}
|
||||
|
||||
if (!(dpy = XOpenDisplay(NULL))) {
|
||||
die("polytreewm: cannot open display");
|
||||
}
|
||||
|
@ -306,6 +305,15 @@ int dwm_main()
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
bool dwm_has_locale_support()
|
||||
{
|
||||
return XSupportsLocale();
|
||||
}
|
||||
|
||||
/************************************
|
||||
* Private function implementations *
|
||||
************************************/
|
||||
|
||||
int applysizehints(
|
||||
Client *c,
|
||||
ClientGeometry client_geometry,
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _DWM_H
|
||||
#define _DWM_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
int dwm_main();
|
||||
bool dwm_has_locale_support();
|
||||
|
||||
#endif // _DWM_H
|
||||
|
|
17
src/main.c
17
src/main.c
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "dwm.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -18,6 +19,10 @@ int main(int argc, char *argv[])
|
|||
die("usage: polytreewm [-v]");
|
||||
}
|
||||
|
||||
if (!setlocale(LC_CTYPE, "") || !dwm_has_locale_support()) {
|
||||
warning("no locale support");
|
||||
}
|
||||
|
||||
return dwm_main(argc, argv);
|
||||
}
|
||||
|
||||
|
@ -45,3 +50,15 @@ void die_perror(const char *const fmt, ...)
|
|||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void warning(const char *const fmt, ...)
|
||||
{
|
||||
fputs("WARN: ", stderr);
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
|
||||
void die(const char *fmt, ...);
|
||||
void die_perror(const char *fmt, ...);
|
||||
void warning(const char *fmt, ...);
|
||||
|
||||
#endif // _MAIN_H
|
||||
|
|
Loading…
Reference in New Issue