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

Re: hzoli change: $foo:s//r/



Wayne Davison wrote:
> 
> If you wish to initialize globals in a file that is used to either
> declare or define, I find the following syntax more readable:
> 
> --------------------------------------------------------
> #ifdef GLOBALS
> # define EXTERN
> # define INIT(x) = x
> #else
> # define EXTERN extern
> # define INIT(x)
> #endif
> 
> [...]
> 
> /* the last l for s/l/r/ history substitution */
> 
> EXTERN char *hsubl INIT(NULL);
> 
> /* the last r for s/l/r/ history substitution */
> 
> EXTERN char *hsubr INIT(NULL);
> --------------------------------------------------------
> 
> This can be used for any type variable and could simplify a few
> of the other #ifdef GLOBALS initializations in the file.

Yes, it is really a good idea.  But if it is really guaranteed that externs
are initialized to zere therese initializations are unnecessary.  The fact
that zsh worked so far shows that it is quite safe to assume that global
variables are initialized to zero, but what is in the ANSI-C standard?

Zoltan



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