Skip to content

Commit 7cab041

Browse files
committed
Fix #8: No more possible POSIX reserved type names
1 parent e6e2164 commit 7cab041

File tree

6 files changed

+58
-60
lines changed

6 files changed

+58
-60
lines changed

src/conf.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <string.h>
2424

2525
static int config_setting_lookup_dim(const config_setting_t *setting,
26-
const char *name, dim_t *value)
26+
const char *name, Dim *value)
2727
{
2828
double rel;
2929
int abs;
@@ -99,7 +99,7 @@ static int config_setting_lookup_color(const config_setting_t *setting,
9999
}
100100

101101
static int config_setting_lookup_colorspec(const config_setting_t *setting,
102-
const char *name, colorspec_t *value)
102+
const char *name, Colorspec *value)
103103
{
104104
config_setting_t *colorspec_setting;
105105
int success_status = CONFIG_FALSE;
@@ -119,7 +119,7 @@ static int config_setting_lookup_colorspec(const config_setting_t *setting,
119119

120120
static int config_setting_lookup_overflowmode(const config_setting_t *setting,
121121
const char *name,
122-
overflow_mode_t *value)
122+
Overflow_mode *value)
123123
{
124124
const char *stringvalue;
125125
int success_status = CONFIG_FALSE;
@@ -148,14 +148,13 @@ static int config_setting_lookup_overflowmode(const config_setting_t *setting,
148148
return success_status;
149149
}
150150

151-
style_t parse_style_config(FILE *file, const char *stylename,
152-
style_t default_style)
151+
Style parse_style_config(FILE *file, const char *stylename, Style default_style)
153152
{
154153
config_t config;
155154
config_setting_t *style_config;
156155
config_setting_t *color_config;
157156
config_init(&config);
158-
style_t style = default_style;
157+
Style style = default_style;
159158

160159
if (config_read(&config, file))
161160
{

src/conf.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,41 @@ typedef struct
2525
const char *fg;
2626
const char *bg;
2727
const char *border;
28-
} colorspec_t;
28+
} Colorspec;
2929

3030
typedef struct
3131
{
3232
double rel;
3333
int abs;
34-
} dim_t;
34+
} Dim;
3535

3636
typedef enum
3737
{
3838
HIDDEN,
3939
PROPORTIONAL
40-
} overflow_mode_t;
40+
} Overflow_mode;
4141

4242
typedef struct
4343
{
44-
dim_t x;
45-
dim_t y;
46-
dim_t length;
44+
Dim x;
45+
Dim y;
46+
Dim length;
4747
int thickness;
4848
int border;
4949
int padding;
5050
int outline;
51-
overflow_mode_t overflow;
51+
Overflow_mode overflow;
5252
struct
5353
{
54-
colorspec_t normal;
55-
colorspec_t overflow;
56-
colorspec_t alt;
57-
colorspec_t altoverflow;
54+
Colorspec normal;
55+
Colorspec overflow;
56+
Colorspec alt;
57+
Colorspec altoverflow;
5858
} color;
59-
} style_t;
59+
} Style;
6060

6161
/* clang-format off */
62-
#define DEFAULT_CONFIGURATION (style_t) {\
62+
#define DEFAULT_CONFIGURATION (Style) {\
6363
.x =\
6464
{\
6565
.rel = 0.5,\
@@ -114,7 +114,7 @@ typedef struct
114114
#define DEFAULT_CONFIG_APPNAME "xob"
115115
#define DEFAULT_CONFIG_FILENAME "styles.cfg"
116116

117-
style_t parse_style_config(FILE *filename, const char *stylename,
118-
style_t default_style);
117+
Style parse_style_config(FILE *filename, const char *stylename,
118+
Style default_style);
119119

120120
#endif /* __CONF_H__ */

src/display.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int fit_in(int value, int min, int max)
2929

3030
/* Get graphic context from a hex color specification string */
3131
/* NULL is returned in case of a parse error. */
32-
static GC gc_from_string(x_context_t x, const char *hexcolorstring)
32+
static GC gc_from_string(X_context x, const char *hexcolorstring)
3333
{
3434
XColor color;
3535
GC gc = XCreateGC(x.display, x.window, 0, NULL);
@@ -47,7 +47,7 @@ static GC gc_from_string(x_context_t x, const char *hexcolorstring)
4747
}
4848

4949
/* Draw an empty bar with the given border color */
50-
static void draw_empty(x_context_t x, geometry_context_t g, gc_colorset_t color)
50+
static void draw_empty(X_context x, Geometry_context g, Gc_colorset color)
5151
{
5252
/* Outline */
5353
XFillRectangle(x.display, x.window, color.bg, 0, 0,
@@ -64,14 +64,13 @@ static void draw_empty(x_context_t x, geometry_context_t g, gc_colorset_t color)
6464
}
6565

6666
/* Draw a given length of filled bar with the given color */
67-
static void draw_content(x_context_t x, geometry_context_t g, int length,
68-
GC color)
67+
static void draw_content(X_context x, Geometry_context g, int length, GC color)
6968
{
7069
XFillRectangle(x.display, x.window, color, g.outline + g.border + g.padding,
7170
g.outline + g.border + g.padding, length, g.height);
7271
}
7372
/* Draw a separator (padding-sized gap) at the given position */
74-
static void draw_separator(x_context_t x, geometry_context_t g, int position,
73+
static void draw_separator(X_context x, Geometry_context g, int position,
7574
GC color)
7675
{
7776
XFillRectangle(x.display, x.window, color,
@@ -82,9 +81,9 @@ static void draw_separator(x_context_t x, geometry_context_t g, int position,
8281
/* PUBLIC Returns a new display context from a given configuration. If the
8382
* .x.display field of the returned display context is NULL, display could not
8483
* have been opened.*/
85-
display_context_t init(style_t conf)
84+
Display_context init(Style conf)
8685
{
87-
display_context_t dc;
86+
Display_context dc;
8887
Window root;
8988
XSetWindowAttributes window_attributes;
9089
int topleft_x;
@@ -171,13 +170,13 @@ display_context_t init(style_t conf)
171170
}
172171

173172
/* PUBLIC Show a bar filled at value/cap in normal or alternative mode */
174-
display_context_t show(display_context_t dc, int value, int cap,
175-
overflow_mode_t overflow_mode, show_mode_t show_mode)
173+
Display_context show(Display_context dc, int value, int cap,
174+
Overflow_mode overflow_mode, Show_mode show_mode)
176175
{
177-
display_context_t newdc = dc;
176+
Display_context newdc = dc;
178177

179-
gc_colorset_t colorset;
180-
gc_colorset_t colorset_overflow_proportional;
178+
Gc_colorset colorset;
179+
Gc_colorset colorset_overflow_proportional;
181180

182181
if (!dc.x.mapped)
183182
{
@@ -228,9 +227,9 @@ display_context_t show(display_context_t dc, int value, int cap,
228227
}
229228

230229
/* PUBLIC Hide the window */
231-
display_context_t hide(display_context_t dc)
230+
Display_context hide(Display_context dc)
232231
{
233-
display_context_t newdc = dc;
232+
Display_context newdc = dc;
234233

235234
if (dc.x.mapped)
236235
{

src/display.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef enum
2626
{
2727
NORMAL,
2828
ALTERNATIVE
29-
} show_mode_t;
29+
} Show_mode;
3030

3131
typedef struct
3232
{
@@ -35,22 +35,22 @@ typedef struct
3535
Screen *screen;
3636
Window window;
3737
Bool mapped;
38-
} x_context_t;
38+
} X_context;
3939

4040
typedef struct
4141
{
4242
GC fg;
4343
GC bg;
4444
GC border;
45-
} gc_colorset_t;
45+
} Gc_colorset;
4646

4747
typedef struct
4848
{
49-
gc_colorset_t normal;
50-
gc_colorset_t overflow;
51-
gc_colorset_t alt;
52-
gc_colorset_t altoverflow;
53-
} color_context_t;
49+
Gc_colorset normal;
50+
Gc_colorset overflow;
51+
Gc_colorset alt;
52+
Gc_colorset altoverflow;
53+
} Color_context;
5454

5555
typedef struct
5656
{
@@ -59,18 +59,18 @@ typedef struct
5959
int padding;
6060
int width;
6161
int height;
62-
} geometry_context_t;
62+
} Geometry_context;
6363

6464
typedef struct
6565
{
66-
x_context_t x;
67-
color_context_t color;
68-
geometry_context_t geometry;
69-
} display_context_t;
66+
X_context x;
67+
Color_context color;
68+
Geometry_context geometry;
69+
} Display_context;
7070

71-
display_context_t init(style_t conf);
72-
display_context_t show(display_context_t dc, int value, int cap,
73-
overflow_mode_t overflow_mode, show_mode_t show_mode);
74-
display_context_t hide(display_context_t dc);
71+
Display_context init(Style conf);
72+
Display_context show(Display_context dc, int value, int cap,
73+
Overflow_mode overflow_mode, Show_mode show_mode);
74+
Display_context hide(Display_context dc);
7575

7676
#endif /* __DISPLAY_H__ */

src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
9191

9292
/* Style */
9393
FILE *config_file = NULL;
94-
style_t style = DEFAULT_CONFIGURATION;
94+
Style style = DEFAULT_CONFIGURATION;
9595
char xdg_config_file_path[PATH_MAX];
9696
char real_config_file_path[PATH_MAX];
9797

@@ -169,8 +169,8 @@ int main(int argc, char *argv[])
169169
/* Display */
170170
bool displayed = false;
171171
bool listening = true;
172-
input_value_t input_value;
173-
display_context_t display_context = init(style);
172+
Input_Value input_value;
173+
Display_context display_context = init(style);
174174

175175
if (display_context.x.display == NULL)
176176
{
@@ -228,9 +228,9 @@ int main(int argc, char *argv[])
228228
return EXIT_SUCCESS;
229229
}
230230

231-
input_value_t parse_input(void)
231+
Input_Value parse_input(void)
232232
{
233-
input_value_t input_value;
233+
Input_Value input_value;
234234
char altflag;
235235

236236
input_value.valid = false;

src/main.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ typedef struct
2727
{
2828
bool valid;
2929
int value;
30-
show_mode_t show_mode;
31-
} input_value_t;
30+
Show_mode show_mode;
31+
} Input_Value;
3232

33-
input_value_t parse_input(void);
33+
Input_Value parse_input(void);
3434

3535
#endif

0 commit comments

Comments
 (0)