mirror of https://github.com/mpv-player/mpv
bstr: rename BSTR() -> bstr()
Rename the BSTR() function to bstr(). The former caused a conflict with some Windows OS name, and it's no longer a macro so uppercase naming is less appropriate.
This commit is contained in:
parent
ea4cc89f36
commit
0958620591
2
bstr.h
2
bstr.h
|
@ -73,7 +73,7 @@ static inline struct bstr bstrdup(void *talloc_ctx, struct bstr str)
|
|||
return r;
|
||||
}
|
||||
|
||||
static inline struct bstr BSTR(const unsigned char *s)
|
||||
static inline struct bstr bstr(const unsigned char *s)
|
||||
{
|
||||
return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
|
||||
}
|
||||
|
|
|
@ -1536,7 +1536,8 @@ int mp_input_get_key_from_name(const char *name)
|
|||
const char *p;
|
||||
while ((p = strchr(name, '+'))) {
|
||||
for (struct key_name *m = modifier_names; m->name; m++)
|
||||
if (!bstrcasecmp(BSTR(m->name), (struct bstr){(char *)name, p - name})) {
|
||||
if (!bstrcasecmp(bstr(m->name),
|
||||
(struct bstr){(char *)name, p - name})) {
|
||||
modifiers |= m->key;
|
||||
goto found;
|
||||
}
|
||||
|
|
|
@ -503,8 +503,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i)
|
|||
NULL, 0);
|
||||
char *filename = ftag ? ftag->value : NULL;
|
||||
if (st->codec->codec_id == CODEC_ID_TTF)
|
||||
demuxer_add_attachment(demuxer, BSTR(filename),
|
||||
BSTR("application/x-truetype-font"),
|
||||
demuxer_add_attachment(demuxer, bstr(filename),
|
||||
bstr("application/x-truetype-font"),
|
||||
(struct bstr){codec->extradata,
|
||||
codec->extradata_size});
|
||||
break;
|
||||
|
@ -630,7 +630,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer)
|
|||
uint64_t end = av_rescale_q(c->end, c->time_base,
|
||||
(AVRational){1, 1000000000});
|
||||
t = av_metadata_get(c->metadata, "title", NULL, 0);
|
||||
demuxer_add_chapter(demuxer, t ? BSTR(t->value) : BSTR(NULL),
|
||||
demuxer_add_chapter(demuxer, t ? bstr(t->value) : bstr(NULL),
|
||||
start, end);
|
||||
}
|
||||
|
||||
|
|
|
@ -1619,8 +1619,8 @@ static int demux_mkv_open(demuxer_t *demuxer)
|
|||
if (ebml_master.doc_type.start == NULL) {
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] File has EBML header but no doctype."
|
||||
" Assuming \"matroska\".\n");
|
||||
} else if (bstrcmp(ebml_master.doc_type, BSTR("matroska")) != 0
|
||||
&& bstrcmp(ebml_master.doc_type, BSTR("webm")) != 0) {
|
||||
} else if (bstrcmp(ebml_master.doc_type, bstr("matroska")) != 0
|
||||
&& bstrcmp(ebml_master.doc_type, bstr("webm")) != 0) {
|
||||
mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] no head found\n");
|
||||
talloc_free(parse_ctx.talloc_ctx);
|
||||
return 0;
|
||||
|
|
|
@ -1227,7 +1227,7 @@ int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay,
|
|||
|
||||
int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
|
||||
{
|
||||
return demux_info_add_bstr(demuxer, BSTR(opt), BSTR(param));
|
||||
return demux_info_add_bstr(demuxer, bstr(opt), bstr(param));
|
||||
}
|
||||
|
||||
int demux_info_add_bstr(demuxer_t *demuxer, struct bstr opt, struct bstr param)
|
||||
|
@ -1237,8 +1237,8 @@ int demux_info_add_bstr(demuxer_t *demuxer, struct bstr opt, struct bstr param)
|
|||
|
||||
|
||||
for (n = 0; info && info[2 * n] != NULL; n++) {
|
||||
if (!bstrcasecmp(opt, BSTR(info[2*n]))) {
|
||||
if (!bstrcmp(param, BSTR(info[2*n + 1]))) {
|
||||
if (!bstrcasecmp(opt, bstr(info[2*n]))) {
|
||||
if (!bstrcmp(param, bstr(info[2*n + 1]))) {
|
||||
mp_msg(MSGT_DEMUX, MSGL_V, "Demuxer info %.*s set to unchanged value %.*s\n",
|
||||
BSTR_P(opt), BSTR_P(param));
|
||||
return 0;
|
||||
|
|
2
path.c
2
path.c
|
@ -201,7 +201,7 @@ struct bstr mp_dirname(const char *path)
|
|||
{
|
||||
struct bstr ret = {(uint8_t *)path, mp_basename(path) - path};
|
||||
if (ret.len == 0)
|
||||
return BSTR(".");
|
||||
return bstr(".");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ static void append_dir_subtitles(struct MPOpts *opts,
|
|||
FILE *f;
|
||||
assert(strlen(fname) < 1e6);
|
||||
|
||||
struct bstr f_fname = BSTR(mp_basename(fname));
|
||||
struct bstr f_fname = bstr(mp_basename(fname));
|
||||
struct bstr f_fname_noext = bstrdup(tmpmem, strip_ext(f_fname));
|
||||
bstr_lower(f_fname_noext);
|
||||
struct bstr f_fname_trim = bstr_strip(f_fname_noext);
|
||||
|
@ -105,7 +105,7 @@ static void append_dir_subtitles(struct MPOpts *opts,
|
|||
mp_msg(MSGT_SUBREADER, MSGL_INFO, "Load subtitles in %.*s\n", BSTR_P(path));
|
||||
struct dirent *de;
|
||||
while ((de = readdir(d))) {
|
||||
struct bstr dename = BSTR(de->d_name);
|
||||
struct bstr dename = bstr(de->d_name);
|
||||
void *tmpmem2 = talloc_new(tmpmem);
|
||||
|
||||
// retrieve various parts of the filename
|
||||
|
@ -116,11 +116,11 @@ static void append_dir_subtitles(struct MPOpts *opts,
|
|||
|
||||
// If it's a .sub, check if there is a .idx with the same name. If
|
||||
// there is one, it's certainly a vobsub so we skip it.
|
||||
if (bstrcasecmp(tmp_fname_ext, BSTR("sub")) == 0) {
|
||||
if (bstrcasecmp(tmp_fname_ext, bstr("sub")) == 0) {
|
||||
char *idxname = talloc_asprintf(tmpmem2, "%.*s.idx",
|
||||
(int)tmp_fname_noext.len,
|
||||
de->d_name);
|
||||
char *idx = mp_path_join(tmpmem2, path, BSTR(idxname));
|
||||
char *idx = mp_path_join(tmpmem2, path, bstr(idxname));
|
||||
f = fopen(idx, "rt");
|
||||
if (f) {
|
||||
fclose(f);
|
||||
|
@ -141,7 +141,7 @@ static void append_dir_subtitles(struct MPOpts *opts,
|
|||
while (1) {
|
||||
if (!sub_exts[i])
|
||||
goto next_sub;
|
||||
if (bstrcasecmp(BSTR(sub_exts[i]), tmp_fname_ext) == 0)
|
||||
if (bstrcasecmp(bstr(sub_exts[i]), tmp_fname_ext) == 0)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ static void append_dir_subtitles(struct MPOpts *opts,
|
|||
if (lang.len) {
|
||||
for (int n = 0; opts->sub_lang[n]; n++) {
|
||||
if (bstr_startswith(lang,
|
||||
BSTR(opts->sub_lang[n]))) {
|
||||
bstr(opts->sub_lang[n]))) {
|
||||
prio = 4; // matches the movie name + lang extension
|
||||
break;
|
||||
}
|
||||
|
@ -217,15 +217,15 @@ char **find_text_subtitles(struct MPOpts *opts, const char *fname)
|
|||
if (opts->sub_paths) {
|
||||
for (int i = 0; opts->sub_paths[i]; i++) {
|
||||
char *path = mp_path_join(slist, mp_dirname(fname),
|
||||
BSTR(opts->sub_paths[i]));
|
||||
append_dir_subtitles(opts, &slist, &n, BSTR(path), fname, 0);
|
||||
bstr(opts->sub_paths[i]));
|
||||
append_dir_subtitles(opts, &slist, &n, bstr(path), fname, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Load subtitles in ~/.mplayer/sub limiting sub fuzziness
|
||||
char *mp_subdir = get_path("sub/");
|
||||
if (mp_subdir)
|
||||
append_dir_subtitles(opts, &slist, &n, BSTR(mp_subdir), fname, 1);
|
||||
append_dir_subtitles(opts, &slist, &n, bstr(mp_subdir), fname, 1);
|
||||
free(mp_subdir);
|
||||
|
||||
// Sort subs by priority and append them
|
||||
|
@ -245,7 +245,7 @@ char **find_vob_subtitles(struct MPOpts *opts, const char *fname)
|
|||
int n = 0;
|
||||
|
||||
// Potential vobsub in the media directory
|
||||
struct bstr bname = BSTR(mp_basename(fname));
|
||||
struct bstr bname = bstr(mp_basename(fname));
|
||||
int pdot = bstrrchr(bname, '.');
|
||||
if (pdot >= 0)
|
||||
bname.len = pdot;
|
||||
|
@ -255,9 +255,9 @@ char **find_vob_subtitles(struct MPOpts *opts, const char *fname)
|
|||
if (opts->sub_paths) {
|
||||
for (int i = 0; opts->sub_paths[i]; i++) {
|
||||
char *path = mp_path_join(NULL, mp_dirname(fname),
|
||||
BSTR(opts->sub_paths[i]));
|
||||
bstr(opts->sub_paths[i]));
|
||||
MP_GROW_ARRAY(vobs, n);
|
||||
vobs[n++] = mp_path_join(vobs, BSTR(path), bname);
|
||||
vobs[n++] = mp_path_join(vobs, bstr(path), bname);
|
||||
talloc_free(path);
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ char **find_vob_subtitles(struct MPOpts *opts, const char *fname)
|
|||
char *mp_subdir = get_path("sub/");
|
||||
if (mp_subdir) {
|
||||
MP_GROW_ARRAY(vobs, n);
|
||||
vobs[n++] = mp_path_join(vobs, BSTR(mp_subdir), bname);
|
||||
vobs[n++] = mp_path_join(vobs, bstr(mp_subdir), bname);
|
||||
}
|
||||
|
||||
free(mp_subdir);
|
||||
|
|
|
@ -63,18 +63,18 @@ static int find_edl_source(struct edl_source *sources, int num_sources,
|
|||
|
||||
void build_edl_timeline(struct MPContext *mpctx)
|
||||
{
|
||||
const struct bstr file_prefix = BSTR("<");
|
||||
const struct bstr file_prefix = bstr("<");
|
||||
void *tmpmem = talloc_new(NULL);
|
||||
|
||||
struct bstr *lines = bstr_splitlines(tmpmem, mpctx->demuxer->file_contents);
|
||||
int linec = MP_TALLOC_ELEMS(lines);
|
||||
struct bstr header = BSTR("mplayer EDL file, version ");
|
||||
struct bstr header = bstr("mplayer EDL file, version ");
|
||||
if (!linec || !bstr_startswith(lines[0], header)) {
|
||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "EDL: Bad EDL header!\n");
|
||||
goto out;
|
||||
}
|
||||
struct bstr version = bstr_strip(bstr_cut(lines[0], header.len));
|
||||
if (bstrcmp(BSTR("2"), version)) {
|
||||
if (bstrcmp(bstr("2"), version)) {
|
||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "EDL: Unsupported EDL file version!\n");
|
||||
goto out;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ void build_edl_timeline(struct MPContext *mpctx)
|
|||
goto out;
|
||||
}
|
||||
struct bstr dirname = mp_dirname(mpctx->demuxer->filename);
|
||||
char *fullname = mp_path_join(tmpmem, dirname, BSTR(filename));
|
||||
char *fullname = mp_path_join(tmpmem, dirname, bstr(filename));
|
||||
edl_ids[num_sources++] = (struct edl_source){id, fullname, i+1};
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void build_edl_timeline(struct MPContext *mpctx)
|
|||
if (!arg.len)
|
||||
goto bad;
|
||||
int64_t val;
|
||||
if (!bstrcmp(arg, BSTR("*")))
|
||||
if (!bstrcmp(arg, bstr("*")))
|
||||
val = -1;
|
||||
else if (isdigit(*arg.start)) {
|
||||
val = bstrtoll(arg, &arg, 10) * 1000000000;
|
||||
|
|
|
@ -57,7 +57,7 @@ static char **find_files(const char *original_file, const char *suffix)
|
|||
if (!strcmp(ep->d_name, basename))
|
||||
continue;
|
||||
|
||||
char *name = mp_path_join(results, directory, BSTR(ep->d_name));
|
||||
char *name = mp_path_join(results, directory, bstr(ep->d_name));
|
||||
char *s1 = ep->d_name;
|
||||
char *s2 = basename;
|
||||
int matchlen = 0;
|
||||
|
|
Loading…
Reference in New Issue