Skip to content

Commit 3c3c946

Browse files
committed
(runloop) Condense conditionals)
(d3d9hlsl) Silence warnings and some code style nits
1 parent b20f011 commit 3c3c946

2 files changed

Lines changed: 56 additions & 33 deletions

File tree

gfx/drivers/d3d9hlsl.c

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5683,17 +5683,17 @@ static char *d3d9_hlsl_init_vs_output_members(const char *source)
56835683
static char *d3d9_hlsl_convert_macro_loops(const char *source)
56845684
{
56855685
/* Find #define candidates: single-param function-like macros */
5686-
const char *p;
56875686
char macro_name[128];
56885687
char macro_param[64];
56895688
const char *macro_body_start = NULL;
56905689
size_t macro_body_len = 0;
5691-
size_t macro_name_len = 0;
5692-
size_t macro_param_len = 0;
5690+
#ifdef DEBUG
5691+
size_t macro_name_len = 0;
5692+
size_t macro_param_len = 0;
5693+
#endif
56935694
const char *macro_define_start = NULL;
5694-
const char *macro_define_end = NULL;
5695-
5696-
p = source;
5695+
const char *macro_define_end = NULL;
5696+
const char *p = source;
56975697
while (*p)
56985698
{
56995699
/* Look for #define at start of line */
@@ -5706,22 +5706,25 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
57065706
const char *nm = dir + 6;
57075707
const char *nm_end, *pp, *pp_end, *body, *body_end;
57085708

5709-
while (*nm == ' ' || *nm == '\t') nm++;
5709+
while (*nm == ' ' || *nm == '\t')
5710+
nm++;
57105711
nm_end = nm;
57115712
while (d3d9_hlsl_is_ident_char(*nm_end)) nm_end++;
57125713

57135714
/* Check for (param) */
57145715
if (*nm_end == '(' && nm_end > nm)
57155716
{
57165717
pp = nm_end + 1;
5717-
while (*pp == ' ' || *pp == '\t') pp++;
5718+
while (*pp == ' ' || *pp == '\t')
5719+
pp++;
57185720
pp_end = pp;
57195721
while (d3d9_hlsl_is_ident_char(*pp_end)) pp_end++;
57205722
if (pp_end > pp && *pp_end == ')')
57215723
{
57225724
/* Found #define NAME(PARAM) — get the body */
57235725
body = pp_end + 1;
5724-
while (*body == ' ' || *body == '\t') body++;
5726+
while (*body == ' ' || *body == '\t')
5727+
body++;
57255728

57265729
/* Find end of body (handle line continuations) */
57275730
body_end = body;
@@ -5730,7 +5733,10 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
57305733
if (*body_end == '\n')
57315734
{
57325735
if (body_end > body && body_end[-1] == '\\')
5733-
{ body_end++; continue; }
5736+
{
5737+
body_end++;
5738+
continue;
5739+
}
57345740
break;
57355741
}
57365742
body_end++;
@@ -5746,7 +5752,10 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
57465752
if (strncmp(scan, pp, pl) == 0
57475753
&& (scan == body || !d3d9_hlsl_is_ident_char(scan[-1]))
57485754
&& !d3d9_hlsl_is_ident_char(scan[pl]))
5749-
{ found = true; break; }
5755+
{
5756+
found = true;
5757+
break;
5758+
}
57505759
scan++;
57515760
}
57525761

@@ -5755,9 +5764,9 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
57555764
{
57565765
/* Now search for consecutive invocations:
57575766
* NAME(0) NAME(1) ... NAME(N) */
5758-
int max_seq = -1;
5767+
int max_seq = -1;
57595768
const char *seq_start = NULL, *seq_end_ptr = NULL;
5760-
const char *s = source;
5769+
const char *s = source;
57615770

57625771
while (*s)
57635772
{
@@ -5815,28 +5824,33 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
58155824
if (max_seq >= 4 && seq_start && seq_end_ptr)
58165825
{
58175826
/* Build the replacement loop */
5827+
size_t cap, opos;
58185828
size_t src_len_full = strlen(source);
5819-
size_t body_l = (size_t)(body_end - body);
5829+
size_t body_l = (size_t)(body_end - body);
58205830
char *out;
5821-
size_t cap, opos;
5822-
size_t nml = (size_t)(nm_end - nm);
5831+
size_t nml = (size_t)(nm_end - nm);
58235832

58245833
memcpy(macro_name, nm, nml);
5825-
macro_name[nml] = '\0';
5826-
macro_name_len = nml;
5834+
macro_name[nml] = '\0';
5835+
#ifdef DEBUG
5836+
macro_name_len = nml;
5837+
#endif
58275838
memcpy(macro_param, pp, (size_t)(pp_end - pp));
58285839
macro_param[(size_t)(pp_end - pp)] = '\0';
5829-
macro_param_len = (size_t)(pp_end - pp);
5830-
macro_body_start = body;
5831-
macro_body_len = body_l;
5832-
macro_define_start = p;
5833-
macro_define_end = body_end;
5840+
#ifdef DEBUG
5841+
macro_param_len = (size_t)(pp_end - pp);
5842+
#endif
5843+
macro_body_start = body;
5844+
macro_body_len = body_l;
5845+
macro_define_start = p;
5846+
macro_define_end = body_end;
58345847
if (*macro_define_end == '\n')
58355848
macro_define_end++;
58365849

58375850
cap = src_len_full + body_l + 256;
58385851
out = (char*)malloc(cap);
5839-
if (!out) return NULL;
5852+
if (!out)
5853+
return NULL;
58405854
opos = 0;
58415855

58425856
/* Copy everything before the #define, commenting it out */
@@ -5849,7 +5863,7 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
58495863
/* Comment out the #define line */
58505864
{
58515865
const char *dl = "/* ";
5852-
size_t dll = 3;
5866+
size_t dll = 3;
58535867
size_t def_len = (size_t)(macro_define_end - macro_define_start);
58545868
/* Strip any trailing newline from the define for the comment */
58555869
size_t comment_len = def_len;
@@ -5917,7 +5931,10 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
59175931
char *tmp;
59185932
cap *= 2;
59195933
if (!(tmp = (char*)realloc(out, cap)))
5920-
{ free(out); return NULL; }
5934+
{
5935+
free(out);
5936+
return NULL;
5937+
}
59215938
out = tmp;
59225939
}
59235940
out[opos++] = *bp_src++;
@@ -5932,7 +5949,10 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
59325949
char *tmp;
59335950
cap *= 2;
59345951
if (!(tmp = (char*)realloc(out, cap)))
5935-
{ free(out); return NULL; }
5952+
{
5953+
free(out);
5954+
return NULL;
5955+
}
59365956
out = tmp;
59375957
}
59385958
memcpy(out + opos, cl, 3); opos += 3;
@@ -5946,7 +5966,10 @@ static char *d3d9_hlsl_convert_macro_loops(const char *source)
59465966
char *tmp;
59475967
cap *= 2;
59485968
if (!(tmp = (char*)realloc(out, cap)))
5949-
{ free(out); return NULL; }
5969+
{
5970+
free(out);
5971+
return NULL;
5972+
}
59505973
out = tmp;
59515974
}
59525975
memcpy(out + opos, seq_end_ptr, tail);

runloop.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4085,11 +4085,11 @@ void runloop_event_deinit_core(void)
40854085
/* Remap save and cleanup logic should be placed before
40864086
* core_unload_game(), to ensure that input description data
40874087
* does not become invalid before remaps are saved. */
4088-
if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
4089-
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
4090-
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE)
4091-
|| (runloop_st->name.remapfile && *runloop_st->name.remapfile)
4092-
)
4088+
if ((runloop_st->flags & (
4089+
RUNLOOP_FLAG_REMAPS_CORE_ACTIVE
4090+
| RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE
4091+
| RUNLOOP_FLAG_REMAPS_GAME_ACTIVE))
4092+
|| (runloop_st->name.remapfile && *runloop_st->name.remapfile))
40934093
{
40944094
input_remapping_deinit(settings->bools.remap_save_on_exit);
40954095
input_remapping_set_defaults(true);

0 commit comments

Comments
 (0)