mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
OSX compatibility fixes for zero width space character and initialising an NSURL
with bad strings.
This commit is contained in:
parent
0e12e226c9
commit
7045f84acc
21 changed files with 31196 additions and 30499 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
2018-01-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* NSCharacterSets/GNUmakefile:
|
||||||
|
* NSCharacterSets/alphanumericCharSet.dat:
|
||||||
|
* NSCharacterSets/controlCharSet.dat:
|
||||||
|
* NSCharacterSets/dataToHeader.c:
|
||||||
|
* NSCharacterSets/decimalDigitCharSet.dat:
|
||||||
|
* NSCharacterSets/decomposableCharSet.dat:
|
||||||
|
* NSCharacterSets/illegalCharSet.dat:
|
||||||
|
* NSCharacterSets/letterCharSet.dat:
|
||||||
|
* NSCharacterSets/lowercaseLetterCharSet.dat:
|
||||||
|
* NSCharacterSets/newlineCharSet.dat:
|
||||||
|
* NSCharacterSets/nonBaseCharSet.dat:
|
||||||
|
* NSCharacterSets/punctuationCharSet.dat:
|
||||||
|
* NSCharacterSets/symbolAndOperatorCharSet.dat:
|
||||||
|
* NSCharacterSets/uppercaseLetterCharSet.dat:
|
||||||
|
* NSCharacterSets/whitespaceAndNlCharSet.dat:
|
||||||
|
* NSCharacterSets/whitespaceCharSet.dat:
|
||||||
|
Obsolete files deleted.
|
||||||
|
* NSCharacterSets/README.CharSet: updated
|
||||||
|
* Source/NSCharacterSetData.h: regenerated using the ucsdata library
|
||||||
|
and the charsets tools to take into account the fact that a unicode
|
||||||
|
zero width space should be counted as white space by us.
|
||||||
|
* Source/NSURL.m: A few OSX compatibility tweaks.
|
||||||
|
* Tests/base/NSURL/basic.m: A couple more OSX compatibility tests.
|
||||||
|
|
||||||
2018-01-25 Richard Frith-Macdonald <rfm@gnu.org>
|
2018-01-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Foundation/NSException.h:
|
* Headers/Foundation/NSException.h:
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
#
|
|
||||||
# NSCharacterSet makefile for GNUstep Base Library
|
|
||||||
# Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
|
||||||
#
|
|
||||||
# This file is part of the GNUstep Base Library.
|
|
||||||
#
|
|
||||||
# This library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This library is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# Library General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
|
||||||
# License along with this library; if not, write to the Free
|
|
||||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
# Boston, MA 02111 USA.
|
|
||||||
|
|
||||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
|
||||||
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
|
|
||||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
|
||||||
$(warning )
|
|
||||||
$(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!)
|
|
||||||
$(warning Perhaps gnustep-make is not properly installed,)
|
|
||||||
$(warning so gnustep-config is not in your PATH.)
|
|
||||||
$(warning )
|
|
||||||
$(warning Your PATH is currently $(PATH))
|
|
||||||
$(warning )
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
|
||||||
$(error You need to set GNUSTEP_MAKEFILES before compiling!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
PACKAGE_NAME = gnustep-base
|
|
||||||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/common.make
|
|
||||||
-include ../config.mak
|
|
||||||
|
|
||||||
CHARSET_FILES = \
|
|
||||||
alphanumericCharSet.dat \
|
|
||||||
controlCharSet.dat \
|
|
||||||
decimalDigitCharSet.dat \
|
|
||||||
decomposableCharSet.dat \
|
|
||||||
illegalCharSet.dat \
|
|
||||||
letterCharSet.dat \
|
|
||||||
lowercaseLetterCharSet.dat \
|
|
||||||
nonBaseCharSet.dat \
|
|
||||||
punctuationCharSet.dat \
|
|
||||||
symbolAndOperatorCharSet.dat \
|
|
||||||
uppercaseLetterCharSet.dat \
|
|
||||||
whitespaceAndNlCharSet.dat \
|
|
||||||
whitespaceCharSet.dat
|
|
||||||
|
|
||||||
CTOOL_NAME = dataToHeader
|
|
||||||
dataToHeader_C_FILES = dataToHeader.c
|
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/ctool.make
|
|
||||||
|
|
||||||
after-all:: NSCharacterSetData.h
|
|
||||||
|
|
||||||
NSCharacterSetData.h: $(CHARSET_FILES)
|
|
||||||
$(GNUSTEP_OBJ_DIR_NAME)/dataToHeader $(CHARSET_FILES)
|
|
||||||
|
|
|
@ -5,21 +5,3 @@
|
||||||
using the tools in tools/charsets and the library in libs/ucsdata
|
using the tools in tools/charsets and the library in libs/ucsdata
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
|
||||||
This files in this directory are CharacterSet bitmaps which contain
|
|
||||||
a bitmap representation of the Unicode characters in the respective
|
|
||||||
character sets.
|
|
||||||
|
|
||||||
These file were generated automatically from the the latest version
|
|
||||||
of the Unicode character set as of Feb. 27, 2001. The Unicode character
|
|
||||||
set can be obtained from http://www.unicode.org
|
|
||||||
|
|
||||||
The binary data files are no longer used at runtime.
|
|
||||||
|
|
||||||
The current character sets are based on UnicodeData.txt version 3.0.1.
|
|
||||||
|
|
||||||
NOTE: There are a number of differences between these sets and the
|
|
||||||
sets provided by NeXT in their OPENSTEP system. The Unicode Consortium
|
|
||||||
has added thousands of characters, and changed the classification for
|
|
||||||
many of them, since the version of the Unicode standard used by NeXT.
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* A trivial C program to read characterset data files and produce a C
|
|
||||||
* header file to be included into NSCharacterSet.m
|
|
||||||
* Pass it the names of the data files as arguments.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int c;
|
|
||||||
FILE *o;
|
|
||||||
|
|
||||||
if (argc < 2)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Expecting names of data files to convert\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
o = fopen("NSCharacterSetData.h", "w");
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
char name[BUFSIZ];
|
|
||||||
int j;
|
|
||||||
int sep = '{';
|
|
||||||
|
|
||||||
strcpy(name, argv[i]);
|
|
||||||
j = strlen(name) - 4;
|
|
||||||
if (j < 0 || strcmp(&name[j], ".dat") != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Bad file name '%s'\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
f = fopen(name, "r");
|
|
||||||
if (f == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Unable to read '%s'\n", name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
name[j] = '\0';
|
|
||||||
fprintf(o, "static unsigned char %s[8192] = ", name);
|
|
||||||
while ((c = fgetc(f)) != EOF)
|
|
||||||
{
|
|
||||||
fprintf(o, "%c\n'\\x%02x'", sep, c);
|
|
||||||
sep = ',';
|
|
||||||
}
|
|
||||||
fprintf(o,"};\n");
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
fclose(o);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -811,6 +811,11 @@ static NSUInteger urlAlign;
|
||||||
*/
|
*/
|
||||||
static const char *filepath = ";/?:@&=+$,[]#";
|
static const char *filepath = ";/?:@&=+$,[]#";
|
||||||
|
|
||||||
|
if (nil == aUrlString)
|
||||||
|
{
|
||||||
|
RELEASE(self);
|
||||||
|
return nil; // OSX behavior is to give up.
|
||||||
|
}
|
||||||
if ([aUrlString isKindOfClass: [NSString class]] == NO)
|
if ([aUrlString isKindOfClass: [NSString class]] == NO)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
@ -843,9 +848,20 @@ static NSUInteger urlAlign;
|
||||||
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
|
||||||
memset(buf, '\0', size);
|
memset(buf, '\0', size);
|
||||||
start = end = ptr = (char*)&buf[1];
|
start = end = ptr = (char*)&buf[1];
|
||||||
[_urlString getCString: start
|
NS_DURING
|
||||||
maxLength: size
|
{
|
||||||
encoding: NSASCIIStringEncoding];
|
[_urlString getCString: start
|
||||||
|
maxLength: size
|
||||||
|
encoding: NSASCIIStringEncoding];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
/* OSX behavior when given non-ascii text is to return nil.
|
||||||
|
*/
|
||||||
|
RELEASE(self);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the scheme if possible.
|
* Parse the scheme if possible.
|
||||||
|
|
|
@ -15,6 +15,8 @@ int main()
|
||||||
NSString *str;
|
NSString *str;
|
||||||
NSNumber *num;
|
NSNumber *num;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
unichar bad[] = {'h', 't', 't', 'p', ':', '/', '/', 'w', 'w', 'w',
|
||||||
|
'.', 'w', '3', '.', 'o', 'r', 'g', '/', 0x200B};
|
||||||
unichar u = 163;
|
unichar u = 163;
|
||||||
unichar buf[256];
|
unichar buf[256];
|
||||||
|
|
||||||
|
@ -27,6 +29,10 @@ int main()
|
||||||
TEST_FOR_CLASS(@"NSURL", [NSURL URLWithString: @"http://www.w3.org/"],
|
TEST_FOR_CLASS(@"NSURL", [NSURL URLWithString: @"http://www.w3.org/"],
|
||||||
"NSURL +URLWithString: returns an NSURL");
|
"NSURL +URLWithString: returns an NSURL");
|
||||||
|
|
||||||
|
str = [NSString stringWithCharacters: bad length: sizeof(bad)/sizeof(*bad)];
|
||||||
|
url = [NSURL URLWithString: str];
|
||||||
|
PASS(nil == url, "Bad characters result in nil");
|
||||||
|
|
||||||
str = [NSString stringWithCharacters: &u length: 1];
|
str = [NSString stringWithCharacters: &u length: 1];
|
||||||
url = [NSURL fileURLWithPath: str];
|
url = [NSURL fileURLWithPath: str];
|
||||||
str = [[[NSFileManager defaultManager] currentDirectoryPath]
|
str = [[[NSFileManager defaultManager] currentDirectoryPath]
|
||||||
|
|
Loading…
Reference in a new issue