C coding tips please / Localisation

Wayne Davison wayned at samba.org
Sun Jul 12 18:07:22 UTC 2015


On Fri, Jul 10, 2015 at 5:57 PM Michael <cuscotravelservices at gmail.com>
wrote:

> However, given the warning messages I saw, maybe this is not the
> correct (elegant and most efficient) way for the secondary files to
> reference "libintl.h".
>
The best place to add that include and the gettext define would be to put
them in rsync.h somewhere, which would make the localisation idiom
available in all the .c files.  Putting it down at the bottom of the file
would be a reasonable spot for it.

Are "extern" variables always declared before other variables?
>
No, they can be declared anywhere before they get used.  Rsync just has a
particular top-of-file style for them.

What is the purpose of "#define"?
>
It's just a simple search-and-replace mechanism that allows macro
definitions in C files.  It is sometimes used for inline "functions" and
sometimes for global constants (they existed long before "const" vars).

I think your idea of adding localisation to rsync is reasonable, though
hasn't been that popular of a topic since the translatable messages that it
outputs are fairly limited.  I think for the official release that I'd make
it a configure option so that folks can choose to include it or not, as
they see fit.

For your localisation efforts, I'd recommend that you either make a "git
clone" of the source and change that since that makes it easy to diff your
changes and make a patch file with the end results of what you've done. You
could also just keep an unchanged version in a directory and use "diff -ru"
on the old and new directory hierarchies should you not want to learn to
use git.

..wayne..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20150712/432bbd04/attachment.html>


More information about the rsync mailing list