diff --git a/Source/Makefile.in b/Source/Makefile.in index 2d07b7340..2d543ea3f 100644 --- a/Source/Makefile.in +++ b/Source/Makefile.in @@ -174,6 +174,7 @@ Time.m \ UdpPort.m \ behavior.m \ lex.pl.m \ +lex.sf.m \ ostream.m \ o_array.m \ o_array_bas.m \ @@ -195,6 +196,7 @@ o_map_bas.m \ o_map_cbs.m \ preface.m \ proplist.tab.m \ +stringsfile.tab.m \ mframe.m \ objc-gnu2next.m @@ -212,6 +214,9 @@ md5.h \ proplist.l \ proplist.tab.h \ proplist.y \ +stringsfile.l \ +stringsfile.tab.h \ +stringsfile.y \ win32-entry.c \ win32-def.top @@ -588,6 +593,13 @@ proplist.tab.m proplist.tab.h: proplist.y lex.pl.m: proplist.l proplist.tab.h $(LEX) -t -B -Ppl proplist.l > $@ +stringsfile.tab.m stringsfile.tab.h: stringsfile.y + rm -f stringsfile.tab.m.h + $(YACC) -d -p sf stringsfile.y -o stringsfile.tab.m + mv stringsfile.tab.m.h stringsfile.tab.h +lex.sf.m: stringsfile.l stringsfile.tab.h + $(LEX) -t -B -Psf stringsfile.l > $@ + objc-load${OEXT}: dynamic-load.h dynamic-load.h: ../config.status diff --git a/Source/NSString.m b/Source/NSString.m index 327332587..a2d48f491 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -48,12 +48,19 @@ #include #include #include +#include #include #include #include #include #include #include // for strstr() +#include +#include +#include +#include +#include + @implementation NSString @@ -289,8 +296,21 @@ handle_printf_atsign (FILE *stream, - (id) initWithContentsOfFile: (NSString*)path { - [self notImplemented:_cmd]; - return self; + struct stat buf; + int fd; + char *s; + + stat([path cString], &buf); + + OBJC_MALLOC(s,char,buf.st_size + 1); + fd = open([path cString], O_RDONLY); + if ( fd < 0 ) + [NSException raise: NSGenericException format: @"Could not open file %s", [path cString]]; + + read(fd,(void *)s,buf.st_size); + s[buf.st_size] = (char)0; + + return [self initWithCStringNoCopy:s length: buf.st_size freeWhenDone:YES]; } - (id) initWithData: (NSData*)data @@ -1038,8 +1058,14 @@ handle_printf_atsign (FILE *stream, - (NSDictionary*) propertyListFromStringsFileFormat { - [self notImplemented:_cmd]; - return nil; + id dict = [[[NSMutableDictionary alloc] init] autorelease]; + void *bufstate; + + bufstate = (void *)sf_scan_string([self cString]); + sfSetDict(dict); + sfparse(dict); + sf_delete_buffer(bufstate); + return dict; }