~ubuntu-branches/ubuntu/precise/mplayer2/precise-proposed

« back to all changes in this revision

Viewing changes to sub/find_subfiles.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:59:30 UTC
  • mfrom: (5.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20120112225930-jsg10o7na7nk73w5
Tags: 2.0-426-gc32b3ed-2
* Upload to unstable
* don't build-depend on libcdparanoia-dev on the hurd

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
    FILE *f;
90
90
    assert(strlen(fname) < 1e6);
91
91
 
92
 
    struct bstr f_fname = BSTR(mp_basename(fname));
 
92
    struct bstr f_fname = bstr(mp_basename(fname));
93
93
    struct bstr f_fname_noext = bstrdup(tmpmem, strip_ext(f_fname));
94
94
    bstr_lower(f_fname_noext);
95
95
    struct bstr f_fname_trim = bstr_strip(f_fname_noext);
105
105
    mp_msg(MSGT_SUBREADER, MSGL_INFO, "Load subtitles in %.*s\n", BSTR_P(path));
106
106
    struct dirent *de;
107
107
    while ((de = readdir(d))) {
108
 
        struct bstr dename = BSTR(de->d_name);
 
108
        struct bstr dename = bstr(de->d_name);
109
109
        void *tmpmem2 = talloc_new(tmpmem);
110
110
 
111
111
        // retrieve various parts of the filename
116
116
 
117
117
        // If it's a .sub, check if there is a .idx with the same name. If
118
118
        // there is one, it's certainly a vobsub so we skip it.
119
 
        if (bstrcasecmp(tmp_fname_ext, BSTR("sub")) == 0) {
 
119
        if (bstrcasecmp(tmp_fname_ext, bstr("sub")) == 0) {
120
120
            char *idxname = talloc_asprintf(tmpmem2, "%.*s.idx",
121
121
                                            (int)tmp_fname_noext.len,
122
122
                                            de->d_name);
123
 
            char *idx = mp_path_join(tmpmem2, path, BSTR(idxname));
 
123
            char *idx = mp_path_join(tmpmem2, path, bstr(idxname));
124
124
            f = fopen(idx, "rt");
125
125
            if (f) {
126
126
                fclose(f);
141
141
        while (1) {
142
142
            if (!sub_exts[i])
143
143
                goto next_sub;
144
 
            if (bstrcasecmp(BSTR(sub_exts[i]), tmp_fname_ext) == 0)
 
144
            if (bstrcasecmp(bstr(sub_exts[i]), tmp_fname_ext) == 0)
145
145
                break;
146
146
            i++;
147
147
        }
154
154
                if (lang.len) {
155
155
                    for (int n = 0; opts->sub_lang[n]; n++) {
156
156
                        if (bstr_startswith(lang,
157
 
                                            BSTR(opts->sub_lang[n]))) {
 
157
                                            bstr(opts->sub_lang[n]))) {
158
158
                            prio = 4; // matches the movie name + lang extension
159
159
                            break;
160
160
                        }
217
217
    if (opts->sub_paths) {
218
218
        for (int i = 0; opts->sub_paths[i]; i++) {
219
219
            char *path = mp_path_join(slist, mp_dirname(fname),
220
 
                                      BSTR(opts->sub_paths[i]));
221
 
            append_dir_subtitles(opts, &slist, &n, BSTR(path), fname, 0);
 
220
                                      bstr(opts->sub_paths[i]));
 
221
            append_dir_subtitles(opts, &slist, &n, bstr(path), fname, 0);
222
222
        }
223
223
    }
224
224
 
225
225
    // Load subtitles in ~/.mplayer/sub limiting sub fuzziness
226
226
    char *mp_subdir = get_path("sub/");
227
227
    if (mp_subdir)
228
 
        append_dir_subtitles(opts, &slist, &n, BSTR(mp_subdir), fname, 1);
 
228
        append_dir_subtitles(opts, &slist, &n, bstr(mp_subdir), fname, 1);
229
229
    free(mp_subdir);
230
230
 
231
231
    // Sort subs by priority and append them
245
245
    int n = 0;
246
246
 
247
247
    // Potential vobsub in the media directory
248
 
    struct bstr bname = BSTR(mp_basename(fname));
 
248
    struct bstr bname = bstr(mp_basename(fname));
249
249
    int pdot = bstrrchr(bname, '.');
250
250
    if (pdot >= 0)
251
251
        bname.len = pdot;
255
255
    if (opts->sub_paths) {
256
256
        for (int i = 0; opts->sub_paths[i]; i++) {
257
257
            char *path = mp_path_join(NULL, mp_dirname(fname),
258
 
                                      BSTR(opts->sub_paths[i]));
 
258
                                      bstr(opts->sub_paths[i]));
259
259
            MP_GROW_ARRAY(vobs, n);
260
 
            vobs[n++] = mp_path_join(vobs, BSTR(path), bname);
 
260
            vobs[n++] = mp_path_join(vobs, bstr(path), bname);
261
261
            talloc_free(path);
262
262
        }
263
263
    }
266
266
    char *mp_subdir = get_path("sub/");
267
267
    if (mp_subdir) {
268
268
        MP_GROW_ARRAY(vobs, n);
269
 
        vobs[n++] = mp_path_join(vobs, BSTR(mp_subdir), bname);
 
269
        vobs[n++] = mp_path_join(vobs, bstr(mp_subdir), bname);
270
270
    }
271
271
 
272
272
    free(mp_subdir);