Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: pws-19: associative array interface to files



This is why I was looking at the parameter module so closely:  it's an
associative array interface to files, just so that Bart can do `vared
mapfile[foo]' to edit the file foo.  All the finnicky parameter details are
simply copied from parameter.c, which is why Sven is in the copyright as
co-author.  See the manual page for more details of how to use this (the
interface is open to possible criticism).

I implemented I/O in what should be an efficient way by using mmap() if
available (and provided all the other bits I need for my way of doing
things, munmap(), msync(), ftruncate(), <sys/mman.h> are there, too): note
that so far I've only tried this on AIX, whose memory management is a bit
sui generis, so it's possible the mmap() stuff is going to fail on other
systems.  However, I hope that in convering AIX I've covered pretty much
what the OS writers can throw at it.  You can #undef USE_MMAP to compile if
you need to to try it out.

Unfortunately, zsh's internal memory management is anything but efficient.
For example, if you vared a file this way, the file is read twice: once for
use by the editor, then again when vared retrieves the modified struct pm
to write to it; there's currently no way mapfile can know that the value
it's making is not going to be used, nor can it know when it will be called
next, so there's no way of caching the value.  Also, the file can
potentially be copied any number of times by the handling in paramsubst(),
though in general we can't really do a lot about this.  I have a number of
remarks and questions on parameter and related memory and efficiency
issues, which I'll post separately (not today).

A separate issue is the zmodload interface: I'd quite like it to change
things so that you can pass arguments to the module you're loading to
configure it, so that for example you can call the variable something other
than mapfile.  That's only a half-way street anyway, since you can't use
multiple file mapping variables which would need some other interface to
the module to arrange, probably beyond the scope of zmodload.  But it might
be useful anyway, although it's not that important.  Does anybody use
zmodload with multiple library arguments?  It could be made to require a
flag.

begin 644 mapfile.dif.gz
M'XL("`?(1C<``VUA<&9I;&4N9&EF`)U;^W?;-I8^^Z/U5Z">.0D5R8KMQ$YC
MUYUJ;*?V63]R++O93K?'0Y&@Q`E?0Y!6E*;[M^]W+P`^)-I-QV<F(@%<X.(^
MOPNB6UM;XB3U7OY#S5_&J7\?A)%4HV4ZBH.-B5N(2W<I=G?%SO[![JN#5_MB
MY^W;M[W!8-!)M$KQ^F![6U/\\(/8VAF^%@/ZYX<?>EN%_!0FJ2^=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<G=Q>D*JZBQW>3)
M?38.S2OV]3EG]S<+XC7D*W6J",T'-;J%N[H=IY4B+="O#ET=V](Z3>Z;$RBB
M;59F?9-T*R\]$O_7\--#KDOMP3[&.V05V^1+;:-X0JE!F(1J_B<,PE0*CUUW
MB7V_^\++MT]?>`'=Q@>Z8D1WRM[2';$]NB:V?N6%+[S0/5;>M#JJ/O00<^GT
M7W"YNG&4;E:<T@5*?1NGN<[.P>[NP<YVFSD]=.7.VMZ;@]W&?TNQ^^HU77(:
MF%^Z[`03XFBA@2$%"',UC>^8%N:2*1F,H,'XW3(IT<+1WJ!Z:D),/A)(="+\
M-RINF`5#]`K%0DF'O%%$IR"<E;E$K;MZ@?+U`7:[U]AJ<_#J!;VWU55+OJ"W
MSWO5/[15%%,%W=))U6@NZ",K:\,\0_)A2L\,^?!@0M]<_"]3\@4$(@R\I(CP
M&X53S]"6A>+_8D._Y5*E9>[)FI0^#=&KS/-$K^&#&@\E[+CP#9WG9N;.`E-N
M@;(LXHR&X>>3&54L,TEL9`NBF^74GZ41.*(`]"=)1/VIF>X)!GQ;7?S57V([
MT/"16)K_,B0AW8V/[X_/3H__F\JED].;B>-'$`:3=G92#RGBS?8^*4+_D"+:
M?RJ<97GJQ:[Z2#"E#'WZD>8WKQ^4>5+T@W>ZXTPB;O]!I/<1V1>"1#&CBQ4*
M.IL3GH*$[PE^TG)LJGQZE]"=)=*4IL>`63[#$OQ`69]*E06A!WZH6@PW&03*
MZM+D@4(5E8J@D*@S+*I=:>9#85O'\@FVJ`YQ^^1G?A*)K?:?;F01BW=W5\>W
/Y]=7D][_`Y7OZLLF-P``
`
end
-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author