diff options
-rw-r--r-- | bstr.h | 2 | ||||
-rw-r--r-- | input/input.c | 3 | ||||
-rw-r--r-- | libmpdemux/demux_lavf.c | 6 | ||||
-rw-r--r-- | libmpdemux/demux_mkv.c | 4 | ||||
-rw-r--r-- | libmpdemux/demuxer.c | 6 | ||||
-rw-r--r-- | path.c | 2 | ||||
-rw-r--r-- | sub/find_subfiles.c | 26 | ||||
-rw-r--r-- | timeline/tl_edl.c | 10 | ||||
-rw-r--r-- | timeline/tl_matroska.c | 2 |
9 files changed, 31 insertions, 30 deletions
@@ -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}; } diff --git a/input/input.c b/input/input.c index 4fe0e5297c..f77dddfa91 100644 --- a/input/input.c +++ b/input/input.c @@ -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; } diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 545e3bdace..2da898bf5c 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -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); } diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 4b4d8704a5..dadb3887cf 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -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; diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 276d62dbae..9aaed21a8f 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -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; @@ -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; } diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 1e4b33d0cc..3de8014ce1 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -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); diff --git a/timeline/tl_edl.c b/timeline/tl_edl.c index 99b9ddad82..1a54918bcc 100644 --- a/timeline/tl_edl.c +++ b/timeline/tl_edl.c @@ -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; diff --git a/timeline/tl_matroska.c b/timeline/tl_matroska.c index 03b6cc3dc4..6912bac159 100644 --- a/timeline/tl_matroska.c +++ b/timeline/tl_matroska.c @@ -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; |