2626#include <string/stdstring.h>
2727#include <string.h>
2828
29- const size_t disc_strings_length = 3 ;
29+ #define DISC_STRINGS_LENGTH 3
30+ #define REGION_STRINGS_LENGTH 20
3031
31- const char * disc_strings [3 ] = {
32+ const char * disc_strings [DISC_STRINGS_LENGTH ] = {
3233 "(CD" ,
3334 "(Disc" ,
3435 "(Disk"
3536};
3637
37- const size_t region_strings_length = 20 ;
38-
3938/*
4039 * We'll use the standard No-Intro regions for now.
4140 */
42- const char * region_strings [20 ] = {
41+ const char * region_strings [REGION_STRINGS_LENGTH ] = {
4342 "(Australia)" , /* Don’t use with Europe */
4443 "(Brazil)" ,
4544 "(Canada)" , /* Don’t use with USA */
@@ -129,16 +128,16 @@ static bool left_exclusion(char *left,
129128 char exclusion_string [32 ];
130129 char comparison_string [32 ];
131130
132- strlcpy (exclusion_string , left , 32 );
131+ strlcpy (exclusion_string , left , sizeof ( exclusion_string ) );
133132 string_to_upper (exclusion_string );
134133
135134 for (i = 0 ; i < (unsigned )strings_count ; i ++ )
136135 {
137- strlcpy (comparison_string , strings [i ], 32 );
136+ strlcpy (comparison_string , strings [i ], sizeof ( comparison_string ) );
138137 string_to_upper (comparison_string );
139138
140- if (string_is_equal_fast (exclusion_string ,
141- comparison_string , strlen ( comparison_string ) ))
139+ if (string_is_equal (exclusion_string ,
140+ comparison_string ))
142141 return true;
143142 }
144143
@@ -148,20 +147,20 @@ static bool left_exclusion(char *left,
148147static bool left_parens_or_brackets_excluding_region (char * left )
149148{
150149 return left_parens_or_brackets (left )
151- && !left_exclusion (left , region_strings , region_strings_length );
150+ && !left_exclusion (left , region_strings , REGION_STRINGS_LENGTH );
152151}
153152
154153static bool left_parens_or_brackets_excluding_disc (char * left )
155154{
156155 return left_parens_or_brackets (left )
157- && !left_exclusion (left , disc_strings , disc_strings_length );
156+ && !left_exclusion (left , disc_strings , DISC_STRINGS_LENGTH );
158157}
159158
160159static bool left_parens_or_brackets_excluding_region_or_disc (char * left )
161160{
162161 return left_parens_or_brackets (left )
163- && !left_exclusion (left , region_strings , region_strings_length )
164- && !left_exclusion (left , disc_strings , disc_strings_length );
162+ && !left_exclusion (left , region_strings , REGION_STRINGS_LENGTH )
163+ && !left_exclusion (left , disc_strings , DISC_STRINGS_LENGTH );
165164}
166165
167166void label_remove_parens (char * label )
@@ -176,20 +175,24 @@ void label_remove_brackets(char *label)
176175
177176void label_remove_parens_and_brackets (char * label )
178177{
179- label_sanitize (label , left_parens_or_brackets , right_parens_or_brackets );
178+ label_sanitize (label , left_parens_or_brackets ,
179+ right_parens_or_brackets );
180180}
181181
182182void label_keep_region (char * label )
183183{
184- label_sanitize (label , left_parens_or_brackets_excluding_region , right_parens_or_brackets );
184+ label_sanitize (label , left_parens_or_brackets_excluding_region ,
185+ right_parens_or_brackets );
185186}
186187
187188void label_keep_disc (char * label )
188189{
189- label_sanitize (label , left_parens_or_brackets_excluding_disc , right_parens_or_brackets );
190+ label_sanitize (label , left_parens_or_brackets_excluding_disc ,
191+ right_parens_or_brackets );
190192}
191193
192194void label_keep_region_and_disc (char * label )
193195{
194- label_sanitize (label , left_parens_or_brackets_excluding_region_or_disc , right_parens_or_brackets );
196+ label_sanitize (label , left_parens_or_brackets_excluding_region_or_disc ,
197+ right_parens_or_brackets );
195198}
0 commit comments