{"thread":{"id":"2733","subject":"[PATCH] Add compat/setenv.c, use in git.c.","startedAt":"2005-12-02T23:08:28Z","lastAt":"2005-12-07T00:58:00Z","messageCount":15,"participants":["Jason Riedy","Junio C Hamano","H. Peter Anvin","Morten Welinder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13122","messageId":"28409.1133564908@lotus.CS.Berkeley.EDU","threadId":"2733","inReplyTo":null,"subject":"[PATCH] Add compat/setenv.c, use in git.c.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-02T23:08:28Z","receivedAt":"2005-12-02T23:08:28Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"There is no setenv() in Solaris 5.8.  The trivial calls to\nsetenv() were replaced by putenv() in a much earlier patch,\nbut setenv() was used again in git.c.  This patch just adds\na compat/setenv.c.\n\nThe rule for building git$(X) also needs to include compat.\nobjects and compiler flags.  Those are now in makefile vars\nCOMPAT_OBJS and COMPAT_CFLAGS.\n\nSigned-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>\n\n---\n\n Makefile        |   27 ++++++++++++++++++---------\n compat/setenv.c |   31 +++++++++++++++++++++++++++++++\n git.c           |    4 ++++\n 3 files changed, 53 insertions(+), 9 deletions(-)\n create mode 100644 compat/setenv.c\n\napplies-to: fc206c1ad60cfb6481cc51f6737ce728d1d8d83f\n4bbc94c80d34b1ef859dd92254284198b0c3c2b6\ndiff --git a/Makefile b/Makefile\nindex 45db357..df3c6eb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -21,6 +21,8 @@ all:\n #\n # Define NO_STRCASESTR if you don't have strcasestr.\n #\n+# Define NO_SETENV if you don't have setenv in the C library.\n+#\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\n #\n@@ -194,6 +196,7 @@ shellquote = '$(call shq,$(1))'\n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')\n uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')\n+uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')\n \n ifeq ($(uname_S),Darwin)\n \tNEEDS_SSL_WITH_CRYPTO = YesPlease\n@@ -211,6 +214,9 @@ ifeq ($(uname_S),SunOS)\n \tNEEDS_LIBICONV = YesPlease\n \tSHELL_PATH = /bin/bash\n \tNO_STRCASESTR = YesPlease\n+\tifeq ($(uname_R),5.8)\n+\t\tNO_SETENV = YesPlease\n+\tendif\n \tINSTALL = ginstall\n \tTAR = gtar\n \tALL_CFLAGS += -D__EXTENSIONS__\n@@ -314,12 +320,16 @@ ifdef NEEDS_NSL\n \tSIMPLE_LIB += -lnsl\n endif\n ifdef NO_STRCASESTR\n-\tALL_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1\n-\tLIB_OBJS += compat/strcasestr.o\n+\tCOMPAT_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1\n+\tCOMPAT_OBJS += compat/strcasestr.o\n+endif\n+ifdef NO_SETENV\n+\tCOMPAT_CFLAGS += -Dsetenv=gitsetenv -DNO_SETENV=1\n+\tCOMPAT_OBJS += compat/setenv.o\n endif\n ifdef NO_MMAP\n-\tALL_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP\n-\tLIB_OBJS += compat/mmap.o\n+\tCOMPAT_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP\n+\tCOMPAT_OBJS += compat/mmap.o\n endif\n ifdef NO_IPV6\n \tALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in\n@@ -343,8 +353,8 @@ endif\n endif\n endif\n \n-ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))\n-\n+ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)\n+LIB_OBJS += $(COMPAT_OBJS)\n export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir\n ### Build rules\n \n@@ -353,10 +363,9 @@ all: $(ALL_PROGRAMS)\n all:\n \t$(MAKE) -C templates\n \n-# Only use $(CFLAGS). We don't need anything else.\n-git$(X): git.c Makefile\n+git$(X): git.c $(COMPAT_OBJS) Makefile\n \t$(CC) -DGIT_EXEC_PATH='\"$(bindir)\"' -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n-\t\t$(CFLAGS) $< -o $@\n+\t\t$(CFLAGS) $(COMPAT_CFLAGS) -o $@ $(filter %.c,$^) $(filter %.o,$^)\n \n $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n \trm -f $@\ndiff --git a/compat/setenv.c b/compat/setenv.c\nnew file mode 100644\nindex 0000000..94acd2d\n--- /dev/null\n+++ b/compat/setenv.c\n@@ -0,0 +1,31 @@\n+#include <stdlib.h>\n+#include <string.h>\n+\n+int gitsetenv(const char *name, const char *value, int replace)\n+{\n+\tint out;\n+\tsize_t namelen, valuelen;\n+\tchar *envstr;\n+\n+\tif (!name || !value) return -1;\n+\tif (!replace) {\n+\t\tchar *oldval = NULL;\n+\t\toldval = getenv(name);\n+\t\tif (oldval) return 0;\n+\t}\n+\n+\tnamelen = strlen(name);\n+\tvaluelen = strlen(value);\n+\tenvstr = malloc((namelen + valuelen + 2) * sizeof(char));\n+\tif (!envstr) return -1;\n+\n+\tmemcpy(envstr, name, namelen);\n+\tenvstr[namelen] = '=';\n+\tmemcpy(envstr + namelen + 1, value, valuelen);\n+\tenvstr[namelen + valuelen + 1] = 0;\n+\n+\tout = putenv(envstr);\n+\n+\tfree(envstr);\n+\treturn out;\n+}\ndiff --git a/git.c b/git.c\nindex 878c359..619f25a 100644\n--- a/git.c\n+++ b/git.c\n@@ -13,6 +13,10 @@\n # define PATH_MAX 4096\n #endif\n \n+#ifdef NO_SETENV\n+extern int gitsetenv(char *name, char *value, int overwrite);\n+#endif\n+\n static const char git_usage[] =\n \t\"Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]\";\n \n---\n0.99.9h\n"},{"id":"13170","messageId":"7vk6eltm26.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"28409.1133564908@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-04T06:26:25Z","receivedAt":"2005-12-04T06:26:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> The rule for building git$(X) also needs to include compat.\n> objects and compiler flags.  Those are now in makefile vars\n> COMPAT_OBJS and COMPAT_CFLAGS.\n\nThanks for the cleanup.  Looks much saner.\n"},{"id":"13180","messageId":"43935A9E.2060602@zytor.com","threadId":"2733","inReplyTo":"28409.1133564908@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-04T21:07:42Z","receivedAt":"2005-12-04T21:07:42Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Jason Riedy wrote:\n> +\n> +int gitsetenv(const char *name, const char *value, int replace)\n> +{\n> +\tint out;\n> +\tsize_t namelen, valuelen;\n> +\tchar *envstr;\n> +\n> +\tif (!name || !value) return -1;\n> +\tif (!replace) {\n> +\t\tchar *oldval = NULL;\n> +\t\toldval = getenv(name);\n> +\t\tif (oldval) return 0;\n> +\t}\n> +\n> +\tnamelen = strlen(name);\n> +\tvaluelen = strlen(value);\n> +\tenvstr = malloc((namelen + valuelen + 2) * sizeof(char));\n> +\tif (!envstr) return -1;\n> +\n> +\tmemcpy(envstr, name, namelen);\n> +\tenvstr[namelen] = '=';\n> +\tmemcpy(envstr + namelen + 1, value, valuelen);\n> +\tenvstr[namelen + valuelen + 1] = 0;\n> +\n> +\tout = putenv(envstr);\n> +\n> +\tfree(envstr);\n> +\treturn out;\n> +}\n\nWouldn't this be a good case for using alloca()?\n\n\t-hpa\n"},{"id":"13182","messageId":"7vy830ec15.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"43935A9E.2060602@zytor.com","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-04T22:24:22Z","receivedAt":"2005-12-04T22:24:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> Wouldn't this be a good case for using alloca()?\n\nPerhaps, but considering that (1) this function is not something\nfrequently called anyway, and (2) the proposed change would make\nit the first alloca() user, and (3) this is compatibility\nreplacement function, I'd rather choose to keep it \"old, known\nto work at more places\" malloc/free pair, and not having to\nworry about it.\n\nBut now you quote the patch, sizeof(char) looks funny.  Isn't it\nalways 1 by definition?\n"},{"id":"13183","messageId":"7vr78sebp8.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"43935A9E.2060602@zytor.com","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-04T22:31:31Z","receivedAt":"2005-12-04T22:31:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> Jason Riedy wrote:\n>> +\n>> +int gitsetenv(const char *name, const char *value, int replace)\n>> +{\n>> +...\n>> +\tenvstr = malloc((namelen + valuelen + 2) * sizeof(char));\n>> +...\n>> +\tout = putenv(envstr);\n>> +\n>> +\tfree(envstr);\n>> +\treturn out;\n>> +}\n>\n> Wouldn't this be a good case for using alloca()?\n\nOops.  Isn't the patch itself wrong, so is using alloca()?\n\nputenv(3) says\n\n\tint putenv(char *string);\n\n\tThe string pointed to by string becomes part of the environment,\n\tso altering the string changes the environment.\n\nwhich tell sme that whatever we pass to putenv() we should *not*\nfree.\n"},{"id":"13184","messageId":"7vlkz0eaan.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"28409.1133564908@lotus.CS.Berkeley.EDU","subject":"[PATCH] compat/setenv: do not free what we fed putenv(3).","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-04T23:01:52Z","receivedAt":"2005-12-04T23:01:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n compat/setenv.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\n3a2674337c12e958f8c697af991a0ef6c06ddd4d\ndiff --git a/compat/setenv.c b/compat/setenv.c\nindex 94acd2d..b7d7678 100644\n--- a/compat/setenv.c\n+++ b/compat/setenv.c\n@@ -16,7 +16,7 @@ int gitsetenv(const char *name, const ch\n \n \tnamelen = strlen(name);\n \tvaluelen = strlen(value);\n-\tenvstr = malloc((namelen + valuelen + 2) * sizeof(char));\n+\tenvstr = malloc((namelen + valuelen + 2));\n \tif (!envstr) return -1;\n \n \tmemcpy(envstr, name, namelen);\n@@ -25,7 +25,11 @@ int gitsetenv(const char *name, const ch\n \tenvstr[namelen + valuelen + 1] = 0;\n \n \tout = putenv(envstr);\n+\t/* putenv(3) makes the argument string part of the environment,\n+\t * and changing that string modifies the environment --- which\n+\t * means we do not own that storage anymore.  Do not free\n+\t * envstr.\n+\t */\n \n-\tfree(envstr);\n \treturn out;\n }\n-- \n0.99.9.GIT\n"},{"id":"13188","messageId":"43937D01.8090706@zytor.com","threadId":"2733","inReplyTo":"7vr78sebp8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-04T23:34:25Z","receivedAt":"2005-12-04T23:34:25Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Junio C Hamano wrote:\n> \n> Oops.  Isn't the patch itself wrong, so is using alloca()?\n> \n> putenv(3) says\n> \n> \tint putenv(char *string);\n> \n> \tThe string pointed to by string becomes part of the environment,\n> \tso altering the string changes the environment.\n> \n> which tell sme that whatever we pass to putenv() we should *not*\n> free.\n\nIndeed.\n\n\t-hpa\n"},{"id":"13208","messageId":"14404.1133806037@lotus.CS.Berkeley.EDU","threadId":"2733","inReplyTo":"7vr78sebp8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-05T18:07:17Z","receivedAt":"2005-12-05T18:07:17Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"And Junio C Hamano writes:\n - putenv(3) says\n - \tThe string pointed to by string becomes part of the environment,\n - \tso altering the string changes the environment.\n\nGood catch, thanks.  The Solaris man page first says the \nstring space is \"no longer used\", but at the very end warns \nagainst using an automatic variable.  Chalk one up for lousy \ndocs.\n\n(And sizeof(char) is just habit; 99% of my mallocs aren't of \nchar...  Sorry.)\n\nJason\n"},{"id":"13210","messageId":"43948977.7060405@zytor.com","threadId":"2733","inReplyTo":"14404.1133806037@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-05T18:39:51Z","receivedAt":"2005-12-05T18:39:51Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Jason Riedy wrote:\n> And Junio C Hamano writes:\n>  - putenv(3) says\n>  - \tThe string pointed to by string becomes part of the environment,\n>  - \tso altering the string changes the environment.\n> \n> Good catch, thanks.  The Solaris man page first says the \n> string space is \"no longer used\", but at the very end warns \n> against using an automatic variable.  Chalk one up for lousy \n> docs.\n> \n> (And sizeof(char) is just habit; 99% of my mallocs aren't of \n> char...  Sorry.)\n> \n\nPersonally I consider it a serious bug in the C language that \nsizeof(char) == 1 by definition.  It basically prohibits a whole lot of \nuseful machine models.\n\n\t-hpa\n"},{"id":"13240","messageId":"7vslt67v9o.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"14404.1133806037@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-06T03:35:15Z","receivedAt":"2005-12-06T03:35:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> And Junio C Hamano writes:\n>  - putenv(3) says\n>  - \tThe string pointed to by string becomes part of the environment,\n>  - \tso altering the string changes the environment.\n>\n> Good catch, thanks.  The Solaris man page first says the \n> string space is \"no longer used\", but at the very end warns \n> against using an automatic variable.  Chalk one up for lousy \n> docs.\n\nSame thing for 5.9.\n\nWith the \"compat update\" patch from last night, I managed to\nbuild on a borrowed sparc with Solaris 5.9, but I needed\nNO_SETENV myself.  I'd like to throw in another Makefile patch\nto catch both 5.8 and 5.9 for this, but would appreciate if\npeople with various vintage of Solaris boxes can give some\ninputs before doing that.\n\nThis was done with somewhat stripped down configuration.  I had\nto say NO_EXPAT, libiconv was needed but iconv and openssl were\ninstalled at nonstandard places, python was 2.3 so I also said\nPYTHON_PATH and WITH_OWN_SUBPROCESS_PY from the make command\nline.  But the borrowed box is not what I administer myself, so\nI declare victory for now.\n"},{"id":"13276","messageId":"14331.1133899163@lotus.CS.Berkeley.EDU","threadId":"2733","inReplyTo":"7vslt67v9o.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-06T19:59:23Z","receivedAt":"2005-12-06T19:59:23Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"And Junio C Hamano writes:\n - I'd like to throw in another Makefile patch to catch both 5.8 and \n - 5.9 for this, but would appreciate if people with various vintage \n - of Solaris boxes can give some inputs before doing that.\n\nAnyone else seeing the qsort in object.c trash memory?  The\ninput _looks_ correct.  I only see this on Solaris (8), but \nI've never had a problem with qsort there.  I think we have \na Solaris 9 box around here somewhere, but probably only\npartially 9.  The admins here are too busy fixing Windows to\nmaintain anything else properly.\n\n - This was done with somewhat stripped down configuration.\n\nOnce I replace the qsort (with an insertion sort), almost all \nthe tests work with my odd-ball but full configuration.  I'm \nhaving some problems with cpio in the push tests, but it's \njust some path issue for my setup.  When I run the same \ncommands by hand, they work.\n\nI'll test this on AIX again soon.\n\nJason\n"},{"id":"13278","messageId":"118833cc0512061310r6398f812ia47a84d3cfad1564@mail.gmail.com","threadId":"2733","inReplyTo":"14331.1133899163@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2005-12-06T21:10:56Z","receivedAt":"2005-12-06T21:10:56Z","isPatch":true,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":"The code looks wrong.  It assumes that pointers are no larger than ints.\nIf pointers are larger than ints, the code does not necessarily compute\na consistent ordering and qsort is allowed to do whatever it wants.\n\nMorten\n\n\n\nstatic int compare_object_pointers(const void *a, const void *b)\n{\n\tconst struct object * const *pa = a;\n\tconst struct object * const *pb = b;\n\treturn *pa - *pb;\n}\n"},{"id":"13283","messageId":"7vwtih299f.fsf@assigned-by-dhcp.cox.net","threadId":"2733","inReplyTo":"118833cc0512061310r6398f812ia47a84d3cfad1564@mail.gmail.com","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-06T21:41:48Z","receivedAt":"2005-12-06T21:41:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Morten Welinder <mwelinder@gmail.com> writes:\n\n> The code looks wrong.  It assumes that pointers are no larger than ints.\n> If pointers are larger than ints, the code does not necessarily compute\n> a consistent ordering and qsort is allowed to do whatever it wants.\n>\n> Morten\n>\n>\n>\n> static int compare_object_pointers(const void *a, const void *b)\n> {\n> \tconst struct object * const *pa = a;\n> \tconst struct object * const *pb = b;\n> \treturn *pa - *pb;\n> }\n\nAre you suggesting it to be done like this?\n\n---\ngit diff\ndiff --git a/object.c b/object.c\nindex 427e14c..dac5c92 100644\n--- a/object.c\n+++ b/object.c\n@@ -82,7 +82,12 @@ static int compare_object_pointers(const\n {\n \tconst struct object * const *pa = a;\n \tconst struct object * const *pb = b;\n-\treturn *pa - *pb;\n+\tif (*pa == *pb)\n+\t\treturn 0;\n+\telse if (*pa < *pb)\n+\t\treturn -1;\n+\telse\n+\t\treturn 1;\n }\n \n void set_object_refs(struct object *obj, struct object_refs *refs)\n"},{"id":"13287","messageId":"20475.1133907505@lotus.CS.Berkeley.EDU","threadId":"2733","inReplyTo":"7vwtih299f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2005-12-06T22:18:25Z","receivedAt":"2005-12-06T22:18:25Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"And Morten Welinder writes:\n - The code looks wrong.  It assumes that pointers are no larger than ints.\n\nThe failure's in 32-bit mode, so they _are_ the same size.\nThe difference is no more than 0x80 in the tests.\n\nBut you're right; the result is implementation defined in\nC99.\n\nAnd Junio C Hamano writes:\n - Are you suggesting it to be done like this?\n\nYour change fixed it.  Oddly enough, using arithmetic in\nptrdiff_t then testing against zero didn't...  I don't\nhave time to dig through assembly or try different gcc\nversions to figure out the real problem.  ugh.\n\nJason\n"},{"id":"13302","messageId":"118833cc0512061658g474edf35m4b1038fb739f0468@mail.gmail.com","threadId":"2733","inReplyTo":"7vwtih299f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add compat/setenv.c, use in git.c.","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2005-12-07T00:58:00Z","receivedAt":"2005-12-07T00:58:00Z","isPatch":true,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":"> Are you suggesting it to be done like this?\n\nPrecisely.\n\nMorten\n"}]}