[mythtv] [PATCH] OSD regexp substitution

David Engel dlengel at attbi.com
Wed Oct 22 15:31:31 EDT 2003


On Wed, Oct 22, 2003 at 01:47:10PM -0400, Chris Pinkham wrote:
> I haven't tested it, but was wondering if it is possible to make all 3
> optional with one regex.  So it would be "%FIELD|prefix|suffix|ifnull%".
> A user could use any one of the following:

No problem.  I actually did that in an earlier prototype but took it
out because I was concerned about compatibility.  I no longer think
compatbility should be a problem so the new patch is below.

David
-- 
David Engel
dlengel at attbi.com

Index: libs/libmythtv/osdtypes.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/osdtypes.cpp,v
retrieving revision 1.34
diff -u -r1.34 osdtypes.cpp
--- libs/libmythtv/osdtypes.cpp	18 Oct 2003 23:40:36 -0000	1.34
+++ libs/libmythtv/osdtypes.cpp	22 Oct 2003 19:26:24 -0000
@@ -242,8 +242,13 @@
             else
                 for (; riter != regexpMap.end(); riter++)
                 {
-                    full_regex = "%" + riter.key().upper() + "%";
-                    new_text.replace(QRegExp(full_regex), riter.data());
+		    full_regex = "%" + riter.key().upper() + 
+		      "(\\|([^%|]*))?" + "(\\|([^%|]*))?" + "(\\|([^%]*))?%";
+		    if (riter.data() != "")
+			new_text.replace(QRegExp(full_regex), 
+					 "\\2" + riter.data() + "\\4");
+		    else
+			new_text.replace(QRegExp(full_regex), "\\6");
                 }
 
             if (new_text != "")


More information about the mythtv-dev mailing list