src/main/macos/SDL_main.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/main/macos/SDL_main.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/main/macos/SDL_main.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -64,11 +64,11 @@
     1.4  
     1.5  /* See if the command key is held down at startup */
     1.6  static Boolean
     1.7 -CommandKeyIsDown (void)
     1.8 +CommandKeyIsDown(void)
     1.9  {
    1.10      KeyMap theKeyMap;
    1.11  
    1.12 -    GetKeys (theKeyMap);
    1.13 +    GetKeys(theKeyMap);
    1.14  
    1.15      if (((unsigned char *) theKeyMap)[6] & 0x80) {
    1.16          return (true);
    1.17 @@ -80,7 +80,7 @@
    1.18  
    1.19  /* Parse a command line buffer into arguments */
    1.20  static int
    1.21 -ParseCommandLine (char *cmdline, char **argv)
    1.22 +ParseCommandLine(char *cmdline, char **argv)
    1.23  {
    1.24      char *bufp;
    1.25      int argc;
    1.26 @@ -88,7 +88,7 @@
    1.27      argc = 0;
    1.28      for (bufp = cmdline; *bufp;) {
    1.29          /* Skip leading whitespace */
    1.30 -        while (SDL_isspace (*bufp)) {
    1.31 +        while (SDL_isspace(*bufp)) {
    1.32              ++bufp;
    1.33          }
    1.34          /* Skip over argument */
    1.35 @@ -112,7 +112,7 @@
    1.36                  ++argc;
    1.37              }
    1.38              /* Skip over word */
    1.39 -            while (*bufp && !SDL_isspace (*bufp)) {
    1.40 +            while (*bufp && !SDL_isspace(*bufp)) {
    1.41                  ++bufp;
    1.42              }
    1.43          }
    1.44 @@ -131,30 +131,30 @@
    1.45  
    1.46  /* Remove the output files if there was no output written */
    1.47  static void
    1.48 -cleanup_output (void)
    1.49 +cleanup_output(void)
    1.50  {
    1.51      FILE *file;
    1.52      int empty;
    1.53  
    1.54      /* Flush the output in case anything is queued */
    1.55 -    fclose (stdout);
    1.56 -    fclose (stderr);
    1.57 +    fclose(stdout);
    1.58 +    fclose(stderr);
    1.59  
    1.60      /* See if the files have any output in them */
    1.61 -    file = fopen (STDOUT_FILE, "rb");
    1.62 +    file = fopen(STDOUT_FILE, "rb");
    1.63      if (file) {
    1.64 -        empty = (fgetc (file) == EOF) ? 1 : 0;
    1.65 -        fclose (file);
    1.66 +        empty = (fgetc(file) == EOF) ? 1 : 0;
    1.67 +        fclose(file);
    1.68          if (empty) {
    1.69 -            remove (STDOUT_FILE);
    1.70 +            remove(STDOUT_FILE);
    1.71          }
    1.72      }
    1.73 -    file = fopen (STDERR_FILE, "rb");
    1.74 +    file = fopen(STDERR_FILE, "rb");
    1.75      if (file) {
    1.76 -        empty = (fgetc (file) == EOF) ? 1 : 0;
    1.77 -        fclose (file);
    1.78 +        empty = (fgetc(file) == EOF) ? 1 : 0;
    1.79 +        fclose(file);
    1.80          if (empty) {
    1.81 -            remove (STDERR_FILE);
    1.82 +            remove(STDERR_FILE);
    1.83          }
    1.84      }
    1.85  }
    1.86 @@ -162,7 +162,7 @@
    1.87  #endif //!(defined(__APPLE__) && defined(__MACH__))
    1.88  
    1.89  static int
    1.90 -getCurrentAppName (StrFileName name)
    1.91 +getCurrentAppName(StrFileName name)
    1.92  {
    1.93  
    1.94      ProcessSerialNumber process;
    1.95 @@ -171,19 +171,19 @@
    1.96  
    1.97      process.highLongOfPSN = 0;
    1.98      process.lowLongOfPSN = kCurrentProcess;
    1.99 -    process_info.processInfoLength = sizeof (process_info);
   1.100 +    process_info.processInfoLength = sizeof(process_info);
   1.101      process_info.processName = NULL;
   1.102      process_info.processAppSpec = &process_fsp;
   1.103  
   1.104 -    if (noErr != GetProcessInformation (&process, &process_info))
   1.105 +    if (noErr != GetProcessInformation(&process, &process_info))
   1.106          return 0;
   1.107  
   1.108 -    SDL_memcpy (name, process_fsp.name, process_fsp.name[0] + 1);
   1.109 +    SDL_memcpy(name, process_fsp.name, process_fsp.name[0] + 1);
   1.110      return 1;
   1.111  }
   1.112  
   1.113  static int
   1.114 -getPrefsFile (FSSpec * prefs_fsp, int create)
   1.115 +getPrefsFile(FSSpec * prefs_fsp, int create)
   1.116  {
   1.117  
   1.118      /* The prefs file name is the application name, possibly truncated, */
   1.119 @@ -199,36 +199,36 @@
   1.120  
   1.121      /* Get Preferences folder - works with Multiple Users */
   1.122      if (noErr !=
   1.123 -        FindFolder (kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder,
   1.124 -                    &volume_ref_number, &directory_id))
   1.125 -        exit (-1);
   1.126 +        FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder,
   1.127 +                   &volume_ref_number, &directory_id))
   1.128 +        exit(-1);
   1.129  
   1.130 -    if (!getCurrentAppName (app_name))
   1.131 -        exit (-1);
   1.132 +    if (!getCurrentAppName(app_name))
   1.133 +        exit(-1);
   1.134  
   1.135      /* Truncate if name is too long */
   1.136      if (app_name[0] > MAX_NAME)
   1.137          app_name[0] = MAX_NAME;
   1.138  
   1.139 -    SDL_memcpy (prefs_name + 1, app_name + 1, app_name[0]);
   1.140 -    SDL_memcpy (prefs_name + app_name[0] + 1, SUFFIX, strlen (SUFFIX));
   1.141 -    prefs_name[0] = app_name[0] + strlen (SUFFIX);
   1.142 +    SDL_memcpy(prefs_name + 1, app_name + 1, app_name[0]);
   1.143 +    SDL_memcpy(prefs_name + app_name[0] + 1, SUFFIX, strlen(SUFFIX));
   1.144 +    prefs_name[0] = app_name[0] + strlen(SUFFIX);
   1.145  
   1.146      /* Make the file spec for prefs file */
   1.147      if (noErr !=
   1.148 -        FSMakeFSSpec (volume_ref_number, directory_id, prefs_name, prefs_fsp))
   1.149 +        FSMakeFSSpec(volume_ref_number, directory_id, prefs_name, prefs_fsp))
   1.150      {
   1.151          if (!create)
   1.152              return 0;
   1.153          else {
   1.154              /* Create the prefs file */
   1.155 -            SDL_memcpy (prefs_fsp->name, prefs_name, prefs_name[0] + 1);
   1.156 +            SDL_memcpy(prefs_fsp->name, prefs_name, prefs_name[0] + 1);
   1.157              prefs_fsp->parID = directory_id;
   1.158              prefs_fsp->vRefNum = volume_ref_number;
   1.159  
   1.160 -            FSpCreateResFile (prefs_fsp, 0x3f3f3f3f, 'pref', 0);        // '????' parsed as trigraph
   1.161 +            FSpCreateResFile(prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph
   1.162  
   1.163 -            if (noErr != ResError ())
   1.164 +            if (noErr != ResError())
   1.165                  return 0;
   1.166          }
   1.167      }
   1.168 @@ -236,133 +236,133 @@
   1.169  }
   1.170  
   1.171  static int
   1.172 -readPrefsResource (PrefsRecord * prefs)
   1.173 +readPrefsResource(PrefsRecord * prefs)
   1.174  {
   1.175  
   1.176      Handle prefs_handle;
   1.177  
   1.178 -    prefs_handle = Get1Resource ('CLne', 128);
   1.179 +    prefs_handle = Get1Resource('CLne', 128);
   1.180  
   1.181      if (prefs_handle != NULL) {
   1.182          int offset = 0;
   1.183  //              int j      = 0;
   1.184  
   1.185 -        HLock (prefs_handle);
   1.186 +        HLock(prefs_handle);
   1.187  
   1.188          /* Get command line string */
   1.189 -        SDL_memcpy (prefs->command_line, *prefs_handle,
   1.190 -                    (*prefs_handle)[0] + 1);
   1.191 +        SDL_memcpy(prefs->command_line, *prefs_handle,
   1.192 +                   (*prefs_handle)[0] + 1);
   1.193  
   1.194          /* Get video driver name */
   1.195          offset += (*prefs_handle)[0] + 1;
   1.196 -        SDL_memcpy (prefs->video_driver_name, *prefs_handle + offset,
   1.197 -                    (*prefs_handle)[offset] + 1);
   1.198 +        SDL_memcpy(prefs->video_driver_name, *prefs_handle + offset,
   1.199 +                   (*prefs_handle)[offset] + 1);
   1.200  
   1.201          /* Get save-to-file option (1 or 0) */
   1.202          offset += (*prefs_handle)[offset] + 1;
   1.203          prefs->output_to_file = (*prefs_handle)[offset];
   1.204  
   1.205 -        ReleaseResource (prefs_handle);
   1.206 +        ReleaseResource(prefs_handle);
   1.207  
   1.208 -        return ResError () == noErr;
   1.209 +        return ResError() == noErr;
   1.210      }
   1.211  
   1.212      return 0;
   1.213  }
   1.214  
   1.215  static int
   1.216 -writePrefsResource (PrefsRecord * prefs, short resource_file)
   1.217 +writePrefsResource(PrefsRecord * prefs, short resource_file)
   1.218  {
   1.219  
   1.220      Handle prefs_handle;
   1.221  
   1.222 -    UseResFile (resource_file);
   1.223 +    UseResFile(resource_file);
   1.224  
   1.225 -    prefs_handle = Get1Resource ('CLne', 128);
   1.226 +    prefs_handle = Get1Resource('CLne', 128);
   1.227      if (prefs_handle != NULL)
   1.228 -        RemoveResource (prefs_handle);
   1.229 +        RemoveResource(prefs_handle);
   1.230  
   1.231      prefs_handle =
   1.232 -        NewHandle (prefs->command_line[0] + prefs->video_driver_name[0] + 4);
   1.233 +        NewHandle(prefs->command_line[0] + prefs->video_driver_name[0] + 4);
   1.234      if (prefs_handle != NULL) {
   1.235  
   1.236          int offset;
   1.237  
   1.238 -        HLock (prefs_handle);
   1.239 +        HLock(prefs_handle);
   1.240  
   1.241          /* Command line text */
   1.242          offset = 0;
   1.243 -        SDL_memcpy (*prefs_handle, prefs->command_line,
   1.244 -                    prefs->command_line[0] + 1);
   1.245 +        SDL_memcpy(*prefs_handle, prefs->command_line,
   1.246 +                   prefs->command_line[0] + 1);
   1.247  
   1.248          /* Video driver name */
   1.249          offset += prefs->command_line[0] + 1;
   1.250 -        SDL_memcpy (*prefs_handle + offset, prefs->video_driver_name,
   1.251 -                    prefs->video_driver_name[0] + 1);
   1.252 +        SDL_memcpy(*prefs_handle + offset, prefs->video_driver_name,
   1.253 +                   prefs->video_driver_name[0] + 1);
   1.254  
   1.255          /* Output-to-file option */
   1.256          offset += prefs->video_driver_name[0] + 1;
   1.257          *(*((char **) prefs_handle) + offset) = (char) prefs->output_to_file;
   1.258          *(*((char **) prefs_handle) + offset + 1) = 0;
   1.259  
   1.260 -        AddResource (prefs_handle, 'CLne', 128, "\pCommand Line");
   1.261 -        WriteResource (prefs_handle);
   1.262 -        UpdateResFile (resource_file);
   1.263 -        DisposeHandle (prefs_handle);
   1.264 +        AddResource(prefs_handle, 'CLne', 128, "\pCommand Line");
   1.265 +        WriteResource(prefs_handle);
   1.266 +        UpdateResFile(resource_file);
   1.267 +        DisposeHandle(prefs_handle);
   1.268  
   1.269 -        return ResError () == noErr;
   1.270 +        return ResError() == noErr;
   1.271      }
   1.272  
   1.273      return 0;
   1.274  }
   1.275  
   1.276  static int
   1.277 -readPreferences (PrefsRecord * prefs)
   1.278 +readPreferences(PrefsRecord * prefs)
   1.279  {
   1.280  
   1.281      int no_error = 1;
   1.282      FSSpec prefs_fsp;
   1.283  
   1.284      /* Check for prefs file first */
   1.285 -    if (getPrefsFile (&prefs_fsp, 0)) {
   1.286 +    if (getPrefsFile(&prefs_fsp, 0)) {
   1.287  
   1.288          short prefs_resource;
   1.289  
   1.290 -        prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdPerm);
   1.291 +        prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdPerm);
   1.292          if (prefs_resource == -1)       /* this shouldn't happen, but... */
   1.293              return 0;
   1.294  
   1.295 -        UseResFile (prefs_resource);
   1.296 -        no_error = readPrefsResource (prefs);
   1.297 -        CloseResFile (prefs_resource);
   1.298 +        UseResFile(prefs_resource);
   1.299 +        no_error = readPrefsResource(prefs);
   1.300 +        CloseResFile(prefs_resource);
   1.301      }
   1.302  
   1.303      /* Fall back to application's resource fork (reading only, so this is safe) */
   1.304      else {
   1.305  
   1.306 -        no_error = readPrefsResource (prefs);
   1.307 +        no_error = readPrefsResource(prefs);
   1.308      }
   1.309  
   1.310      return no_error;
   1.311  }
   1.312  
   1.313  static int
   1.314 -writePreferences (PrefsRecord * prefs)
   1.315 +writePreferences(PrefsRecord * prefs)
   1.316  {
   1.317  
   1.318      int no_error = 1;
   1.319      FSSpec prefs_fsp;
   1.320  
   1.321      /* Get prefs file, create if it doesn't exist */
   1.322 -    if (getPrefsFile (&prefs_fsp, 1)) {
   1.323 +    if (getPrefsFile(&prefs_fsp, 1)) {
   1.324  
   1.325          short prefs_resource;
   1.326  
   1.327 -        prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdWrPerm);
   1.328 +        prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdWrPerm);
   1.329          if (prefs_resource == -1)
   1.330              return 0;
   1.331 -        no_error = writePrefsResource (prefs, prefs_resource);
   1.332 -        CloseResFile (prefs_resource);
   1.333 +        no_error = writePrefsResource(prefs, prefs_resource);
   1.334 +        CloseResFile(prefs_resource);
   1.335      }
   1.336  
   1.337      return no_error;
   1.338 @@ -370,7 +370,7 @@
   1.339  
   1.340  /* This is where execution begins */
   1.341  int
   1.342 -main (int argc, char *argv[])
   1.343 +main(int argc, char *argv[])
   1.344  {
   1.345  
   1.346  #if !(defined(__APPLE__) && defined(__MACH__))
   1.347 @@ -401,22 +401,22 @@
   1.348  
   1.349      /* Kyle's SDL command-line dialog code ... */
   1.350  #if !TARGET_API_MAC_CARBON
   1.351 -    InitGraf (&qd.thePort);
   1.352 -    InitFonts ();
   1.353 -    InitWindows ();
   1.354 -    InitMenus ();
   1.355 -    InitDialogs (nil);
   1.356 +    InitGraf(&qd.thePort);
   1.357 +    InitFonts();
   1.358 +    InitWindows();
   1.359 +    InitMenus();
   1.360 +    InitDialogs(nil);
   1.361  #endif
   1.362 -    InitCursor ();
   1.363 -    FlushEvents (everyEvent, 0);
   1.364 +    InitCursor();
   1.365 +    FlushEvents(everyEvent, 0);
   1.366  #if !TARGET_API_MAC_CARBON
   1.367 -    MaxApplZone ();
   1.368 +    MaxApplZone();
   1.369  #endif
   1.370 -    MoreMasters ();
   1.371 -    MoreMasters ();
   1.372 +    MoreMasters();
   1.373 +    MoreMasters();
   1.374  #if 0
   1.375      /* Intialize SDL, and put up a dialog if we fail */
   1.376 -    if (SDL_Init (0) < 0) {
   1.377 +    if (SDL_Init(0) < 0) {
   1.378  
   1.379  #define kErr_OK		1
   1.380  #define kErr_Text	2
   1.381 @@ -427,46 +427,46 @@
   1.382          Handle dummyHandle;
   1.383          short itemHit;
   1.384  
   1.385 -        errorDialog = GetNewDialog (1001, nil, (WindowPtr) - 1);
   1.386 +        errorDialog = GetNewDialog(1001, nil, (WindowPtr) - 1);
   1.387          if (errorDialog == NULL)
   1.388              return -1;
   1.389 -        DrawDialog (errorDialog);
   1.390 +        DrawDialog(errorDialog);
   1.391  
   1.392 -        GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle,
   1.393 -                       &dummyRect);
   1.394 -        SetDialogItemText (dummyHandle, "\pError Initializing SDL");
   1.395 +        GetDialogItem(errorDialog, kErr_Text, &dummyType, &dummyHandle,
   1.396 +                      &dummyRect);
   1.397 +        SetDialogItemText(dummyHandle, "\pError Initializing SDL");
   1.398  
   1.399  #if TARGET_API_MAC_CARBON
   1.400 -        SetPort (GetDialogPort (errorDialog));
   1.401 +        SetPort(GetDialogPort(errorDialog));
   1.402  #else
   1.403 -        SetPort (errorDialog);
   1.404 +        SetPort(errorDialog);
   1.405  #endif
   1.406          do {
   1.407 -            ModalDialog (nil, &itemHit);
   1.408 +            ModalDialog(nil, &itemHit);
   1.409          }
   1.410          while (itemHit != kErr_OK);
   1.411  
   1.412 -        DisposeDialog (errorDialog);
   1.413 -        exit (-1);
   1.414 +        DisposeDialog(errorDialog);
   1.415 +        exit(-1);
   1.416      }
   1.417 -    atexit (cleanup_output);
   1.418 -    atexit (SDL_Quit);
   1.419 +    atexit(cleanup_output);
   1.420 +    atexit(SDL_Quit);
   1.421  #endif
   1.422  
   1.423  /* Set up SDL's QuickDraw environment  */
   1.424  #if !TARGET_API_MAC_CARBON
   1.425 -    SDL_InitQuickDraw (&qd);
   1.426 +    SDL_InitQuickDraw(&qd);
   1.427  #endif
   1.428  
   1.429 -    if (readPreferences (&prefs)) {
   1.430 +    if (readPreferences(&prefs)) {
   1.431  
   1.432 -        if (SDL_memcmp (prefs.video_driver_name + 1, "DSp", 3) == 0)
   1.433 +        if (SDL_memcmp(prefs.video_driver_name + 1, "DSp", 3) == 0)
   1.434              videodriver = 1;
   1.435 -        else if (SDL_memcmp (prefs.video_driver_name + 1, "toolbox", 7) == 0)
   1.436 +        else if (SDL_memcmp(prefs.video_driver_name + 1, "toolbox", 7) == 0)
   1.437              videodriver = 2;
   1.438      }
   1.439  
   1.440 -    if (CommandKeyIsDown ()) {
   1.441 +    if (CommandKeyIsDown()) {
   1.442  
   1.443  #define kCL_OK		1
   1.444  #define kCL_Cancel	2
   1.445 @@ -487,52 +487,52 @@
   1.446          settingsChanged = 1;
   1.447  
   1.448          /* Create dialog and display it */
   1.449 -        commandDialog = GetNewDialog (1000, nil, (WindowPtr) - 1);
   1.450 +        commandDialog = GetNewDialog(1000, nil, (WindowPtr) - 1);
   1.451  #if TARGET_API_MAC_CARBON
   1.452 -        SetPort (GetDialogPort (commandDialog));
   1.453 +        SetPort(GetDialogPort(commandDialog));
   1.454  #else
   1.455 -        SetPort (commandDialog);
   1.456 +        SetPort(commandDialog);
   1.457  #endif
   1.458  
   1.459          /* Setup controls */
   1.460  #if TARGET_API_MAC_CARBON
   1.461 -        GetDialogItemAsControl (commandDialog, kCL_File, &control);
   1.462 -        SetControlValue (control, prefs.output_to_file);
   1.463 +        GetDialogItemAsControl(commandDialog, kCL_File, &control);
   1.464 +        SetControlValue(control, prefs.output_to_file);
   1.465  #else
   1.466 -        GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);  /* MJS */
   1.467 -        SetControlValue ((ControlHandle) dummyHandle, prefs.output_to_file);
   1.468 +        GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
   1.469 +        SetControlValue((ControlHandle) dummyHandle, prefs.output_to_file);
   1.470  #endif
   1.471  
   1.472 -        GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle,
   1.473 -                       &dummyRect);
   1.474 -        SetDialogItemText (dummyHandle, prefs.command_line);
   1.475 +        GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle,
   1.476 +                      &dummyRect);
   1.477 +        SetDialogItemText(dummyHandle, prefs.command_line);
   1.478  
   1.479  #if TARGET_API_MAC_CARBON
   1.480 -        GetDialogItemAsControl (commandDialog, kCL_Video, &control);
   1.481 -        SetControlValue (control, videodriver);
   1.482 +        GetDialogItemAsControl(commandDialog, kCL_Video, &control);
   1.483 +        SetControlValue(control, videodriver);
   1.484  #else
   1.485 -        GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle,
   1.486 -                       &dummyRect);
   1.487 -        SetControlValue ((ControlRef) dummyHandle, videodriver);
   1.488 +        GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle,
   1.489 +                      &dummyRect);
   1.490 +        SetControlValue((ControlRef) dummyHandle, videodriver);
   1.491  #endif
   1.492  
   1.493 -        SetDialogDefaultItem (commandDialog, kCL_OK);
   1.494 -        SetDialogCancelItem (commandDialog, kCL_Cancel);
   1.495 +        SetDialogDefaultItem(commandDialog, kCL_OK);
   1.496 +        SetDialogCancelItem(commandDialog, kCL_Cancel);
   1.497  
   1.498          do {
   1.499  
   1.500 -            ModalDialog (nil, &itemHit);        /* wait for user response */
   1.501 +            ModalDialog(nil, &itemHit); /* wait for user response */
   1.502  
   1.503              /* Toggle command-line output checkbox */
   1.504              if (itemHit == kCL_File) {
   1.505  #if TARGET_API_MAC_CARBON
   1.506 -                GetDialogItemAsControl (commandDialog, kCL_File, &control);
   1.507 -                SetControlValue (control, !GetControlValue (control));
   1.508 +                GetDialogItemAsControl(commandDialog, kCL_File, &control);
   1.509 +                SetControlValue(control, !GetControlValue(control));
   1.510  #else
   1.511 -                GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);  /* MJS */
   1.512 -                SetControlValue ((ControlHandle) dummyHandle,
   1.513 -                                 !GetControlValue ((ControlHandle)
   1.514 -                                                   dummyHandle));
   1.515 +                GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
   1.516 +                SetControlValue((ControlHandle) dummyHandle,
   1.517 +                                !GetControlValue((ControlHandle)
   1.518 +                                                 dummyHandle));
   1.519  #endif
   1.520              }
   1.521  
   1.522 @@ -540,69 +540,68 @@
   1.523          while (itemHit != kCL_OK && itemHit != kCL_Cancel);
   1.524  
   1.525          /* Get control values, even if they did not change */
   1.526 -        GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect);  /* MJS */
   1.527 -        GetDialogItemText (dummyHandle, prefs.command_line);
   1.528 +        GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
   1.529 +        GetDialogItemText(dummyHandle, prefs.command_line);
   1.530  
   1.531  #if TARGET_API_MAC_CARBON
   1.532 -        GetDialogItemAsControl (commandDialog, kCL_File, &control);
   1.533 -        prefs.output_to_file = GetControlValue (control);
   1.534 +        GetDialogItemAsControl(commandDialog, kCL_File, &control);
   1.535 +        prefs.output_to_file = GetControlValue(control);
   1.536  #else
   1.537 -        GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);  /* MJS */
   1.538 -        prefs.output_to_file = GetControlValue ((ControlHandle) dummyHandle);
   1.539 +        GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect);   /* MJS */
   1.540 +        prefs.output_to_file = GetControlValue((ControlHandle) dummyHandle);
   1.541  #endif
   1.542  
   1.543  #if TARGET_API_MAC_CARBON
   1.544 -        GetDialogItemAsControl (commandDialog, kCL_Video, &control);
   1.545 -        videodriver = GetControlValue (control);
   1.546 +        GetDialogItemAsControl(commandDialog, kCL_Video, &control);
   1.547 +        videodriver = GetControlValue(control);
   1.548  #else
   1.549 -        GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle,
   1.550 -                       &dummyRect);
   1.551 -        videodriver = GetControlValue ((ControlRef) dummyHandle);
   1.552 +        GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle,
   1.553 +                      &dummyRect);
   1.554 +        videodriver = GetControlValue((ControlRef) dummyHandle);
   1.555  #endif
   1.556  
   1.557 -        DisposeDialog (commandDialog);
   1.558 +        DisposeDialog(commandDialog);
   1.559  
   1.560          if (itemHit == kCL_Cancel) {
   1.561 -            exit (0);
   1.562 +            exit(0);
   1.563          }
   1.564      }
   1.565  
   1.566      /* Set pseudo-environment variables for video driver, update prefs */
   1.567      switch (videodriver) {
   1.568      case VIDEO_ID_DRAWSPROCKET:
   1.569 -        SDL_putenv ("SDL_VIDEODRIVER=DSp");
   1.570 -        SDL_memcpy (prefs.video_driver_name, "\pDSp", 4);
   1.571 +        SDL_putenv("SDL_VIDEODRIVER=DSp");
   1.572 +        SDL_memcpy(prefs.video_driver_name, "\pDSp", 4);
   1.573          break;
   1.574      case VIDEO_ID_TOOLBOX:
   1.575 -        SDL_putenv ("SDL_VIDEODRIVER=toolbox");
   1.576 -        SDL_memcpy (prefs.video_driver_name, "\ptoolbox", 8);
   1.577 +        SDL_putenv("SDL_VIDEODRIVER=toolbox");
   1.578 +        SDL_memcpy(prefs.video_driver_name, "\ptoolbox", 8);
   1.579          break;
   1.580      }
   1.581  
   1.582  #if !(defined(__APPLE__) && defined(__MACH__))
   1.583      /* Redirect standard I/O to files */
   1.584      if (prefs.output_to_file) {
   1.585 -        freopen (STDOUT_FILE, "w", stdout);
   1.586 -        freopen (STDERR_FILE, "w", stderr);
   1.587 +        freopen(STDOUT_FILE, "w", stdout);
   1.588 +        freopen(STDERR_FILE, "w", stderr);
   1.589      } else {
   1.590 -        fclose (stdout);
   1.591 -        fclose (stderr);
   1.592 +        fclose(stdout);
   1.593 +        fclose(stderr);
   1.594      }
   1.595  #endif
   1.596  
   1.597      if (settingsChanged) {
   1.598          /* Save the prefs, even if they might not have changed (but probably did) */
   1.599 -        if (!writePreferences (&prefs))
   1.600 -            fprintf (stderr, "WARNING: Could not save preferences!\n");
   1.601 +        if (!writePreferences(&prefs))
   1.602 +            fprintf(stderr, "WARNING: Could not save preferences!\n");
   1.603      }
   1.604  #if !(defined(__APPLE__) && defined(__MACH__))
   1.605      appNameText[0] = 0;
   1.606 -    getCurrentAppName (appNameText);    /* check for error here ? */
   1.607 +    getCurrentAppName(appNameText);     /* check for error here ? */
   1.608  
   1.609 -    commandLine =
   1.610 -        (char *) malloc (appNameText[0] + prefs.command_line[0] + 2);
   1.611 +    commandLine = (char *) malloc(appNameText[0] + prefs.command_line[0] + 2);
   1.612      if (commandLine == NULL) {
   1.613 -        exit (-1);
   1.614 +        exit(-1);
   1.615      }
   1.616  
   1.617      /* Rather than rewrite ParseCommandLine method, let's replace  */
   1.618 @@ -613,33 +612,33 @@
   1.619              appNameText[i] = '_';
   1.620  
   1.621      /* Copy app name & full command text to command-line C-string */
   1.622 -    SDL_memcpy (commandLine, appNameText + 1, appNameText[0]);
   1.623 +    SDL_memcpy(commandLine, appNameText + 1, appNameText[0]);
   1.624      commandLine[appNameText[0]] = ' ';
   1.625 -    SDL_memcpy (commandLine + appNameText[0] + 1, prefs.command_line + 1,
   1.626 -                prefs.command_line[0]);
   1.627 +    SDL_memcpy(commandLine + appNameText[0] + 1, prefs.command_line + 1,
   1.628 +               prefs.command_line[0]);
   1.629      commandLine[appNameText[0] + 1 + prefs.command_line[0]] = '\0';
   1.630  
   1.631      /* Parse C-string into argv and argc */
   1.632 -    nargs = ParseCommandLine (commandLine, NULL);
   1.633 -    args = (char **) malloc ((nargs + 1) * (sizeof *args));
   1.634 +    nargs = ParseCommandLine(commandLine, NULL);
   1.635 +    args = (char **) malloc((nargs + 1) * (sizeof *args));
   1.636      if (args == NULL) {
   1.637 -        exit (-1);
   1.638 +        exit(-1);
   1.639      }
   1.640 -    ParseCommandLine (commandLine, args);
   1.641 +    ParseCommandLine(commandLine, args);
   1.642  
   1.643      /* Run the main application code */
   1.644 -    SDL_main (nargs, args);
   1.645 -    free (args);
   1.646 -    free (commandLine);
   1.647 +    SDL_main(nargs, args);
   1.648 +    free(args);
   1.649 +    free(commandLine);
   1.650  
   1.651      /* Remove useless stdout.txt and stderr.txt */
   1.652 -    cleanup_output ();
   1.653 +    cleanup_output();
   1.654  #else // defined(__APPLE__) && defined(__MACH__)
   1.655 -    SDL_main (argc, argv);
   1.656 +    SDL_main(argc, argv);
   1.657  #endif
   1.658  
   1.659      /* Exit cleanly, calling atexit() functions */
   1.660 -    exit (0);
   1.661 +    exit(0);
   1.662  
   1.663      /* Never reached, but keeps the compiler quiet */
   1.664      return (0);