From 08caadb9c0b3c9070f2e5cb7f883f43d6cd5590e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 28 Jul 2012 23:47:42 +0200 Subject: bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstr Replace all uses of bstr() with bstr0(). Also remove the ridiculous C++ workaround. --- bstr.h | 22 +++++++++------------- command.c | 6 +++--- input/input.c | 4 ++-- libmpcodecs/vf.c | 2 +- libmpdemux/demux_lavf.c | 6 +++--- libmpdemux/demux_mkv.c | 6 +++--- libmpdemux/demuxer.c | 6 +++--- libvo/vo_gl3.c | 8 ++++---- m_config.c | 14 +++++++------- m_config.h | 4 ++-- m_option.c | 18 +++++++++--------- m_property.c | 2 +- m_struct.c | 2 +- mplayer.c | 4 ++-- parser-mpcmd.c | 14 +++++++------- path.c | 2 +- playtree.c | 2 +- playtreeparser.c | 2 +- screenshot.c | 2 +- stream/stream.c | 2 +- sub/find_subfiles.c | 26 +++++++++++++------------- sub/subassconvert.c | 4 ++-- timeline/tl_cue.c | 16 ++++++++-------- timeline/tl_edl.c | 10 +++++----- timeline/tl_matroska.c | 2 +- 25 files changed, 91 insertions(+), 95 deletions(-) diff --git a/bstr.h b/bstr.h index d3434cfa13..1ce624cf08 100644 --- a/bstr.h +++ b/bstr.h @@ -29,13 +29,11 @@ /* NOTE: 'len' is size_t, but most string-handling functions below assume * that input size has been sanity checked and len fits in an int. */ -struct bstr { +typedef struct bstr { unsigned char *start; size_t len; -}; +} bstr; -// demux_rtp.cpp (live555) C++ compilation workaround -#ifndef __cplusplus // If str.start is NULL, return NULL. static inline char *bstrdup0(void *talloc_ctx, struct bstr str) { @@ -51,7 +49,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 bstr0(const unsigned char *s) { return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0}; } @@ -124,7 +122,7 @@ static inline bool bstr_startswith(struct bstr str, struct bstr prefix) static inline bool bstr_startswith0(struct bstr str, const char *prefix) { - return bstr_startswith(str, bstr(prefix)); + return bstr_startswith(str, bstr0(prefix)); } static inline bool bstr_endswith(struct bstr str, struct bstr suffix) @@ -136,31 +134,29 @@ static inline bool bstr_endswith(struct bstr str, struct bstr suffix) static inline bool bstr_endswith0(struct bstr str, const char *suffix) { - return bstr_endswith(str, bstr(suffix)); + return bstr_endswith(str, bstr0(suffix)); } static inline int bstrcmp0(struct bstr str1, const char *str2) { - return bstrcmp(str1, bstr(str2)); + return bstrcmp(str1, bstr0(str2)); } static inline int bstrcasecmp0(struct bstr str1, const char *str2) { - return bstrcasecmp(str1, bstr(str2)); + return bstrcasecmp(str1, bstr0(str2)); } static inline int bstr_find0(struct bstr haystack, const char *needle) { - return bstr_find(haystack, bstr(needle)); + return bstr_find(haystack, bstr0(needle)); } static inline int bstr_eatstart0(struct bstr *s, char *prefix) { - return bstr_eatstart(s, bstr(prefix)); + return bstr_eatstart(s, bstr0(prefix)); } -#endif - // create a pair (not single value!) for "%.*s" printf syntax #define BSTR_P(bstr) (int)((bstr).len), (bstr).start diff --git a/command.c b/command.c index 6a32148de8..1f38603aff 100644 --- a/command.c +++ b/command.c @@ -226,7 +226,7 @@ static int mp_property_generic_option(struct m_option *prop, int action, { char *optname = prop->priv; const struct m_option *opt = m_config_get_option(mpctx->mconfig, - bstr(optname)); + bstr0(optname)); void *valptr = m_option_get_ptr(opt, &mpctx->opts); switch (action) { @@ -1187,7 +1187,7 @@ static int levels_property_helper(int offset, m_option_t *prop, int action, { char *optname = prop->priv; const struct m_option *opt = m_config_get_option(mpctx->mconfig, - bstr(optname)); + bstr0(optname)); int *valptr = (int *)m_option_get_ptr(opt, &mpctx->opts); switch (action) { @@ -3220,7 +3220,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_LOADLIST: { play_tree_t *e = parse_playlist_file(mpctx->mconfig, - bstr(cmd->args[0].v.s)); + bstr0(cmd->args[0].v.s)); if (!e) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "\nUnable to load playlist %s.\n", cmd->args[0].v.s); diff --git a/input/input.c b/input/input.c index 014216e093..dbc29d964f 100644 --- a/input/input.c +++ b/input/input.c @@ -1546,7 +1546,7 @@ 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), + if (!bstrcasecmp(bstr0(m->name), (struct bstr){(char *)name, p - name})) { modifiers |= m->key; goto found; @@ -1558,7 +1558,7 @@ found: name = p + 1; } - struct bstr bname = bstr(name); + struct bstr bname = bstr0(name); struct bstr rest; int code = bstr_decode_utf8(bname, &rest); diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 83ae763fba..7a774be741 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -495,7 +495,7 @@ struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts, void *vf_priv = m_struct_alloc(st); int n; for (n = 0; args && args[2 * n]; n++) - m_struct_set(st, vf_priv, args[2 * n], bstr(args[2 * n + 1])); + m_struct_set(st, vf_priv, args[2 * n], bstr0(args[2 * n + 1])); vf->priv = vf_priv; args = NULL; } else // Otherwise we should have the '_oldargs_' diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 1487a6db6b..79d5a3c420 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -524,8 +524,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, bstr0(filename), + bstr0("application/x-truetype-font"), (struct bstr){codec->extradata, codec->extradata_size}); break; @@ -644,7 +644,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_dict_get(c->metadata, "title", NULL, 0); - demuxer_add_chapter(demuxer, t ? bstr(t->value) : bstr(NULL), + demuxer_add_chapter(demuxer, t ? bstr0(t->value) : bstr0(NULL), start, end); } diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index b0f45758d7..bcc01fcc0f 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -1373,7 +1373,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, if (t->id == NULL) goto error; if (t->prefix) { - if (!bstr_startswith0(bstr(track->codec_id), t->id)) + if (!bstr_startswith0(bstr0(track->codec_id), t->id)) continue; } else { if (strcmp(track->codec_id, t->id)) @@ -1633,8 +1633,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, bstr0("matroska")) != 0 + && bstrcmp(ebml_master.doc_type, bstr0("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 ea8c4e01f1..453de0b91a 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1234,7 +1234,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, bstr0(opt), bstr0(param)); } int demux_info_add_bstr(demuxer_t *demuxer, struct bstr opt, struct bstr param) @@ -1244,8 +1244,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, bstr0(info[2*n]))) { + if (!bstrcmp(param, bstr0(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; diff --git a/libvo/vo_gl3.c b/libvo/vo_gl3.c index 6a3f427ef9..4f673e951f 100644 --- a/libvo/vo_gl3.c +++ b/libvo/vo_gl3.c @@ -486,7 +486,7 @@ static char *get_section(void *talloc_ctx, struct bstr source, bool copy = false; while (source.len) { struct bstr line = bstr_strip_linebreaks(bstr_getline(source, &source)); - if (bstr_eatstart(&line, bstr(SECTION_HEADER))) { + if (bstr_eatstart(&line, bstr0(SECTION_HEADER))) { copy = bstrcmp0(line, section) == 0; } else if (copy) { res = talloc_asprintf_append_buffer(res, "%.*s\n", BSTR_P(line)); @@ -631,7 +631,7 @@ static void compile_shaders(struct gl_priv *p) void *tmp = talloc_new(NULL); - struct bstr src = bstr(vo_gl3_shaders); + struct bstr src = bstr0(vo_gl3_shaders); char *vertex_shader = get_section(tmp, src, "vertex_all"); char *shader_prelude = get_section(tmp, src, "prelude"); char *s_video = get_section(tmp, src, "frag_video"); @@ -1970,8 +1970,8 @@ static bool load_icc(struct gl_priv *p, const char *icc_file, mp_msg(MSGT_VO, MSGL_INFO, "[gl] Opening 3D LUT cache in file '%s'.\n", icc_cache); struct bstr cachedata = load_file(p, tmp, icc_cache); - if (bstr_eatstart(&cachedata, bstr(LUT3D_CACHE_HEADER)) - && bstr_eatstart(&cachedata, bstr(cache_info)) + if (bstr_eatstart(&cachedata, bstr0(LUT3D_CACHE_HEADER)) + && bstr_eatstart(&cachedata, bstr0(cache_info)) && bstr_eatstart(&cachedata, iccdata) && cachedata.len == talloc_get_size(output)) { diff --git a/m_config.c b/m_config.c index fb9e1b6492..0c5677a7cc 100644 --- a/m_config.c +++ b/m_config.c @@ -412,7 +412,7 @@ static struct m_config_option *m_config_get_co(const struct m_config *config, struct m_config_option *co; for (co = config->opts; co; co = co->next) { - struct bstr coname = bstr(co->name); + struct bstr coname = bstr0(co->name); if ((co->opt->type->flags & M_OPT_TYPE_ALLOW_WILDCARD) && bstr_endswith0(coname, "*")) { coname.len--; @@ -500,7 +500,7 @@ static int parse_subopts(struct m_config *config, void *optstruct, char *name, { char **lst = NULL; // Split the argument into child options - int r = m_option_type_subconfig.parse(NULL, bstr(""), param, false, &lst, + int r = m_option_type_subconfig.parse(NULL, bstr0(""), param, false, &lst, optstruct); if (r < 0) return r; @@ -510,11 +510,11 @@ static int parse_subopts(struct m_config *config, void *optstruct, char *name, char n[110]; if (snprintf(n, 110, "%s%s", prefix, lst[2 * i]) > 100) abort(); - if (!m_config_get_option(config, bstr(n))) { + if (!m_config_get_option(config, bstr0(n))) { if (strncmp(lst[2 * i], "no-", 3)) goto nosubopt; snprintf(n, 110, "%s%s", prefix, lst[2 * i] + 3); - const struct m_option *o = m_config_get_option(config, bstr(n)); + const struct m_option *o = m_config_get_option(config, bstr0(n)); if (!o || o->type != &m_option_type_flag) { nosubopt: mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, @@ -532,8 +532,8 @@ static int parse_subopts(struct m_config *config, void *optstruct, char *name, } lst[2 * i + 1] = "no"; } - int sr = m_config_parse_option(config, optstruct, bstr(n), - bstr(lst[2 * i + 1]), false, set); + int sr = m_config_parse_option(config, optstruct, bstr0(n), + bstr0(lst[2 * i + 1]), false, set); if (sr < 0) { if (sr == M_OPT_MISSING_PARAM) { mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, @@ -578,7 +578,7 @@ int m_config_parse_suboptions(struct m_config *config, void *optstruct, { if (!subopts || !*subopts) return 0; - return parse_subopts(config, optstruct, name, "", bstr(subopts), true); + return parse_subopts(config, optstruct, name, "", bstr0(subopts), true); } diff --git a/m_config.h b/m_config.h index 24e80eb538..623b754718 100644 --- a/m_config.h +++ b/m_config.h @@ -151,7 +151,7 @@ static inline int m_config_set_option0(struct m_config *config, const char *name, const char *param, bool ambiguous) { - return m_config_set_option(config, bstr(name), bstr(param), ambiguous); + return m_config_set_option(config, bstr0(name), bstr0(param), ambiguous); } /* Check if an option setting is valid. @@ -164,7 +164,7 @@ static inline int m_config_check_option0(struct m_config *config, const char *name, const char *param, bool ambiguous) { - return m_config_check_option(config, bstr(name), bstr(param), ambiguous); + return m_config_check_option(config, bstr0(name), bstr0(param), ambiguous); } int m_config_parse_suboptions(struct m_config *config, void *optstruct, diff --git a/m_option.c b/m_option.c index 086f2c8842..9df177467f 100644 --- a/m_option.c +++ b/m_option.c @@ -58,7 +58,7 @@ static const struct m_option *m_option_list_findb(const struct m_option *list, struct bstr name) { for (int i = 0; list[i].name; i++) { - struct bstr lname = bstr(list[i].name); + struct bstr lname = bstr0(list[i].name); if ((list[i].type->flags & M_OPT_TYPE_ALLOW_WILDCARD) && bstr_endswith0(lname, "*")) { lname.len--; @@ -72,7 +72,7 @@ static const struct m_option *m_option_list_findb(const struct m_option *list, const m_option_t *m_option_list_find(const m_option_t *list, const char *name) { - return m_option_list_findb(list, bstr(name)); + return m_option_list_findb(list, bstr0(name)); } // Default function that just does a memcpy @@ -857,7 +857,7 @@ static int parse_subconf(const m_option_t *opt, struct bstr name, while (p.len) { int optlen = bstrcspn(p, ":="); struct bstr subopt = bstr_splice(p, 0, optlen); - struct bstr subparam = bstr(NULL); + struct bstr subparam = bstr0(NULL); p = bstr_cut(p, optlen); if (bstr_startswith0(p, "=")) { p = bstr_cut(p, 1); @@ -1311,7 +1311,7 @@ static int get_obj_param(struct bstr opt_name, struct bstr obj_name, return M_OPT_OUT_OF_RANGE; } opt = &desc->fields[(*nold)]; - r = m_option_parse(opt, bstr(opt->name), str, false, NULL); + r = m_option_parse(opt, bstr0(opt->name), str, false, NULL); if (r < 0) { if (r > M_OPT_EXIT) mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: " @@ -1439,7 +1439,7 @@ static int parse_obj_params(const m_option_t *opt, struct bstr name, return M_OPT_INVALID; desc = p->desc; - r = get_obj_params(name, bstr(desc->name), param, desc, p->separator, + r = get_obj_params(name, bstr0(desc->name), param, desc, p->separator, dst ? &opts : NULL); if (r < 0) return r; @@ -1449,7 +1449,7 @@ static int parse_obj_params(const m_option_t *opt, struct bstr name, return 1; for (r = 0; opts[r]; r += 2) - m_struct_set(desc, dst, opts[r], bstr(opts[r + 1])); + m_struct_set(desc, dst, opts[r], bstr0(opts[r + 1])); return 1; } @@ -1491,7 +1491,7 @@ static int parse_obj_settings(struct bstr opt, struct bstr str, const m_struct_t *desc; m_obj_settings_t *ret = _ret ? *_ret : NULL; - struct bstr param = bstr(NULL); + struct bstr param = bstr0(NULL); int idx = bstrchr(str, '='); if (idx >= 0) { param = bstr_cut(str, idx + 1); @@ -2004,7 +2004,7 @@ static int parse_custom_url(const m_option_t *opt, struct bstr name, int p = bstrtoll(bstr_cut(portstr, idx + 1), NULL, 0); char tmp[100]; snprintf(tmp, 99, "%d", p); - r = m_struct_set(desc, dst, "port", bstr(tmp)); + r = m_struct_set(desc, dst, "port", bstr0(tmp)); if (r < 0) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: Error while setting port.\n", @@ -2043,7 +2043,7 @@ static int parse_custom_url(const m_option_t *opt, struct bstr name, if (dst) { char *fname = bstrdup0(NULL, bstr_cut(path, 1)); url_unescape_string(fname, fname); - r = m_struct_set(desc, dst, "filename", bstr(fname)); + r = m_struct_set(desc, dst, "filename", bstr0(fname)); talloc_free(fname); if (r < 0) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, diff --git a/m_property.c b/m_property.c index 762ad73b7d..6eaaf92eeb 100644 --- a/m_property.c +++ b/m_property.c @@ -108,7 +108,7 @@ int m_property_do(const m_option_t *prop_list, const char *name, if (!arg) return M_PROPERTY_ERROR; val = calloc(1, opt->type->size); - if ((r = m_option_parse(opt, bstr(opt->name), bstr(arg), false, + if ((r = m_option_parse(opt, bstr0(opt->name), bstr0(arg), false, val)) <= 0) { free(val); return r; diff --git a/m_struct.c b/m_struct.c index 6e32bf32c8..f8bec673f5 100644 --- a/m_struct.c +++ b/m_struct.c @@ -71,7 +71,7 @@ int m_struct_set(const m_struct_t *st, void *obj, const char *field, return 0; } - if(f->type->parse(f, bstr(field), param, false, M_ST_MB_P(obj,f->p), NULL) < 0) { + if(f->type->parse(f, bstr0(field), param, false, M_ST_MB_P(obj,f->p), NULL) < 0) { mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s, field %s parsing error: %.*s\n", st->name, field, BSTR_P(param)); return 0; diff --git a/mplayer.c b/mplayer.c index 9001c221be..33a09f7a3b 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1015,7 +1015,7 @@ static int libmpdemux_was_interrupted(struct MPContext *mpctx, int stop_play) static int playtree_add_playlist(struct MPContext *mpctx, play_tree_t *entry) { - play_tree_add_bpf(entry, bstr(mpctx->filename)); + play_tree_add_bpf(entry, bstr0(mpctx->filename)); { if (!entry) { @@ -4212,7 +4212,7 @@ play_next_file: // The entry is added to the main playtree after the switch(). break; case MP_CMD_LOADLIST: - entry = parse_playlist_file(mpctx->mconfig, bstr(cmd->args[0].v.s)); + entry = parse_playlist_file(mpctx->mconfig, bstr0(cmd->args[0].v.s)); break; case MP_CMD_QUIT: exit_player_with_rc(mpctx, EXIT_QUIT, diff --git a/parser-mpcmd.c b/parser-mpcmd.c index 93011d3760..058793d09d 100644 --- a/parser-mpcmd.c +++ b/parser-mpcmd.c @@ -55,7 +55,7 @@ static bool split_opt(struct bstr *opt, struct bstr *param, bool *old_syntax) if (bstr_startswith0(*opt, "--")) { *old_syntax = false; *opt = bstr_cut(*opt, 2); - *param = bstr(NULL); + *param = bstr0(NULL); int idx = bstrchr(*opt, '='); if (idx > 0) { *param = bstr_cut(*opt, idx + 1); @@ -88,7 +88,7 @@ static int map_to_option(struct m_config *config, bool old_syntax, if (old_syntax) return -3; *optname = s; - *param = bstr("no"); + *param = bstr0("no"); return 0; } @@ -118,7 +118,7 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, for (int i = 1; i < argc; i++) { //next: - struct bstr opt = bstr(argv[i]); + struct bstr opt = bstr0(argv[i]); orig_opt = opt; /* check for -- (no more options id.) except --help! */ if (!bstrcmp0(opt, "--")) { @@ -150,7 +150,7 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, continue; } - struct bstr param = bstr(i+1 < argc ? argv[i+1] : NULL); + struct bstr param = bstr0(i+1 < argc ? argv[i+1] : NULL); bool old_syntax; if (!no_more_opts && split_opt(&opt, ¶m, &old_syntax)) { // Handle some special arguments outside option parser. @@ -220,7 +220,7 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, if (r >= 0) { play_tree_t *pt = last_entry ? last_entry : last_parent; if (r == 0) - param = bstr(NULL); // for old_syntax case + param = bstr0(NULL); // for old_syntax case play_tree_set_param(pt, opt, param); } } @@ -320,11 +320,11 @@ int m_config_preparse_command_line(m_config_t *config, int argc, char **argv, config->mode = M_COMMAND_LINE_PRE_PARSE; for (int i = 1 ; i < argc ; i++) { - struct bstr opt = bstr(argv[i]); + struct bstr opt = bstr0(argv[i]); // No more options after -- if (!bstrcmp0(opt, "--")) break; - struct bstr param = bstr(i+1 < argc ? argv[i+1] : NULL); + struct bstr param = bstr0(i+1 < argc ? argv[i+1] : NULL); bool old_syntax; if (!split_opt(&opt, ¶m, &old_syntax)) continue; // Ignore non-option arguments diff --git a/path.c b/path.c index e51c4c9c34..2ddcb7c1d2 100644 --- a/path.c +++ b/path.c @@ -185,7 +185,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 bstr0("."); return ret; } diff --git a/playtree.c b/playtree.c index 0d6358406f..df7f1ce7ee 100644 --- a/playtree.c +++ b/playtree.c @@ -359,7 +359,7 @@ play_tree_set_params_from(play_tree_t* dest,play_tree_t* src) { return; for(i = 0; src->params[i].name != NULL ; i++) - play_tree_set_param(dest, bstr(src->params[i].name), bstr(src->params[i].value)); + play_tree_set_param(dest, bstr0(src->params[i].name), bstr0(src->params[i].value)); if(src->flags & PLAY_TREE_RND) // pass the random flag too dest->flags |= PLAY_TREE_RND; diff --git a/playtreeparser.c b/playtreeparser.c index aea0241ca4..704a901e85 100644 --- a/playtreeparser.c +++ b/playtreeparser.c @@ -357,7 +357,7 @@ parse_pls(play_tree_parser_t* p) { entry = play_tree_new(); play_tree_add_file(entry,entries[num].file); if (entries[num].length) - play_tree_set_param(entry, bstr("endpos"), bstr(entries[num].length)); + play_tree_set_param(entry, bstr0("endpos"), bstr0(entries[num].length)); free(entries[num].file); if(list) play_tree_append_entry(last_entry,entry); diff --git a/screenshot.c b/screenshot.c index df92f60d89..2ed2734155 100644 --- a/screenshot.c +++ b/screenshot.c @@ -355,7 +355,7 @@ static char *create_fname(struct MPContext *mpctx, char *template, char *end = strchr(template, '}'); if (!end) goto error_exit; - struct bstr prop = bstr_splice(bstr(template), 0, end - template); + struct bstr prop = bstr_splice(bstr0(template), 0, end - template); template = end + 1; char *s = do_format_property(mpctx, prop); if (s) diff --git a/stream/stream.c b/stream/stream.c index 772c87dd9c..cb3679fbef 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -164,7 +164,7 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo, if(sinfo->opts_url) { m_option_t url_opt = { "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, (void *)sinfo->opts }; - if (m_option_parse(&url_opt, bstr("stream url"), bstr(filename), false, arg) < 0) { + if (m_option_parse(&url_opt, bstr0("stream url"), bstr0(filename), false, arg) < 0) { mp_tmsg(MSGT_OPEN,MSGL_ERR, "URL parsing failed on url %s\n",filename); m_struct_free(desc,arg); return NULL; diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 6af599183f..cb421dac77 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -91,7 +91,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 = bstr0(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); @@ -107,7 +107,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 = bstr0(de->d_name); void *tmpmem2 = talloc_new(tmpmem); // retrieve various parts of the filename @@ -118,11 +118,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, bstr0("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, bstr0(idxname)); f = fopen(idx, "rt"); if (f) { fclose(f); @@ -143,7 +143,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(bstr0(sub_exts[i]), tmp_fname_ext) == 0) break; i++; } @@ -156,7 +156,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]))) { + bstr0(opts->sub_lang[n]))) { prio = 4; // matches the movie name + lang extension break; } @@ -219,15 +219,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); + bstr0(opts->sub_paths[i])); + append_dir_subtitles(opts, &slist, &n, bstr0(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, bstr0(mp_subdir), fname, 1); free(mp_subdir); // Sort subs by priority and append them @@ -247,7 +247,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 = bstr0(mp_basename(fname)); int pdot = bstrrchr(bname, '.'); if (pdot >= 0) bname.len = pdot; @@ -257,9 +257,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])); + bstr0(opts->sub_paths[i])); MP_GROW_ARRAY(vobs, n); - vobs[n++] = mp_path_join(vobs, bstr(path), bname); + vobs[n++] = mp_path_join(vobs, bstr0(path), bname); talloc_free(path); } } @@ -268,7 +268,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, bstr0(mp_subdir), bname); } free(mp_subdir); diff --git a/sub/subassconvert.c b/sub/subassconvert.c index e1db9bb033..e958bb9d49 100644 --- a/sub/subassconvert.c +++ b/sub/subassconvert.c @@ -215,7 +215,7 @@ void subassconvert_subrip(const char *orig, char *dest, int dest_buffer_size) tag->has_size = true; has_valid_attr = true; } else if (!bstrcmp0(attr, "color")) { - if (bstr_eatstart(&val, bstr("#"))) { + if (bstr_eatstart(&val, bstr0("#"))) { // #RRGGBB format tag->color = bstrtoll(val, &val, 16) & 0x00ffffff; if (val.len) @@ -227,7 +227,7 @@ void subassconvert_subrip(const char *orig, char *dest, int dest_buffer_size) // Standard web colors for (int i = 0; i < FF_ARRAY_ELEMS(subrip_web_colors); i++) { char *color = subrip_web_colors[i].s; - if (bstrcasecmp(val, bstr(color)) == 0) { + if (bstrcasecmp(val, bstr0(color)) == 0) { tag->color = subrip_web_colors[i].v; goto foundcolor; } diff --git a/timeline/tl_cue.c b/timeline/tl_cue.c index c4958a823a..14d1127819 100644 --- a/timeline/tl_cue.c +++ b/timeline/tl_cue.c @@ -83,7 +83,7 @@ static enum cue_command read_cmd(struct bstr *data, struct bstr *out_params) if (line.len == 0) return CUE_EMPTY; for (int n = 0; cue_command_strings[n].command != -1; n++) { - struct bstr name = bstr(cue_command_strings[n].text); + struct bstr name = bstr0(cue_command_strings[n].text); if (bstr_startswith(line, name)) { struct bstr rest = bstr_cut(line, name.len); if (rest.len && !strchr(WHITESPACE, rest.start[0])) @@ -187,12 +187,12 @@ static void add_source(struct MPContext *mpctx, struct stream *s, static bool try_open(struct MPContext *mpctx, char *filename) { - struct bstr bfilename = bstr(filename); + struct bstr bfilename = bstr0(filename); // Avoid trying to open itself or another .cue file. Best would be // to check the result of demuxer auto-detection, but the demuxer // API doesn't allow this without opening a full demuxer. - if (bstr_case_endswith(bfilename, bstr(".cue")) - || bstrcasecmp(bstr(mpctx->demuxer->filename), bfilename) == 0) + if (bstr_case_endswith(bfilename, bstr0(".cue")) + || bstrcasecmp(bstr0(mpctx->demuxer->filename), bfilename) == 0) return false; int format = 0; @@ -210,7 +210,7 @@ static bool try_open(struct MPContext *mpctx, char *filename) // fragile, but it's about the only way we have. // TODO: maybe also could check if the .bin file is a multiple of the Audio // CD sector size (2352 bytes) - if (!d && bstr_case_endswith(bfilename, bstr(".bin"))) { + if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n"); d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO, mpctx->opts.audio_id, @@ -234,7 +234,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename) struct bstr dirname = mp_dirname(mpctx->demuxer->filename); - struct bstr base_filename = bstr(mp_basename(bstrdup0(ctx, filename))); + struct bstr base_filename = bstr0(mp_basename(bstrdup0(ctx, filename))); if (!base_filename.len) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Invalid audio filename in .cue file!\n"); @@ -252,7 +252,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename) // are renamed. struct bstr cuefile = - bstr_strip_ext(bstr(mp_basename(mpctx->demuxer->filename))); + bstr_strip_ext(bstr0(mp_basename(mpctx->demuxer->filename))); DIR *d = opendir(bstrdup0(ctx, dirname)); if (!d) @@ -260,7 +260,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename) struct dirent *de; while ((de = readdir(d))) { char *dename0 = de->d_name; - struct bstr dename = bstr(dename0); + struct bstr dename = bstr0(dename0); if (bstr_case_startswith(dename, cuefile)) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: No useful audio filename " "in .cue file found, trying with '%s' instead!\n", diff --git a/timeline/tl_edl.c b/timeline/tl_edl.c index 8bd5c18f3e..6763c9fa63 100644 --- a/timeline/tl_edl.c +++ b/timeline/tl_edl.c @@ -64,18 +64,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 = bstr0("<"); 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 = bstr0("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(bstr0("2"), version)) { mp_msg(MSGT_CPLAYER, MSGL_ERR, "EDL: Unsupported EDL file version!\n"); goto out; } @@ -125,7 +125,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, bstr0(filename)); edl_ids[num_sources++] = (struct edl_source){id, fullname, i+1}; } @@ -175,7 +175,7 @@ void build_edl_timeline(struct MPContext *mpctx) if (!arg.len) goto bad; int64_t val; - if (!bstrcmp(arg, bstr("*"))) + if (!bstrcmp(arg, bstr0("*"))) 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 09f86b8284..562b1bda1f 100644 --- a/timeline/tl_matroska.c +++ b/timeline/tl_matroska.c @@ -82,7 +82,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, bstr0(ep->d_name)); char *s1 = ep->d_name; char *s2 = basename; int matchlen = 0; -- cgit v1.2.3