History

external_files: rename variables in guess_lang_from_filename()

Guido Cella committed 2 years ago

Commit e451d9c1 parent e175b3f1 file · +10 −10Browse files

Unified · Split

player/external_files.c+10−10
@@ -108,36 +108,36 @@ static int compare_sub_priority(const void *a, const void *b) · 107 unmodified lines
108 return strcoll(s1->fname, s2->fname);108 return strcoll(s1->fname, s2->fname);
109}109}
110 110
111static struct bstr guess_lang_from_filename(struct bstr name, int *fn_start)111static struct bstr guess_lang_from_filename(struct bstr name, int *lang_start)
112{112{
113 if (name.len < 2)113 if (name.len < 2)
114 return (struct bstr){NULL, 0};114 return (struct bstr){NULL, 0};
115 115
116 int n = 0;116 int lang_length = 0;
117 int i = name.len - 1;117 int i = name.len - 1;
118 118
119 char thing = '.';119 char delimiter = '.';
120 if (name.start[i] == ')') {120 if (name.start[i] == ')') {
121 thing = '(';121 delimiter = '(';
122 i--;122 i--;
123 }123 }
124 if (name.start[i] == ']') {124 if (name.start[i] == ']') {
125 thing = '[';125 delimiter = '[';
126 i--;126 i--;
127 }127 }
128 128
129 while (i >= 0 && mp_isalpha(name.start[i])) {129 while (i >= 0 && mp_isalpha(name.start[i])) {
130 n++;130 lang_length++;
131 if (n > 3)131 if (lang_length > 3)
132 return (struct bstr){NULL, 0};132 return (struct bstr){NULL, 0};
133 i--;133 i--;
134 }134 }
135 135
136 if (n < 2 || i == 0 || name.start[i] != thing)136 if (lang_length < 2 || i == 0 || name.start[i] != delimiter)
137 return (struct bstr){NULL, 0};137 return (struct bstr){NULL, 0};
138 138
139 *fn_start = i;139 *lang_start = i;
140 return (struct bstr){name.start + i + 1, n};140 return (struct bstr){name.start + i + 1, lang_length};
141}141}
142 142
143char *mp_guess_lang_from_filename(void* ctx, const char *filename)143char *mp_guess_lang_from_filename(void* ctx, const char *filename)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t