Ticket #5896: mythtv-5896-allow_NIS_format_etc_timezone.patch
File mythtv-5896-allow_NIS_format_etc_timezone.patch, 2.0 KB (added by , 16 years ago) |
---|
-
libs/libmyth/util.cpp
old new 154 154 } 155 155 #endif 156 156 157 /* helper fuction to find the zone ID in a configuration string 158 allows NIS-format /etc/timezone , which contains extra information: 159 <time zone ID> <host or NIS domain name> # optional comments 160 */ 161 static bool parse_zone_id_config_string(QString& zone_id) 162 { 163 bool found = false; 164 QString zoneinfo_dir_path("/usr/share/zoneinfo/"); 165 QRegExp sep("\\s+"); 166 QFileInfo file_info; 167 168 while (!found) 169 { 170 QString temp_zone_id = zone_id; 171 temp_zone_id.replace(' ', '_'); 172 file_info.setFile(zoneinfo_dir_path + temp_zone_id); 173 if (file_info.exists()) 174 { 175 found = true; 176 } 177 else 178 { 179 zone_id = zone_id.section(sep, 0, -2); 180 if (zone_id.isEmpty()) 181 break; 182 } 183 } 184 return found; 185 } 186 157 187 /* helper fuction to read time zone id from a file 158 188 Debian's /etc/timezone or Red Hat's /etc/sysconfig/clock */ 159 189 static bool read_time_zone_id(QString filename, QString& zone_id) … … 168 198 QString line; 169 199 QTextStream in(&file); 170 200 // Handle whitespace and quotes 171 QRegExp re("^(?:ZONE\\s*=)?\\s*(['\"]?)([\\w\\s/-\\+]+)\\1\\s* $");201 QRegExp re("^(?:ZONE\\s*=)?\\s*(['\"]?)([\\w\\s/-\\+]+)\\1\\s*(?:#.*)?$"); 172 202 re.setPatternSyntax(QRegExp::RegExp2); 173 203 while (!in.atEnd()) 174 204 { … … 176 206 if (re.indexIn(line) != -1) 177 207 { 178 208 zone_id = re.cap(2); 179 found = true; 209 if (parse_zone_id_config_string(zone_id)) 210 found = true; 180 211 break; 181 212 } 182 213 }