patchGNUstep - Patches: patch #4415, base: mingw unicode filesystemRep

Group
 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #4415: base: mingw unicode filesystemRep

Submitter:  Jeremy Bettis <jeremybettis>
Submitted:  Tue 13 Sep 2005 06:38:25 PM UTC
   
 
Category:  Foundation Priority:  5 - Normal
Status:  Wont Do Privacy:  Public
Assigned to:  None Open/Closed:  Closed

Sun 23 Oct 2005 02:58:29 PM UTC, comment #3: 

Quite right ... the header file should have told users about windows behavior.  Unfortunately, while it got added to the documentation for the method in NSFileManager, it got missed from NSString.  I've added the appropriate documentation.
Really, the methods should use void* as the actual type of data is theoretically dependent on the filesystem being used, but the OpenStep spec and MacOS-X use char*

Richard Frith-Macdonald <CaS>
Group Member
Sun 23 Oct 2005 02:17:38 PM UTC, comment #2: 

I think it would be safer to tell the world that win32 works differently in the header file.  For example, the change to filesystemRepresentation broke my code, and I didn't even know it.  I updated by gnustep-base library to a new version, and didn't get a compiler warning or anything, but filesystemRepresentation only returned the first character of the string. (From my perspective interpreting it as a char*)

The current functionally is flat out dangerous.  Either return a char* or change the header to what you will actually return.  You can't expect every user of -[NSString filesystemRepresentation] to read the source code of gstep-base.

Jeremy Bettis <jeremybettis>
Sun 23 Oct 2005 08:16:42 AM UTC, comment #1: 

Some of what this patch does is already in place ... the part that isn't is the change to the API.
I don't think I want to change the formal return type declared for filesystemRepresentation to say that it's (const unichar*) rather than (const char*) on mingw, as I think it's probably better to use a cast in the code, making it clearer to anyone reading application code that windows and the rest of the world behave differently.

Richard Frith-Macdonald <CaS>
Group Member
Tue 13 Sep 2005 06:38:25 PM UTC, original submission:  

The filesystemRepresentation returns unicode, but doesn't declare the function that way.  This patch resolvs that and fixes some usages that were treating it as a char*.

Index: Headers/Foundation/NSFileManager.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Foundation/NSFileManager.h,v
retrieving revision 1.6
diff -u -r1.6 NSFileManager.h
--- Headers/Foundation/NSFileManager.h 4 Jun 2005 07:22:50 -0000 1.6
+++ Headers/Foundation/NSFileManager.h 27 Jul 2005 18:08:46 -0000
@@ -216,7 +216,11 @@
 - (BOOL) fileExistsAtPath: (NSString*)path;
 - (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
 - (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
+#ifdef _MINGW_
+- (const unichar*) fileSystemRepresentationWithPath: (NSString*)path;
+#else
 - (const char*) fileSystemRepresentationWithPath: (NSString*)path;
+#endif
 #ifndef NO_GNUSTEP
 - (NSString*) localFromOpenStepPath:(NSString*)path;
 - (NSString*) openStepPathFromLocal:(NSString*)localPath;
Index: Headers/Foundation/NSString.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Foundation/NSString.h,v
retrieving revision 1.22
diff -u -r1.22 NSString.h
--- Headers/Foundation/NSString.h 4 Jun 2005 10:55:38 -0000 1.22
+++ Headers/Foundation/NSString.h 27 Jul 2005 18:04:30 -0000
@@ -355,7 +355,11 @@
  * automatically freed soon after it is returned, so copy it if you need it
  * for long.
  */
+#ifdef _MINGW_
+- (const unichar*) fileSystemRepresentation;
+#else
 - (const char*) fileSystemRepresentation;
+#endif
 
 /**
  * Converts the receiver to a C string path using the character encoding
Index: Source/NSPathUtilities.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSPathUtilities.m,v
retrieving revision 1.13
diff -u -r1.13 NSPathUtilities.m
--- Source/NSPathUtilities.m 31 Jul 2005 08:18:19 -0000 1.13
+++ Source/NSPathUtilities.m 1 Aug 2005 15:07:37 -0000
@@ -350,7 +350,7 @@
       dict = GSReadStepConfFile(steprcFile);
       if (dict != nil)
  {
-   PrintOnce("Warning: Configuration: The file %s has been "
+   PrintOnce("Warning: Configuration: The file %S has been "
      "deprecated.  Please use the configuration file %s to "
      "set standard paths.\n",
      [steprcFile fileSystemRepresentation],
@@ -627,13 +627,14 @@
     }
 
   attributes = [MGR() fileAttributesAtPath: fileName traverseLink: YES];
+#if !defined(_MINGW_)
   if (([attributes filePosixPermissions] & 022) != 0)
     {
-      fprintf(stderr, "The file '%s' is writable by someone other than"
+      fprintf(stderr, "The file '%S' is writable by someone other than"
  " its owner.\nIgnoring it.\n", [fileName fileSystemRepresentation]);
       return nil;
     }
-
+#endif
   dict = [NSMutableDictionary dictionaryWithCapacity: 16];
   if (dict == nil)
     {

Jeremy Bettis <jeremybettis>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-10-23 CaS StatusNone Wont Do
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-4448.
Corresponding source code