Re: [PATCH] Fix git to be (more) ANSI C99 compliant.
- From
- Timo Hirvonen <tihirvon@gmail.com>
- Date
- Jun 18, 2006, 08:07 UTC
- Message-ID
- <20060618110749.e6fb9030.tihirvon@gmail.com>
- In-Reply-To
- <1150609831500-git-send-email-octo@verplant.org>
Florian Forster <octo@verplant.org> wrote:
Show 7 quoted lines
> Using this patch I was able to build git with > $ make CFLAGS="-Wall -Werror -ansi -pedantic -std=c99 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE" > > While most of this patch fixes void-pointer arithmetic and is therefore > trivial, I had to change the use of a struct with FAMs in `diff-lib.c'. Since > this is the first time I encountered FAMs it'd probably be a good idea if > someone who knows would take a look at that.
Many of the void-pointer arithmetic warnings could be fixed by changing the variable types to char * instead of casting them in many places.
Show 10 quoted lines
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -34,21 +34,23 @@ int run_diff_files(struct rev_info *revs
> continue;
>
> if (ce_stage(ce)) {
> - struct {
> - struct combine_diff_path p;
> - struct combine_diff_parent filler[5];
> - } combine;Yes this is somewhat ugly but avoids a malloc. You could use alloca but the man-page says:
"The alloca() function is machine and compiler dependent. On many systems
its implementation is buggy. Its use is discouraged."Leave the code as it is now unless it causes real problems.
Show 11 quoted lines
> static inline int needs_quote(int ch)
> {
> - switch (ch) {
> - case '/': case '-': case '.':
> - case 'A'...'Z': case 'a'...'z': case '0'...'9':
> + if (((ch >= 'A') && (ch <= 'Z'))
> + || ((ch >= 'a') && (ch <= 'z'))
> + || ((ch >= '0') && (ch <= '9'))
> + || (ch == '/')
> + || (ch == '-')
> + || (ch == '.'))'A'...'Z' is more readable. Does some compiler fail to compile it?
> +++ b/http-push.c
> static inline int needs_quote(int ch)
Hmm.. same function in http-fetch.c. Lots of common code could be moved to http.h.
-- http://onion.dynserv.net/~timo/