FROM : Philip George
DATE : Sat Nov 16 20:43:01 2002
Simone,
I had the same problem (except in reverse) with a piece of software=20
that I wrote before the release of Jaguar. As soon as Jaguar was=20
released, my parsing algorithm broke. Come to find out it was just=20
that ifconfig (the command whose output I was parsing) got a little=20
upgrade and one of the things that they changed was the format of the=20
output. So some of the little textual "landmarks" that my algorithm=20
was looking for were gone or placed elsewhere in the output, totally=20
ruining my parser.
This may not be the case for you, but sometimes we, as programmers,=20
tend to overlook the simplest explanations for things.
Run the same command with the same args in Terminal.app on a Jag=20
installation and on a 10.1.x installation and compare the output. It=20
may be slightly or even totally different, which would certainly=20
explain why your parser is having problems.
If anyone has any other NSScanner-related ideas, please don't let me=20
kill this thread with my non-NSScanner-explanation. It was just a=20
thought.
:)
- Philip
On Saturday, November 16, 2002, at 10:18 PM, Simone Manganelli wrote:
> Hey everyone --
>
> I'm still having problems with an NSScanner class on Mac OS X 10.1.x.
>
> As I said before, my application uses an NSScanner class to parse some=20=
> command line output
> into data that gets put into a table view. On Mac OS X 10.2 Jaguar, =
my
> application works as expected. However, under Mac OS X 10.1.x, any=20
> data
> that got parsed via an NSScanner class does not display correctly in=20=
> the
> NSTableView =96 it displays the wrong parts of the strings that should
> have been parsed. However, data that was parsed simply via the=20
> NSString
> methods do not exhibit this problem under Mac OS X 10.1.x. Only
> NSScanner parsed data has this problem.
>
> Is there any way to fix this problem and make my application work =
under
> both operating systems? Any help would be greatly appreciated. If
> there's another way to accomplish what NSScanner does, that would be
> acceptable too, as long as it works under both Mac OS X 10.1.x and
> 10.2.x Jaguar.
>
> Here's the code that I am using to parse the output of the command=20
> line:
>
> // sets the full command of the process
> - (void)setFullProcessName:(NSString *)n;
> {
> NSScanner *scanner;
> NSString *tempString =3D nil;
> [n retain];
> [fullProcessName release];
> fullProcessName =3D n;
> // inits the scanner with the last part of the full command of the=20=
> process
> scanner =3D [[NSScanner alloc] initWithString:[[fullProcessName=20
> componentsSeparatedByString:@"/"] lastObject]];
> [scanner setCaseSensitive:YES];
> [scanner scanUpToString:@"console" intoString:&tempString];
> // checks if the word "console" appears =96 if it doesn't, =
searches=20
> for "psn"
> if ([[[fullProcessName componentsSeparatedByString:@"/"]=20
> lastObject] isEqualToString:tempString]) {
> [scanner setScanLocation:0];
> [scanner scanUpToString:@"-psn" intoString:&tempString];
> } else if (![tempString length]) {
> tempString =3D [[fullProcessName=20
> componentsSeparatedByString:@"/"] lastObject];
> } else {
> [scanner scanString:@"console" intoString:NULL];
> }
> // sets the process name
> [self setProcessName:tempString];
> [scanner release];
> }
>
> Thanks for any help that people can give.
>
> -- Simone Manganelli
>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
DATE : Sat Nov 16 20:43:01 2002
Simone,
I had the same problem (except in reverse) with a piece of software=20
that I wrote before the release of Jaguar. As soon as Jaguar was=20
released, my parsing algorithm broke. Come to find out it was just=20
that ifconfig (the command whose output I was parsing) got a little=20
upgrade and one of the things that they changed was the format of the=20
output. So some of the little textual "landmarks" that my algorithm=20
was looking for were gone or placed elsewhere in the output, totally=20
ruining my parser.
This may not be the case for you, but sometimes we, as programmers,=20
tend to overlook the simplest explanations for things.
Run the same command with the same args in Terminal.app on a Jag=20
installation and on a 10.1.x installation and compare the output. It=20
may be slightly or even totally different, which would certainly=20
explain why your parser is having problems.
If anyone has any other NSScanner-related ideas, please don't let me=20
kill this thread with my non-NSScanner-explanation. It was just a=20
thought.
:)
- Philip
On Saturday, November 16, 2002, at 10:18 PM, Simone Manganelli wrote:
> Hey everyone --
>
> I'm still having problems with an NSScanner class on Mac OS X 10.1.x.
>
> As I said before, my application uses an NSScanner class to parse some=20=
> command line output
> into data that gets put into a table view. On Mac OS X 10.2 Jaguar, =
my
> application works as expected. However, under Mac OS X 10.1.x, any=20
> data
> that got parsed via an NSScanner class does not display correctly in=20=
> the
> NSTableView =96 it displays the wrong parts of the strings that should
> have been parsed. However, data that was parsed simply via the=20
> NSString
> methods do not exhibit this problem under Mac OS X 10.1.x. Only
> NSScanner parsed data has this problem.
>
> Is there any way to fix this problem and make my application work =
under
> both operating systems? Any help would be greatly appreciated. If
> there's another way to accomplish what NSScanner does, that would be
> acceptable too, as long as it works under both Mac OS X 10.1.x and
> 10.2.x Jaguar.
>
> Here's the code that I am using to parse the output of the command=20
> line:
>
> // sets the full command of the process
> - (void)setFullProcessName:(NSString *)n;
> {
> NSScanner *scanner;
> NSString *tempString =3D nil;
> [n retain];
> [fullProcessName release];
> fullProcessName =3D n;
> // inits the scanner with the last part of the full command of the=20=
> process
> scanner =3D [[NSScanner alloc] initWithString:[[fullProcessName=20
> componentsSeparatedByString:@"/"] lastObject]];
> [scanner setCaseSensitive:YES];
> [scanner scanUpToString:@"console" intoString:&tempString];
> // checks if the word "console" appears =96 if it doesn't, =
searches=20
> for "psn"
> if ([[[fullProcessName componentsSeparatedByString:@"/"]=20
> lastObject] isEqualToString:tempString]) {
> [scanner setScanLocation:0];
> [scanner scanUpToString:@"-psn" intoString:&tempString];
> } else if (![tempString length]) {
> tempString =3D [[fullProcessName=20
> componentsSeparatedByString:@"/"] lastObject];
> } else {
> [scanner scanString:@"console" intoString:NULL];
> }
> // sets the process name
> [self setProcessName:tempString];
> [scanner release];
> }
>
> Thanks for any help that people can give.
>
> -- Simone Manganelli
>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
>
| Related mails | Author | Date |
|---|---|---|
| Simone Manganelli | Nov 16, 20:19 | |
| Philip George | Nov 16, 20:43 | |
| Philip George | Nov 16, 21:12 | |
| Simone Manganelli | Nov 16, 22:45 |






Cocoa mail archive

