Changeset 391 for python/trunk/Mac/PythonLauncher/FileSettings.m
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Mac/PythonLauncher/FileSettings.m
r2 r391 15 15 static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc; 16 16 FileSettings **curdefault; 17 17 18 18 if ([filetype isEqualToString: @"Python Script"]) { 19 19 curdefault = &fsdefault_py; … … 37 37 static FileSettings *default_py, *default_pyw, *default_pyc; 38 38 FileSettings **curdefault; 39 39 40 40 if ([filetype isEqualToString: @"Python Script"]) { 41 41 curdefault = &default_py; … … 58 58 { 59 59 FileSettings *cur; 60 60 61 61 cur = [FileSettings new]; 62 62 [cur initForFileType: filetype]; … … 68 68 self = [super init]; 69 69 if (!self) return self; 70 70 71 71 interpreter = [source->interpreter retain]; 72 72 honourhashbang = source->honourhashbang; … … 82 82 prefskey = source->prefskey; 83 83 if (prefskey) [prefskey retain]; 84 84 85 85 return self; 86 86 } … … 89 89 { 90 90 FileSettings *defaults; 91 91 92 92 defaults = [FileSettings getDefaultsForFileType: filetype]; 93 93 self = [self initWithFileSettings: defaults]; … … 96 96 } 97 97 98 //- (id)init99 //{100 // self = [self initForFileType: @"Python Script"];101 // return self;102 //}103 104 98 - (id)initForFSDefaultFileType: (NSString *)filetype 105 99 { … … 108 102 NSDictionary *dict; 109 103 static NSDictionary *factorySettings; 110 104 111 105 self = [super init]; 112 106 if (!self) return self; 113 107 114 108 if (factorySettings == NULL) { 115 109 NSBundle *bdl = [NSBundle mainBundle]; … … 150 144 NSUserDefaults *defaults; 151 145 NSDictionary *dict; 152 146 153 147 defaults = [NSUserDefaults standardUserDefaults]; 154 148 dict = [defaults dictionaryForKey: filetype]; … … 157 151 [self applyValuesFromDict: dict]; 158 152 } 159 153 160 154 - (id)initForDefaultFileType: (NSString *)filetype 161 155 { 162 156 FileSettings *fsdefaults; 163 157 164 158 fsdefaults = [FileSettings getFactorySettingsForFileType: filetype]; 165 159 self = [self initWithFileSettings: fsdefaults]; … … 221 215 { 222 216 id value; 223 217 224 218 value = [dict objectForKey: @"interpreter"]; 225 219 if (value) interpreter = [value retain]; … … 248 242 - (NSString*)_replaceSingleQuotes: (NSString*)string 249 243 { 250 251 252 253 254 255 244 /* Replace all single-quotes by '"'"', that way shellquoting will 245 * be correct when the result value is delimited using single quotes. 246 */ 247 NSArray* components = [string componentsSeparatedByString:@"'"]; 248 249 return [components componentsJoinedByString:@"'\"'\"'"]; 256 250 } 257 251 … … 266 260 script_dir = [script substringToIndex: 267 261 [script length]-[[script lastPathComponent] length]]; 268 262 269 263 if (honourhashbang && 270 (fp=fopen([script cString], "r")) &&264 (fp=fopen([script fileSystemRepresentation], "r")) && 271 265 fgets(hashbangbuf, sizeof(hashbangbuf), fp) && 272 266 strncmp(hashbangbuf, "#!", 2) == 0 && … … 275 269 p = hashbangbuf + 2; 276 270 while (*p == ' ') p++; 277 cur_interp = [NSString stringWith CString: p];271 cur_interp = [NSString stringWithUTF8String: p]; 278 272 } 279 273 if (!cur_interp) 280 274 cur_interp = interpreter; 281 275 282 276 return [NSString stringWithFormat: 283 277 @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s", … … 298 292 - (NSArray *) interpreters { return interpreters;}; 299 293 300 // FileSettingsSource protocol 294 // FileSettingsSource protocol 301 295 - (NSString *) interpreter { return interpreter;}; 302 296 - (BOOL) honourhashbang { return honourhashbang; };
Note:
See TracChangeset
for help on using the changeset viewer.