From c11ee7eef77769c957d05c0e90b2d756b57ad837 Mon Sep 17 00:00:00 2001 From: Angel Ortega Date: Thu, 3 Feb 2011 13:08:22 +0100 Subject: [PATCH] Changed sregex(). --- mp_build.mpsl | 2 +- mp_core.mpsl | 10 +++++----- mp_edit.mpsl | 10 +++++----- mp_file.mpsl | 4 ++-- mp_search.mpsl | 6 ++++-- mp_tags.mpsl | 10 +++++----- mp_templates.mpsl | 2 +- mp_tui.mpsl | 6 +++--- mpv_qk_common.cpp | 2 +- tools/po2mpsl.mpsl | 4 ++-- tools/update_ref_docs.mpsl | 6 +++--- 11 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mp_build.mpsl b/mp_build.mpsl index 89e2cc0..fd2d3e9 100644 --- a/mp_build.mpsl +++ b/mp_build.mpsl @@ -96,7 +96,7 @@ sub mp.build_get_targets local t; if (t = regex('/^[A-Za-z0-9_\.-]+:/', l)) - push(r, sregex('/:/', t, '')); + push(r, sregex(t, '/:/', '')); } close(f); diff --git a/mp_core.mpsl b/mp_core.mpsl index 872b4dd..68a06ed 100644 --- a/mp_core.mpsl +++ b/mp_core.mpsl @@ -314,7 +314,7 @@ sub mp.build_status_line() mp.message = NULL; } - return sregex("/%./g", mp.config.status_format, mp.status_line_info); + return sregex(mp.config.status_format, "/%./g", mp.status_line_info); } @@ -322,8 +322,8 @@ sub mp.backslash_codes(s, d) /* encodes (d == 0) or decodes (d == 1) backslash codes (like \n, \r, etc.) */ { - d && sregex("/[\r\n\t]/g", s, { "\r" => '\r', "\n" => '\n', "\t" => '\t'}) || - sregex("/\\\\[rnt]/g", s, { '\r' => "\r", '\n' => "\n", '\t' => "\t"}); + d && sregex(s, "/[\r\n\t]/g", { "\r" => '\r', "\n" => '\n', "\t" => '\t'}) || + sregex(s, "/\\\\[rnt]/g", { '\r' => "\r", '\n' => "\n", '\t' => "\t"}); } @@ -562,7 +562,7 @@ sub mp.setup_language() /* test if gettext() can do a basic translation */ if (gettext('&File') eq '&File' && ENV.LANG) { /* no; try alternatives using the LANG variable */ - local v = [ sregex('!/!g', ENV.LANG) ]; /* es_ES.UTF-8 */ + local v = [ sregex(ENV.LANG, '!/!g') ]; /* es_ES.UTF-8 */ push(v, shift(split(v[-1], '.'))); /* es_ES */ push(v, shift(split(v[-1], '_'))); /* es */ @@ -582,7 +582,7 @@ sub mp.normalize_version(vs) /* converts a version string to something usable with cmp() */ { map( - split(sregex('/-.+$/', vs), '.'), + split(sregex(vs, '/-.+$/'), '.'), sub(e) { sprintf("%03d", e); } ); } diff --git a/mp_edit.mpsl b/mp_edit.mpsl index 8f7b6e7..71ce855 100644 --- a/mp_edit.mpsl +++ b/mp_edit.mpsl @@ -238,10 +238,10 @@ sub mp.break_line(doc, col) local i = regex("/^[ \t]*[-\+\*]?[ \t]+/", c, 0); /* substitute all non-tab characters with spaces */ - i = sregex("/[^\t]/g", i, " "); + i = sregex(i, "/[^\t]/g", " "); /* delete any blank in the new line */ - w[1] = sregex("/^[ \t]*/", w[1]); + w[1] = sregex(w[1], "/^[ \t]*/"); /* concatenate */ w[1] = i ~ w[1]; @@ -474,7 +474,7 @@ sub mp.wrap_words(doc) mp.break_line(doc, w[1]); /* delete the space at the end of the line */ - txt.lines[txt.y - 1] = sregex("/[ \t]$/", txt.lines[txt.y - 1], NULL); + txt.lines[txt.y - 1] = sregex(txt.lines[txt.y - 1], "/[ \t]$/", NULL); } return doc; @@ -496,7 +496,7 @@ sub mp.insert_tab(doc) local pl = doc.txt.lines[doc.txt.y - 1]; if ((pl = regex("/[^ \t]*[ \t]+/", pl, doc.txt.x)) != NULL) { - pl = sregex("/[^\t]/g", pl, ' '); + pl = sregex(pl, "/[^\t]/g", ' '); mp.insert(doc, pl); return doc; } @@ -593,7 +593,7 @@ sub mp.join_paragraph(doc) while ((l = txt.lines[txt.y + 1]) && size(l)) { /* delete all leading blanks in the next line */ - txt.lines[txt.y + 1] = sregex("/^[ \t]+/", txt.lines[txt.y + 1]); + txt.lines[txt.y + 1] = sregex(txt.lines[txt.y + 1], "/^[ \t]+/"); /* move to end of line and add a space separator */ mp.move_eol(doc); diff --git a/mp_file.mpsl b/mp_file.mpsl index 2f66ed5..8638c20 100644 --- a/mp_file.mpsl +++ b/mp_file.mpsl @@ -149,7 +149,7 @@ mp.actions['exec_command'] = sub (d) { local p; /* yes; current document should be fed to it */ - cmd = sregex('/^\|/', cmd, NULL); + cmd = sregex(cmd, '/^\|/'); if ((p = popen(cmd, "w")) != NULL) { foreach (l, mp.get_active_area(d)) @@ -323,7 +323,7 @@ mp.actdesc['open_dropped_files'] = LL("Open dropped files"); sub mp.chomp(str) /* chomps the end of file chars from a string */ { - sregex("/\r*\n*$/", str, NULL); + sregex(str, "/\r*\n*$/"); } diff --git a/mp_search.mpsl b/mp_search.mpsl index 1095bc7..ea89fbc 100644 --- a/mp_search.mpsl +++ b/mp_search.mpsl @@ -301,8 +301,10 @@ sub mp.replace_1(doc, this, that) txt = doc.txt; /* substitute */ - txt.lines[txt.y] = sregex(mp.prefix_regex(this), - txt.lines[txt.y], that, c[0]); + txt.lines[txt.y] = sregex(txt.lines[txt.y], + mp.prefix_regex(this), + that, c[0] + ); /* move to correct position */ c = regex(); diff --git a/mp_tags.mpsl b/mp_tags.mpsl index 394467f..abc39bc 100644 --- a/mp_tags.mpsl +++ b/mp_tags.mpsl @@ -121,15 +121,15 @@ sub mp.load_tags(force) local l, r; /* clean the regex 'markup' for the label */ - l = sregex('@^/\^@', t[2], ''); - l = sregex('@\$/;"$@', l, '') ~ ' [' ~ t[1] ~ ']'; + l = sregex(t[2], '@^/\^@', ''); + l = sregex(l, '@\$/;"$@', '') ~ ' [' ~ t[1] ~ ']'; /* clean the regex itself */ - r = sregex('@/;"$@', t[2], NULL); - r = sregex('@^/@', r, NULL); + r = sregex(t[2], '@/;"$@'); + r = sregex(r, '@^/@'); /* escape all troublesome characters */ - r = sregex("/([\(\)\*\?\[\{\}]|\])/g", r, sub (m) { '\' ~ m; }); + r = sregex(r, "/([\(\)\*\?\[\{\}]|\])/g", sub (m) { '\' ~ m; }); /* store the tag information */ mp.tags[t[0]] = { diff --git a/mp_templates.mpsl b/mp_templates.mpsl index 820d3cc..19b91c7 100644 --- a/mp_templates.mpsl +++ b/mp_templates.mpsl @@ -93,7 +93,7 @@ sub mp.read_templates_file() } /* strip prefix */ - k = sregex("/^%%/", mp.chomp(l), NULL); + k = sregex(mp.chomp(l), "/^%%/"); v = NULL; } else { diff --git a/mp_tui.mpsl b/mp_tui.mpsl index feb67d0..4f42cab 100644 --- a/mp_tui.mpsl +++ b/mp_tui.mpsl @@ -43,7 +43,7 @@ sub mp.tui.prompt(prompt, y) y = mp.window.ty - 1; /* delete all possible newlines */ - prompt = sregex("/\n/g", prompt, ' '); + prompt = sregex(prompt, "/\n/g", ' '); mp.tui.attr(mp.colors.menu.attr); mp.tui.move(0, y, 1); @@ -88,7 +88,7 @@ sub mp.tui.readline(prompt, history, default, flags) /* if it's a password, change everything to asterisks */ if (flags.password) - s = sregex('/./g', s, flags.password); + s = sregex(s, '/./g', flags.password); /* draws the string */ mp.tui.move(c[0], c[1], 1); @@ -480,7 +480,7 @@ sub mp.drv.menu() local l = L(mp.menu[n][0]); /* strip (by now) the & */ - l = sregex('/&/g', l, NULL); + l = sregex(l, '/&/g', NULL); mp.tui.attr(mp.colors.menu.attr); mp.tui.addstr(' '); diff --git a/mpv_qk_common.cpp b/mpv_qk_common.cpp index c765346..268d869 100644 --- a/mpv_qk_common.cpp +++ b/mpv_qk_common.cpp @@ -969,7 +969,7 @@ void MPArea::from_filetabs(int value) void MPArea::from_menu(QAction * action) { mpdm_t label = qstring_to_str(action->text()); - label = mpdm_sregex(MPDM_LS(L"/&/"), label, NULL, 0); + label = mpdm_sregex(label, MPDM_LS(L"/&/"), NULL, 0); mpdm_t a = mpdm_hget_s(mp, L"actions_by_menu_label"); diff --git a/tools/po2mpsl.mpsl b/tools/po2mpsl.mpsl index b4a8a2c..6064e43 100644 --- a/tools/po2mpsl.mpsl +++ b/tools/po2mpsl.mpsl @@ -8,8 +8,8 @@ sub convert_po_line(line) { - line = sregex('/^\s*"/', line); - line = sregex('/"$/', line); + line = sregex(line, '/^\s*"/'); + line = sregex(line, '/"$/'); line = split(line); diff --git a/tools/update_ref_docs.mpsl b/tools/update_ref_docs.mpsl index fb66125..cdf0175 100644 --- a/tools/update_ref_docs.mpsl +++ b/tools/update_ref_docs.mpsl @@ -26,7 +26,7 @@ sub load_ref_document(file) k = NULL; while (l = read(f)) { - l = sregex("/\r?\n$/", l); + l = sregex(l, "/\r?\n$/"); /* is the line only dashes? */ if (regex('/^-+$/', l)) { @@ -45,7 +45,7 @@ sub load_ref_document(file) } else { /* there is a previous one; store */ - r.data[k] = sregex("/^\n/", sregex("/\n$/", b)); + r.data[k] = sregex(sregex(b, "/\n$/"), "/^\n/"); } k = p; @@ -84,7 +84,7 @@ sub save_ref_document(file, r, hash, prefix, def) k = prefix ~ '.' ~ k; write(f, k ~ "\n"); - write(f, sregex('/./g', k, '-')); + write(f, sregex(k, '/./g', '-')); write(f, "\n\n"); write(f, r.data[k] || def[k] || "To be written."); -- 2.11.4.GIT