9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Spaces in values in plan9.ini?
@ 2001-04-16 18:45 rob pike
  2001-04-16 20:01 ` Boyd Roberts
  2001-04-17  0:34 ` Dan Cross
  0 siblings, 2 replies; 4+ messages in thread
From: rob pike @ 2001-04-16 18:45 UTC (permalink / raw)
  To: 9fans

That sort of thing was precisely the reason for the change
to tokenize.  Please try it, see if it works, and tell us the
result. Thanks.

-rob



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] Spaces in values in plan9.ini?
  2001-04-16 18:45 [9fans] Spaces in values in plan9.ini? rob pike
@ 2001-04-16 20:01 ` Boyd Roberts
  2001-04-17  0:34 ` Dan Cross
  1 sibling, 0 replies; 4+ messages in thread
From: Boyd Roberts @ 2001-04-16 20:01 UTC (permalink / raw)
  To: 9fans

From: "rob pike" <rob@plan9.bell-labs.com>
> That sort of thing was precisely the reason for the change
> to tokenize.  Please try it, see if it works, and tell us the
> result. Thanks.

yeah, a long while i had to write a DLL that looked like WinSock 1.1
and then called winsock to talk SOCKS 4 transparently;  so no
need for proxy configs.  it had a 'routing' table to find socks
servers, but then it needed an .ini file.

is it GetProfileString() and all that crap that reads those
things (it's been a while)?

anyway, even though it was only read once, i was told to re-write
the code so the DLL would start more quickly.  trouble was, the
.ini files were not _really_ documented so i just had to make
it up as i went along.

all sorts of horrible sections, white space, quoting etc...

i woulda stuck with GetProfileDebacle() 'cos at least it knew
the format, but i was a contractor and was told to break it.
one of the reasons for the .ini file IIRC was that you could up
read/write buffer sizes to > 16kb [windows 3] and at that point
netscape would crash, so the .ini file specfied in what chunks
to splits 'large' i/o's up into -- puke.

nasty.

i needed a job here, they forced me to code on windows 3, '95 and NT.

ain't CreateProcess() a beauty?  thanks Dave Cutler.

--
Boyd Roberts        http://www.insultant.net        boyd@insultant.net

Rule 1: Whenever there is any doubt, there is no doubt.
Rule 2: I don't remember.
Rule 3: Take the hit and drive on.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] Spaces in values in plan9.ini?
  2001-04-16 18:45 [9fans] Spaces in values in plan9.ini? rob pike
  2001-04-16 20:01 ` Boyd Roberts
@ 2001-04-17  0:34 ` Dan Cross
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Cross @ 2001-04-17  0:34 UTC (permalink / raw)
  To: 9fans

In article <20010416184538.3F48719A0A@mail.cse.psu.edu> you write:
>That sort of thing was precisely the reason for the change
>to tokenize.  Please try it, see if it works, and tell us the
>result. Thanks.

Okay, I changed it, and it seems to be working fine.  However, the
change to parsecmd() was only part of the fix; the other part was
modifying isaconfig() in the couple of places it appears to deal
with quoted strings in plan9.ini.  I did a hack job of fixing that,
allowing simple quoted strings by introducing a flag variable into
isaconfig(), but it doesn't deal with nested or quoted quotes.

Note that one has to preserve the quotes when passing data from
plan9.ini, otherwise tokenize() in parsecmd() won't get what it's
expecting.

I suppose the real fix would be to abstract the parsing of plan9.ini
into a library.

Anyway, diff's follow.  I don't think I missed anything I changed.

	- Dan C.

diff /sys/src/9/port/lib.h 9/port/lib.h
82a83
> extern	int	tokenize(char *, char**, int);
diff /sys/src/9/port/parse.c 9/port/parse.c
24c24
< 	cb->nf = getfields(cb->buf, cb->f, nelem(cb->f), 1, " ");
---
> 	cb->nf = tokenize(cb->buf, cb->f, nelem(cb->f));
diff /sys/src/9/pc/main.c 9/pc/main.c
646c646
< 	int n;
---
> 	int n, inquote;
682c682,686
< 				while(*p && *p != ' ' && *p != '\t'){
---
> 				inquote = 0;
> 				while(*p && (inquote || (*p != ' ' && *p != '\t'))){
> 					if (*p == '\'') {
> 						inquote = (inquote != 0) ? 0 : 1;
> 					}
diff /sys/src/boot/pc/conf.c boot/pc/conf.c
480c480
< 	int n;
---
> 	int n, inquote;
516c516,520
< 				while(*p && *p != ' ' && *p != '\t'){
---
> 				inquote = 0;
> 				while(*p && (inquote || (*p != ' ' && *p != '\t'))){
> 					if (*p == '\'') {
> 						inquote = (inquote != 0) ? 0 : 1;
> 					}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [9fans] Spaces in values in plan9.ini?
@ 2001-04-16 18:43 Dan Cross
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Cross @ 2001-04-16 18:43 UTC (permalink / raw)
  To: 9fans

It appears as though bozo's who set up our office Wavelan
(ne ``Orinoco Enterprise'') network put a space into the
wavelan network name....  Boo....  The Plan 9 Wavelan driver
uses the parsecmd() routine in /sys/src/9/port/parse.c to
parse option strings writen to the driver's ctl file, but
parsecmd() calls getfields() which can't deal with quoted
strings that contain spaces.  So, if our wavelan name is
`Dumb IT People', the driver thinks that it's 'Dumb.  (Note
the quote....).

My question is: is it safe to change the call to getfields(2)
in /sys/src/9/port/parse.c to a call to tokenize(2) instead?
This would allow one to quote strings with embedded spaces.
It would also deal with tabs (getfields in parsecmd() is called
with a space only as the field delimiter).

	- Dan C.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-04-17  0:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-16 18:45 [9fans] Spaces in values in plan9.ini? rob pike
2001-04-16 20:01 ` Boyd Roberts
2001-04-17  0:34 ` Dan Cross
  -- strict thread matches above, loose matches on Subject: below --
2001-04-16 18:43 Dan Cross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).