summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-29 23:56:41 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 23:03:20 +0200
commit8b40494e932c3ddc093a01dacd4ebf0e2fd04bc3 (patch)
treeb8d108f80063ed9fde112ae6c67d77c8ebf95e4e /osdep
parent3789e1bebf23ce1c64d8ef8d9961e6e405747c5d (diff)
downloadmpv-8b40494e932c3ddc093a01dacd4ebf0e2fd04bc3.tar.bz2
mpv-8b40494e932c3ddc093a01dacd4ebf0e2fd04bc3.tar.xz
macosx_application: refactor filename escape
Use Objective-C's new literal syntax to make the code simpler.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_application.m22
1 files changed, 8 insertions, 14 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index f182a2643d..ee1316fe59 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -58,22 +58,16 @@ static pthread_t playback_thread_id;
@synthesize keyFIFO = _key_fifo;
@synthesize menuItems = _menu_items;
-struct escape_couple {
- NSString *in;
- NSString *out;
-};
-
-static struct escape_couple escapes[] = {
- { @"\\", @"\\\\" },
- { @"\"", @"\\\"" },
- { NULL, NULL }
-};
-
static NSString *escape_loadfile_name(NSString *input)
{
- for (int i = 0; escapes[i].out; i++) {
- input = [input stringByReplacingOccurrencesOfString:escapes[i].in
- withString:escapes[i].out];
+ NSArray *mappings = @[
+ @{ @"in": @"\\", @"out": @"\\\\" },
+ @{ @"in": @"\"", @"out": @"\\\"" },
+ ];
+
+ for (NSDictionary *mapping in mappings) {
+ input = [input stringByReplacingOccurrencesOfString:mapping[@"in"]
+ withString:mapping[@"out"]];
}
return input;