Add GCC-style 'const' attribute to functions that can use it.
[bpt/emacs.git] / src / nsterm.m
index ae53663..4c4d3de 100644 (file)
@@ -36,6 +36,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
 #include <signal.h>
 #include <unistd.h>
 #include <setjmp.h>
+#include <c-strcase.h>
 
 #include "lisp.h"
 #include "blockinput.h"
@@ -285,6 +286,26 @@ append2 (Lisp_Object list, Lisp_Object item)
 }
 
 
+char *
+ns_etc_directory (void)
+{
+/* If running as a self-contained app bundle, return as a string the
+   filename of the etc directory, if present; else nil.  */
+
+     NSBundle *bundle = [NSBundle mainBundle];
+     NSString *resourceDir = [bundle resourcePath];
+     NSString *resourcePath;
+     NSFileManager *fileManager = [NSFileManager defaultManager];
+     BOOL isDir;
+
+     resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"];
+     if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
+     {
+          if (isDir) return [resourcePath UTF8String];
+     }
+     return nil;
+}
+
 void
 ns_init_paths (void)
 /* --------------------------------------------------------------------------
@@ -368,18 +389,6 @@ ns_init_paths (void)
       if ([resourcePaths length] > 0)
         setenv ("EMACSPATH", [resourcePaths UTF8String], 1);
     }
-
-  resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"];
-  if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
-    {
-      if (isDir)
-        {
-          if (!getenv ("EMACSDATA"))
-            setenv ("EMACSDATA", [resourcePath UTF8String], 1);
-          if (!getenv ("EMACSDOC"))
-            setenv ("EMACSDOC", [resourcePath UTF8String], 1);
-        }
-    }
 }
 
 static void
@@ -3848,9 +3857,9 @@ ns_default (const char *parameter, Lisp_Object *result,
     {
       double f;
       char *pos;
-      if (strcasecmp (value, "YES") == 0)
+      if (c_strcasecmp (value, "YES") == 0)
         *result = yesval;
-      else if (strcasecmp (value, "NO") == 0)
+      else if (c_strcasecmp (value, "NO") == 0)
         *result = noval;
       else if (is_float && (f = strtod (value, &pos), pos != value))
         *result = make_float (f);