{"thread":{"id":"15077","subject":"[FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","startedAt":"2008-08-18T23:39:40Z","lastAt":"2008-09-15T18:27:34Z","messageCount":36,"participants":["Brandon Casey","Jeff King","Alex Riesen","David Kågedal","Andreas Ericsson","Junio C Hamano","Shawn O. Pearce","Johannes Schindelin","Tom G. Christensen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"87595","messageId":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":null,"subject":"[FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-18T23:39:40Z","receivedAt":"2008-08-18T23:39:40Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"This email describes how I have successfully compiled git on SunOS 5.7 with\nthe native SUNWspro compiler version 6 update 2 C 5.3 2001/05/15 and\nsuccessfully run nearly all of the tests using the Korn shell.\n\nA series of 8 patches will follow this email. The patches work around a\nfew issues with this c89 compiler, and the ancient build environment.\n\nA build script is provided at the end of this email.\n\nThe GIT_SKIP_TESTS environment variable was used to skip tests which still fail.\nThe tests which still fail do so because of an ancient iconv, with two exceptions:\n1) the t5000 tests which fail are due to the installed gnu tar being too old, and\n2) the t6030 tests which fail do so because of the recent change which calls\n   trap with signal 0 inside of a function. The installed korn shell (mis-?)handles\n   this calling sequence.\n\nOtherwise, I've been using this executable somewhat and have not experienced any\nproblems. Maybe it will be useful to others.\n\n Makefile                       |   14 +++++++++++++-\n builtin-cat-file.c             |    2 +-\n builtin-reset.c                |    2 +-\n dir.c                          |   11 ++++++-----\n t/annotate-tests.sh            |    2 +-\n t/lib-git-svn.sh               |    3 +++\n t/t1002-read-tree-m-u-2way.sh  |   10 ++++++----\n t/t4118-apply-empty-context.sh |    2 +-\n t/t4200-rerere.sh              |    5 +++--\n t/t9301-fast-export.sh         |    1 -\n t/t9700/test.pl                |   12 ++++++------\n t/test-lib.sh                  |    2 +-\n 12 files changed, 42 insertions(+), 24 deletions(-)\n\n-brandon\n\n\n#!/bin/sh\n\nGIT_SKIP_TESTS='\n   t3900.1[0-289] t3900.2[023]\n   t3901.*\n   t5000.1[0-24-689] t5000.2[01]\n   t5100.[56] t5100.1[02]\n   t6030.1[2-9] t6030.2[0-9]\n   t9301.4\n'\n\nGIT_TEST_CMP='cmp -s'\n\nPATH=\"/usr/xpg4/bin:$PATH\"\n\nexport PATH GIT_TEST_CMP GIT_SKIP_TESTS\n\nexec gmake \\\n    CC=/opt/SUNWspro/bin/cc \\\n    INSTALL=ginstall \\\n    TAR=gtar \\\n    CFLAGS='-fast' \\\n    NO_CURL=1 \\\n    NO_OPENSSL=1 \\\n    NO_TCLTK=1 \\\n    NO_PERL_MAKEMAKER=1 \\\n    THREADED_DELTA_SEARCH=1 \\\n    \"$@\"\n"},{"id":"87613","messageId":"gyE6_rJUZSrlchRRxI1_FrybgeJIEHsFMLoTC4uoGAmW1PaknxWOVA@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH] Makefile: configuration for SunOS 5.7","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-18T23:55:45Z","receivedAt":"2008-08-18T23:55:45Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"---\n Makefile |   14 +++++++++++++-\n 1 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 551bde9..1e4e66f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -620,11 +620,23 @@ endif\n ifeq ($(uname_S),SunOS)\n \tNEEDS_SOCKET = YesPlease\n \tNEEDS_NSL = YesPlease\n-\tSHELL_PATH = /bin/bash\n+\tSHELL_PATH = /usr/xpg4/bin/sh\n \tNO_STRCASESTR = YesPlease\n \tNO_MEMMEM = YesPlease\n \tNO_HSTRERROR = YesPlease\n \tNO_MKDTEMP = YesPlease\n+\tifeq ($(uname_R),5.7)\n+\t\tNO_IPV6 = YesPlease\n+\t\tNO_SOCKADDR_STORAGE = YesPlease\n+\t\tNO_UNSETENV = YesPlease\n+\t\tNO_SETENV = YesPlease\n+\t\tNO_STRLCPY = YesPlease\n+\t\tNO_INET_NTOP = YesPlease\n+\t\tNO_INET_PTON = YesPlease\n+\t\tNO_C99_FORMAT = YesPlease\n+\t\tNO_STRTOUMAX = YesPlease\n+\t\tOLD_ICONV = UnfortunatelyYes\n+\tendif\n \tifeq ($(uname_R),5.8)\n \t\tNEEDS_LIBICONV = YesPlease\n \t\tNO_UNSETENV = YesPlease\n-- \n1.6.0.11.gecc7e\n"},{"id":"87614","messageId":"G-ipWASixyGW7nvO1KquifehvBB7FNKwjPtIB0ukyEJ1Si1CJWM34w@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH] dir.c: avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-18T23:57:33Z","receivedAt":"2008-08-18T23:57:33Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The following syntax:\n\n        char foo[] = {\n                [0] = 1,\n                [7] = 2,\n                [15] = 3\n        };\n\nis a c99 construct which some compilers do not support even though they\nsupport other c99 constructs. Use an alternative.\n---\n dir.c |   11 ++++++-----\n 1 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 29d1d5b..14d2eea 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -680,13 +680,14 @@ static int cmp_name(const void *p1, const void *p2)\n  */\n static int simple_length(const char *match)\n {\n-\tconst char special[256] = {\n-\t\t[0] = 1, ['?'] = 1,\n-\t\t['\\\\'] = 1, ['*'] = 1,\n-\t\t['['] = 1\n-\t};\n+\tchar special[256] = { 1, };\n \tint len = -1;\n \n+\tspecial['?'] = 1;\n+\tspecial['\\\\'] = 1;\n+\tspecial['*'] = 1;\n+\tspecial['['] = 1;\n+\n \tfor (;;) {\n \t\tunsigned char c = *match++;\n \t\tlen++;\n-- \n1.6.0.11.gecc7e\n"},{"id":"87616","messageId":"hjRg2-WPGYEeqAP0h-sXbS8ouecjwZU2ymwwyp8wKIjQ_CGDG5-urQ@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] reset,cat-file: remove const declaration from array","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:08:50Z","receivedAt":"2008-08-19T00:08:50Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Silence compiler complaints about opt array initialized with local\nvariables which was declared const.\n---\n builtin-cat-file.c |    2 +-\n builtin-reset.c    |    2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-cat-file.c b/builtin-cat-file.c\nindex 7441a56..d954c09 100644\n--- a/builtin-cat-file.c\n+++ b/builtin-cat-file.c\n@@ -212,7 +212,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)\n \tint opt = 0, batch = 0;\n \tconst char *exp_type = NULL, *obj_name = NULL;\n \n-\tconst struct option options[] = {\n+\tstruct option options[] = {\n \t\tOPT_GROUP(\"<type> can be one of: blob, tree, commit, tag\"),\n \t\tOPT_SET_INT('t', NULL, &opt, \"show object type\", 't'),\n \t\tOPT_SET_INT('s', NULL, &opt, \"show object size\", 's'),\ndiff --git a/builtin-reset.c b/builtin-reset.c\nindex 4d246c3..28b633f 100644\n--- a/builtin-reset.c\n+++ b/builtin-reset.c\n@@ -176,7 +176,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\t\t\t*old_orig = NULL, sha1_old_orig[20];\n \tstruct commit *commit;\n \tchar *reflog_action, msg[1024];\n-\tconst struct option options[] = {\n+\tstruct option options[] = {\n \t\tOPT_SET_INT(0, \"mixed\", &reset_type,\n \t\t\t\t\t\t\"reset HEAD and index\", MIXED),\n \t\tOPT_SET_INT(0, \"soft\", &reset_type, \"reset only HEAD\", SOFT),\n-- \n1.6.0.11.gecc7e\n"},{"id":"87617","messageId":"20fxFRoix9DAAeLmqmpHU-KsSuokk8Un2zipN8uZkXEQln3EHA-Paw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] test-lib.sh: work around ksh's trap shortcomings","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:11:41Z","receivedAt":"2008-08-19T00:11:41Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"In ksh, if trap is called within a function with 0 or EXIT as its signal,\nthen the trap will be executed at the time the function returns. This\ncauses a problem in the test functions since 'trap - exit' is called\nwithin the test_done function in order to remove the trap which calls\ndie() on exit. This means trap has to be called from the scripts top-level.\nDo so using an alias.\n\nAdditionally, there is some strangeness with respect to aliases and\nsourced script files; the alias hack doesn't work. So call 'trap - 0'\ndirectly in lib-git-svn.sh before calling the test_done function.\n---\n\n\nThis is the same patch I posted earlier with respect to compiling on IRIX\nand Junio has suggested a more elegant solution.\n\n-brandon\n\n\n t/lib-git-svn.sh |    3 +++\n t/test-lib.sh    |    2 +-\n 2 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex a841df2..e2e8cf3 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -3,6 +3,7 @@\n if test -n \"$NO_SVN_TESTS\"\n then\n \ttest_expect_success 'skipping git-svn tests, NO_SVN_TESTS defined' :\n+\ttrap - exit\n \ttest_done\n \texit\n fi\n@@ -15,6 +16,7 @@ svn >/dev/null 2>&1\n if test $? -ne 1\n then\n     test_expect_success 'skipping git-svn tests, svn not found' :\n+    trap - exit\n     test_done\n     exit\n fi\n@@ -39,6 +41,7 @@ then\n \t\terr='Perl SVN libraries not found or unusable, skipping test'\n \tfi\n \ttest_expect_success \"$err\" :\n+\ttrap - exit\n \ttest_done\n \texit\n fi\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 11c0275..6a3fc93 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -415,7 +415,6 @@ test_create_repo () {\n }\n \n test_done () {\n-\ttrap - exit\n \ttest_results_dir=\"$TEST_DIRECTORY/test-results\"\n \tmkdir -p \"$test_results_dir\"\n \ttest_results_path=\"$test_results_dir/${0%-*}-$$\"\n@@ -457,6 +456,7 @@ test_done () {\n \n \tesac\n }\n+alias test_done='trap - exit && test_done'\n \n # Test the binaries we have just built.  The tests are kept in\n # t/ subdirectory and are run in 'trash directory' subdirectory.\n-- \n1.6.0.11.gecc7e\n"},{"id":"87619","messageId":"Fw5U6bbeAwsJt8NPEGhI_KJGqviiUs1rv931TtDgSG2zzNctlxMWYA@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0'","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:13:31Z","receivedAt":"2008-08-19T00:13:31Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Some old platforms have an old diff which doesn't have the -U option.\n'git diff' can be used in its place. Adjust the comparison function to\nstrip git's additional header lines to make this possible.\n---\n\n\nSame as the one posted in the IRIX thread.\n\n\n t/t1002-read-tree-m-u-2way.sh |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh\nindex aa9dd58..5e40cec 100755\n--- a/t/t1002-read-tree-m-u-2way.sh\n+++ b/t/t1002-read-tree-m-u-2way.sh\n@@ -14,6 +14,8 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n compare_change () {\n \tsed >current \\\n+\t    -e '1{/^diff --git /d;}' \\\n+\t    -e '2{/^index /d;}' \\\n \t    -e '/^--- /d; /^+++ /d; /^@@ /d;' \\\n \t    -e 's/^\\(.[0-7][0-7][0-7][0-7][0-7][0-7]\\) '\"$_x40\"' /\\1 X /' \"$1\"\n \ttest_cmp expected current\n@@ -75,7 +77,7 @@ test_expect_success \\\n      git update-index --add yomin &&\n      git read-tree -m -u $treeH $treeM &&\n      git ls-files --stage >4.out || return 1\n-     diff -U0 M.out 4.out >4diff.out\n+     git diff -U0 --no-index M.out 4.out >4diff.out\n      compare_change 4diff.out expected &&\n      check_cache_at yomin clean &&\n      sum bozbar frotz nitfol >actual4.sum &&\n@@ -94,7 +96,7 @@ test_expect_success \\\n      echo yomin yomin >yomin &&\n      git read-tree -m -u $treeH $treeM &&\n      git ls-files --stage >5.out || return 1\n-     diff -U0 M.out 5.out >5diff.out\n+     git diff -U0 --no-index M.out 5.out >5diff.out\n      compare_change 5diff.out expected &&\n      check_cache_at yomin dirty &&\n      sum bozbar frotz nitfol >actual5.sum &&\n@@ -206,7 +208,7 @@ test_expect_success \\\n      git update-index --add nitfol &&\n      git read-tree -m -u $treeH $treeM &&\n      git ls-files --stage >14.out || return 1\n-     diff -U0 M.out 14.out >14diff.out\n+     git diff -U0 --no-index M.out 14.out >14diff.out\n      compare_change 14diff.out expected &&\n      sum bozbar frotz >actual14.sum &&\n      grep -v nitfol M.sum > expected14.sum &&\n@@ -227,7 +229,7 @@ test_expect_success \\\n      echo nitfol nitfol nitfol >nitfol &&\n      git read-tree -m -u $treeH $treeM &&\n      git ls-files --stage >15.out || return 1\n-     diff -U0 M.out 15.out >15diff.out\n+     git diff -U0 --no-index M.out 15.out >15diff.out\n      compare_change 15diff.out expected &&\n      check_cache_at nitfol dirty &&\n      sum bozbar frotz >actual15.sum &&\n-- \n1.6.0.11.gecc7e\n"},{"id":"87620","messageId":"RJmd_We0BRt641swOemkgHiaYcXguvcn3HcZHHGRLDm-254BgNjVCw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] Work around sed issues","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:18:49Z","receivedAt":"2008-08-19T00:18:49Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"\n/usr/xpg4/bin/sed exits non-zero if the sed script is not newline\nterminated. /bin/sed does not have this problem, so use it instead\nwhere possible.\n\nBut, /bin/sed does not handle tab correctly. For this case in t4200,\nrework the test so that the exit status of sed does not affect the\noutcome of the test, and use /usr/xpg4/bin/sed (which is in the PATH).\n\n---\n t/annotate-tests.sh            |    2 +-\n t/t4118-apply-empty-context.sh |    2 +-\n t/t4200-rerere.sh              |    5 +++--\n 3 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/t/annotate-tests.sh b/t/annotate-tests.sh\nindex cacb273..14ee531 100644\n--- a/t/annotate-tests.sh\n+++ b/t/annotate-tests.sh\n@@ -114,7 +114,7 @@ test_expect_success \\\n test_expect_success \\\n     'some edit' \\\n     'mv file file.orig &&\n-    sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" < file.orig > file &&\n+    /bin/sed -e \"s/^3A/99/\" -e \"/^1A/d\" -e \"/^incomplete/d\" < file.orig > file &&\n     echo \"incomplete\" | tr -d \"\\\\012\" >>file &&\n     GIT_AUTHOR_NAME=\"D\" git commit -a -m \"edit\"'\n \ndiff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh\nindex f92e259..c064f7b 100755\n--- a/t/t4118-apply-empty-context.sh\n+++ b/t/t4118-apply-empty-context.sh\n@@ -23,7 +23,7 @@ test_expect_success setup '\n \tcat file2 >file2.orig\n \tgit add file1 file2 &&\n \tsed -e \"/^B/d\" <file1.orig >file1 &&\n-\tsed -e \"/^[BQ]/d\" <file2.orig >file2 &&\n+\t/bin/sed -e \"/^[BQ]/d\" <file2.orig >file2 &&\n \techo Q | tr -d \"\\\\012\" >>file2 &&\n \tcat file1 >file1.mods &&\n \tcat file2 >file2.mods &&\ndiff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh\nindex b68ab11..834f52f 100755\n--- a/t/t4200-rerere.sh\n+++ b/t/t4200-rerere.sh\n@@ -189,8 +189,9 @@ test_expect_success 'file2 added differently in two branches' '\n \techo Bello > file2 &&\n \tgit add file2 &&\n \tgit commit -m version2 &&\n-\ttest_must_fail git merge fourth &&\n-\tsha1=$(sed -e \"s/\t.*//\" .git/MERGE_RR) &&\n+\ttest_must_fail git merge fourth || return 1\n+\tsha1=$(sed -e \"s/\t.*//\" .git/MERGE_RR)\n+\ttest -n \"$sha1\" &&\n \trr=.git/rr-cache/$sha1 &&\n \techo Cello > file2 &&\n \tgit add file2 &&\n-- \n1.6.0.11.gecc7e\n"},{"id":"87621","messageId":"vGteI3DnC7lCPEEY8NLHOpwB6QEGihg6tXMEhCKrvrD3WSJ6OM1o-A@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] t9301-fast-export.sh: don't unset config variable while we're skipping test 4","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:20:44Z","receivedAt":"2008-08-19T00:20:44Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"---\n\n\nNecessary if using my compile script which included t9301.4 in GIT_SKIP_TESTS\nenvironment variable.\n\n-brandon\n\n\n t/t9301-fast-export.sh |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\nindex c19b4a2..475aadd 100755\n--- a/t/t9301-fast-export.sh\n+++ b/t/t9301-fast-export.sh\n@@ -190,7 +190,6 @@ export GIT_COMMITTER_NAME='C O Mitter'\n \n test_expect_success 'setup copies' '\n \n-\tgit config --unset i18n.commitencoding &&\n \tgit checkout -b copy rein &&\n \tgit mv file file3 &&\n \tgit commit -m move1 &&\n-- \n1.6.0.11.gecc7e\n"},{"id":"87622","messageId":"20080819002047.GA15770@coredump.intra.peff.net","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"Re: [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-08-19T00:20:48Z","receivedAt":"2008-08-19T00:20:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 18, 2008 at 06:39:40PM -0500, Brandon Casey wrote:\n\n> 1) the t5000 tests which fail are due to the installed gnu tar being\n> too old, and\n\nHmm. I thought I had t5000 working on Solaris 5.7 a few months ago.\nUnfortunately, the Solaris box I test on is down at the moment, so I\ncan't take a closer look. What is the problem?\n\n-Peff\n"},{"id":"87623","messageId":"iZMIxnwnUBIGAGz2GMS0uwCvMMo9aaYd2Arx4fbxk9NusvUC5LUNVg@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"[PATCH FYI] t9700/test.pl: backwards compatibility improvements","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:22:35Z","receivedAt":"2008-08-19T00:22:35Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Some versions of perl complain when 'STDERR' is used as the third argument\nin the 3-argument form of open(). Convert to the 2-argument form which is\ndescribed for duping STDERR in my second edition camel book.\n\nThe object oriented version of File::Temp is a rather new incarnation it\nseems. The File::Temp man page for v5.8.0 says \"(NOT YET IMPLEMENTED)\" in\nthe 'Objects' section. These can be converted to use File::Temp::tempfile().\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t9700/test.pl |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex 4d23125..70f9836 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -38,7 +38,7 @@ is($r->get_color(\"color.test.slot1\", \"red\"), $ansi_green, \"get_color\");\n # Failure cases for config:\n # Save and restore STDERR; we will probably extract this into a\n # \"dies_ok\" method and possibly move the STDERR handling to Git.pm.\n-open our $tmpstderr, \">&\", STDERR or die \"cannot save STDERR\"; close STDERR;\n+open our $tmpstderr, \">&STDERR\" or die \"cannot save STDERR\"; close STDERR;\n eval { $r->config(\"test.dupstring\") };\n ok($@, \"config: duplicate entry in scalar context fails\");\n eval { $r->config_bool(\"test.boolother\") };\n@@ -69,18 +69,18 @@ is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n \n # objects and hashes\n ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n-our $tmpfile = File::Temp->new;\n+our ($tmpfile, $tmpnam) = File::Temp::tempfile();\n is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n our $blobcontents;\n { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n seek $tmpfile, 0, 0;\n-is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n-$tmpfile = File::Temp->new();\n+is(Git::hash_object(\"blob\", $tmpnam), $file1hash, \"hash_object: roundtrip\");\n+($tmpfile, $tmpnam) = File::Temp::tempfile();\n print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n-like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n+like(our $newhash = $r->hash_and_insert_object($tmpnam), qr/[0-9a-fA-F]{40}/,\n      \"hash_and_insert_object: returns hash\");\n-$tmpfile = File::Temp->new;\n+$tmpfile = File::Temp::tempfile();\n is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n-- \n1.6.0.11.gecc7e\n"},{"id":"87630","messageId":"L3gfLYBAXG5GUGcbdLqOnZab_UfskZC4FTgP9d47MJuoAiJRa2V5ZQ@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"20080819002047.GA15770@coredump.intra.peff.net","subject":"Re: [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T00:47:39Z","receivedAt":"2008-08-19T00:47:39Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Jeff King wrote:\n> On Mon, Aug 18, 2008 at 06:39:40PM -0500, Brandon Casey wrote:\n> \n>> 1) the t5000 tests which fail are due to the installed gnu tar being\n>> too old, and\n> \n> Hmm. I thought I had t5000 working on Solaris 5.7 a few months ago.\n> Unfortunately, the Solaris box I test on is down at the moment, so I\n> can't take a closer look. What is the problem?\n\nProbably:\n$ gtar --version\ntar (GNU tar) 1.12\n\n\nIf I stop t5000-tar-tree.sh by inserting an exit before the 10th test\n(which is the first one that fails):\n\n    t5000-tar-tree.sh:\n    ...\n    test_expect_success \\\n       'git get-tar-commit-id' \\\n       'git get-tar-commit-id <b.tar >b.commitid &&\n        diff .git/$(git symbolic-ref HEAD) b.commitid'\n\n    exit\n\n    test_expect_success \\\n       'extract tar archive' \\\n       '(cd b && \"$TAR\" xf -) <b.tar'\n    ...\n\nand then execute the test commands manually, I get:\n\n$ cd t/trash\\ directory\n$ cd b\n$ gtar xf - < ../b.tar\n/apps/bin/gtar: Unknown file type 'g' for pax_global_header, extracted as normal file\n/apps/bin/gtar: : Could not create directory: No such file or directory\n/apps/bin/gtar: Error exit delayed from previous errors\n$ find .\n.\n./a\n./a/a\n./a/l1\n./a/substfile1\n./a/long_path_to_a_file\n./a/long_path_to_a_file/long_path_to_a_file\n./a/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file\n./a/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file\n./a/bin\n./a/bin/sh\n./a/substfile2\n./pax_global_header\n./file_with_long_path\n\n\nThe native tar returns:\n$ tar xf - < ../b.tar\ntar: directory checksum error\n\n-brandon\n"},{"id":"87638","messageId":"20080819020131.GA18364@coredump.intra.peff.net","threadId":"15077","inReplyTo":"L3gfLYBAXG5GUGcbdLqOnZab_UfskZC4FTgP9d47MJuoAiJRa2V5ZQ@cipher.nrlssc.navy.mil","subject":"Re: [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-08-19T02:01:32Z","receivedAt":"2008-08-19T02:01:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 18, 2008 at 07:47:39PM -0500, Brandon Casey wrote:\n\n> > Hmm. I thought I had t5000 working on Solaris 5.7 a few months ago.\n> > Unfortunately, the Solaris box I test on is down at the moment, so I\n> > can't take a closer look. What is the problem?\n> \n> Probably:\n> $ gtar --version\n> tar (GNU tar) 1.12\n\nAh, I found out the difference: my box is actually Solaris 5.8. The gtar\nversion there is 1.13 (which is also the version that ships with Solaris\n5.9).\n\n> $ gtar xf - < ../b.tar\n> /apps/bin/gtar: Unknown file type 'g' for pax_global_header, extracted as normal file\n> /apps/bin/gtar: : Could not create directory: No such file or directory\n> /apps/bin/gtar: Error exit delayed from previous errors\n\nI get the pax header warning, but nothing else. Judging from your find\nresults:\n\n> ./a/long_path_to_a_file\n> ./a/long_path_to_a_file/long_path_to_a_file\n> ./a/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file\n> ./a/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file/long_path_to_a_file\n\nThere should be another directory that is one level deeper, with\n\"file_with_long_path\" in it...\n\n> ./file_with_long_path\n\nwhich seems to have been extracted in the root instead!\n\nSo perhaps you are hitting some length limitation in gtar.\n\n-Peff\n"},{"id":"87645","messageId":"20080819061346.GA4046@blimp.local","threadId":"15077","inReplyTo":"IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil","subject":"Re: [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-19T06:13:47Z","receivedAt":"2008-08-19T06:13:47Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Brandon Casey, Tue, Aug 19, 2008 01:39:40 +0200:\n> \n> GIT_SKIP_TESTS='\n>    t3900.1[0-289] t3900.2[023]\n>    t3901.*\n>    t5000.1[0-24-689] t5000.2[01]\n>    t5100.[56] t5100.1[02]\n>    t6030.1[2-9] t6030.2[0-9]\n>    t9301.4\n> '\n> \n> GIT_TEST_CMP='cmp -s'\n> \n> PATH=\"/usr/xpg4/bin:$PATH\"\n> \n> export PATH GIT_TEST_CMP GIT_SKIP_TESTS\n> \n> exec gmake \\\n>     CC=/opt/SUNWspro/bin/cc \\\n>     INSTALL=ginstall \\\n>     TAR=gtar \\\n>     CFLAGS='-fast' \\\n>     NO_CURL=1 \\\n>     NO_OPENSSL=1 \\\n>     NO_TCLTK=1 \\\n>     NO_PERL_MAKEMAKER=1 \\\n>     THREADED_DELTA_SEARCH=1 \\\n>     \"$@\"\n\nYou can put all of it in config.mak. It is exactly what it is there\nfor: build customizations.\n"},{"id":"87710","messageId":"KkHxylCPz2hua_z93fQpvqguijqEkgoLlyt8D2l7qwYTUFHOxhMPoA@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"20080819061346.GA4046@blimp.local","subject":"Re: [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-19T15:42:13Z","receivedAt":"2008-08-19T15:42:13Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Alex Riesen wrote:\n\n> You can put all of it in config.mak. It is exactly what it is there\n> for: build customizations.\n\nAh, I didn't know about config.mak. Thanks.\n\n-brandon\n"},{"id":"88909","messageId":"871w09kvew.fsf@lysator.liu.se","threadId":"15077","inReplyTo":"G-ipWASixyGW7nvO1KquifehvBB7FNKwjPtIB0ukyEJ1Si1CJWM34w@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2008-08-28T15:32:07Z","receivedAt":"2008-08-28T15:32:07Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> The following syntax:\n>\n>         char foo[] = {\n>                 [0] = 1,\n>                 [7] = 2,\n>                 [15] = 3\n>         };\n>\n> is a c99 construct which some compilers do not support even though they\n> support other c99 constructs. Use an alternative.\n\nBut the alternative is much worse. So how important is it to support\nnon-C99 compilers?\n\n> ---\n>  dir.c |   11 ++++++-----\n>  1 files changed, 6 insertions(+), 5 deletions(-)\n>\n> diff --git a/dir.c b/dir.c\n> index 29d1d5b..14d2eea 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -680,13 +680,14 @@ static int cmp_name(const void *p1, const void *p2)\n>   */\n>  static int simple_length(const char *match)\n>  {\n> -\tconst char special[256] = {\n> -\t\t[0] = 1, ['?'] = 1,\n> -\t\t['\\\\'] = 1, ['*'] = 1,\n> -\t\t['['] = 1\n> -\t};\n> +\tchar special[256] = { 1, };\n>  \tint len = -1;\n>  \n> +\tspecial['?'] = 1;\n> +\tspecial['\\\\'] = 1;\n> +\tspecial['*'] = 1;\n> +\tspecial['['] = 1;\n> +\n>  \tfor (;;) {\n>  \t\tunsigned char c = *match++;\n>  \t\tlen++;\n\n-- \nDavid Kågedal\n"},{"id":"88910","messageId":"48B6C715.9060603@op5.se","threadId":"15077","inReplyTo":"871w09kvew.fsf@lysator.liu.se","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-08-28T15:41:09Z","receivedAt":"2008-08-28T15:41:09Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"David Kågedal wrote:\n> Brandon Casey <casey@nrlssc.navy.mil> writes:\n> \n>> The following syntax:\n>>\n>>         char foo[] = {\n>>                 [0] = 1,\n>>                 [7] = 2,\n>>                 [15] = 3\n>>         };\n>>\n>> is a c99 construct which some compilers do not support even though they\n>> support other c99 constructs. Use an alternative.\n> \n> But the alternative is much worse. So how important is it to support\n> non-C99 compilers?\n> \n\nFairly important. Lots of people have gone through lots of work to make\nsure git works with legacy compilers.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"88915","messageId":"GwKOGVPR0AVw4_Phmw1TSNzzMDtafrawMMahm2DQwh44k6uTOHkjTQ@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"871w09kvew.fsf@lysator.liu.se","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-28T16:45:52Z","receivedAt":"2008-08-28T16:45:52Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"David Kågedal wrote:\n> Brandon Casey <casey@nrlssc.navy.mil> writes:\n> \n>> The following syntax:\n>>\n>>         char foo[] = {\n>>                 [0] = 1,\n>>                 [7] = 2,\n>>                 [15] = 3\n>>         };\n>>\n>> is a c99 construct which some compilers do not support even though they\n>> support other c99 constructs. Use an alternative.\n> \n> But the alternative is much worse.\n\n_Much_ worse? In what way?\n\nFrom an execution standpoint, I don't think any more work is performed.\nProbably exactly the same amount of work.\n\nFrom a readability standpoint, I think it is very nearly the same in\nthis case. The whole function is only 17 lines.\n\n> So how important is it to support non-C99 compilers?\n\nI think it is relative to the amount of effort it takes. If there is\na demonstrated need and a trivial work around, I think it is worth\nit to support non-c99 compilers. Demonstrated need is required.\n\nBut, saying that, I posted the patch you replied to in a series that\nwas for informational purposes only (though I could have done a better\njob labeling them). There were no comments from anyone who said that\nthe series solved any problems they were encountering. At some point\nI will post an update.\n\n-brandon\n"},{"id":"88945","messageId":"7vhc95dldz.fsf@gitster.siamese.dyndns.org","threadId":"15077","inReplyTo":"GwKOGVPR0AVw4_Phmw1TSNzzMDtafrawMMahm2DQwh44k6uTOHkjTQ@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-28T18:50:32Z","receivedAt":"2008-08-28T18:50:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> David Kågedal wrote:\n>> Brandon Casey <casey@nrlssc.navy.mil> writes:\n>> \n>>> The following syntax:\n>>>\n>>>         char foo[] = {\n>>>                 [0] = 1,\n>>>                 [7] = 2,\n>>>                 [15] = 3\n>>>         };\n>>>\n>>> is a c99 construct which some compilers do not support even though they\n>>> support other c99 constructs. Use an alternative.\n>> \n>> But the alternative is much worse.\n>\n> _Much_ worse? In what way?\n>\n> From an execution standpoint, I don't think any more work is performed.\n> Probably exactly the same amount of work.\n>\n> From a readability standpoint, I think it is very nearly the same in\n> this case. The whole function is only 17 lines.\n\nI do not think your patch deserves \"much worse\" comment.\n\n>> So how important is it to support non-C99 compilers?\n>\n> I think it is relative to the amount of effort it takes. If there is\n> a demonstrated need and a trivial work around, I think it is worth\n> it to support non-c99 compilers.\n\nI do not mind taking this patch.  While it would not hurt (because the\ncode is readable with or without the change) to convert the trivial ones\nlike this patch addresses, it would not help portability if there are more\nnontrivial dependance to c99 constructs in other places in the code.  Are\nthere known ones?\n"},{"id":"88960","messageId":"81b0412b0808281301m29830c20l3e16432ea8aef45d@mail.gmail.com","threadId":"15077","inReplyTo":"G-ipWASixyGW7nvO1KquifehvBB7FNKwjPtIB0ukyEJ1Si1CJWM34w@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-28T20:01:53Z","receivedAt":"2008-08-28T20:01:53Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/8/19 Brandon Casey <casey@nrlssc.navy.mil>:\n>  static int simple_length(const char *match)\n>  {\n> -       const char special[256] = {\n> -               [0] = 1, ['?'] = 1,\n> -               ['\\\\'] = 1, ['*'] = 1,\n> -               ['['] = 1\n> -       };\n> +       char special[256] = { 1, };\n>        int len = -1;\n>\n> +       special['?'] = 1;\n> +       special['\\\\'] = 1;\n> +       special['*'] = 1;\n> +       special['['] = 1;\n\nFor just these 5 values it is likely more effective to just use\na conditional statement (less stack requested, less likely\nsome stupid compiler tries to optimize it wrongly).\nAnd just as readable.\n\ndiff --git a/dir.c b/dir.c\nindex 92452eb..1cf5985 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n  */\n static int simple_length(const char *match)\n {\n-\tconst char special[256] = {\n-\t\t[0] = 1, ['?'] = 1,\n-\t\t['\\\\'] = 1, ['*'] = 1,\n-\t\t['['] = 1\n-\t};\n \tint len = -1;\n\n \tfor (;;) {\n \t\tunsigned char c = *match++;\n \t\tlen++;\n-\t\tif (special[c])\n+\t\tif (!c || '?' == c || '\\\\' == c || '*' == c || '[' == c)\n \t\t\treturn len;\n \t}\n }\n"},{"id":"88962","messageId":"20080828201657.GH21072@spearce.org","threadId":"15077","inReplyTo":"81b0412b0808281301m29830c20l3e16432ea8aef45d@mail.gmail.com","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-08-28T20:16:57Z","receivedAt":"2008-08-28T20:16:57Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> wrote:\n> \n> For just these 5 values it is likely more effective to just use\n> a conditional statement (less stack requested, less likely\n> some stupid compiler tries to optimize it wrongly).\n> And just as readable.\n> \n> diff --git a/dir.c b/dir.c\n> index 92452eb..1cf5985 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n>   */\n>  static int simple_length(const char *match)\n>  {\n> -\tconst char special[256] = {\n> -\t\t[0] = 1, ['?'] = 1,\n> -\t\t['\\\\'] = 1, ['*'] = 1,\n> -\t\t['['] = 1\n> -\t};\n>  \tint len = -1;\n> \n>  \tfor (;;) {\n>  \t\tunsigned char c = *match++;\n>  \t\tlen++;\n> -\t\tif (special[c])\n> +\t\tif (!c || '?' == c || '\\\\' == c || '*' == c || '[' == c)\n\nI am reminded of a year old thread with my patch to this:\n\n  http://kerneltrap.org/mailarchive/git/2007/4/15/243541\n\nThe patch never applied.  I wonder why.  Was it just Dscho's comment?\n\n-- \nShawn.\n"},{"id":"88963","messageId":"7vwsi0dh61.fsf@gitster.siamese.dyndns.org","threadId":"15077","inReplyTo":"20080828201657.GH21072@spearce.org","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-28T20:21:42Z","receivedAt":"2008-08-28T20:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Alex Riesen <raa.lkml@gmail.com> wrote:\n>> \n>> For just these 5 values it is likely more effective to just use\n>> a conditional statement (less stack requested, less likely\n>> some stupid compiler tries to optimize it wrongly).\n>> And just as readable.\n>> \n>> diff --git a/dir.c b/dir.c\n>> index 92452eb..1cf5985 100644\n>> --- a/dir.c\n>> +++ b/dir.c\n>> @@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n>>   */\n>>  static int simple_length(const char *match)\n>>  {\n>> -\tconst char special[256] = {\n>> -\t\t[0] = 1, ['?'] = 1,\n>> -\t\t['\\\\'] = 1, ['*'] = 1,\n>> -\t\t['['] = 1\n>> -\t};\n>>  \tint len = -1;\n>> \n>>  \tfor (;;) {\n>>  \t\tunsigned char c = *match++;\n>>  \t\tlen++;\n>> -\t\tif (special[c])\n>> +\t\tif (!c || '?' == c || '\\\\' == c || '*' == c || '[' == c)\n>\n> I am reminded of a year old thread with my patch to this:\n>\n>   http://kerneltrap.org/mailarchive/git/2007/4/15/243541\n>\n> The patch never applied.  I wonder why.  Was it just Dscho's comment?\n\nI think it was an unanswered question about stealing one bit from\nctype.c::sane_ctype[] that kept the discussion in limbo.\n"},{"id":"88965","messageId":"81b0412b0808281327q302da48cl9e04ce999ff33903@mail.gmail.com","threadId":"15077","inReplyTo":"20080828201657.GH21072@spearce.org","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-28T20:27:10Z","receivedAt":"2008-08-28T20:27:10Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/8/28 Shawn O. Pearce <spearce@spearce.org>:\n> Alex Riesen <raa.lkml@gmail.com> wrote:\n>>\n>> For just these 5 values it is likely more effective to just use\n>> a conditional statement (less stack requested, less likely\n>> some stupid compiler tries to optimize it wrongly).\n>> And just as readable.\n>>\n>> diff --git a/dir.c b/dir.c\n>> index 92452eb..1cf5985 100644\n>> --- a/dir.c\n>> +++ b/dir.c\n>> @@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n>>   */\n>>  static int simple_length(const char *match)\n>>  {\n>> -     const char special[256] = {\n>> -             [0] = 1, ['?'] = 1,\n>> -             ['\\\\'] = 1, ['*'] = 1,\n>> -             ['['] = 1\n>> -     };\n>>       int len = -1;\n>>\n>>       for (;;) {\n>>               unsigned char c = *match++;\n>>               len++;\n>> -             if (special[c])\n>> +             if (!c || '?' == c || '\\\\' == c || '*' == c || '[' == c)\n>\n> I am reminded of a year old thread with my patch to this:\n>\n>  http://kerneltrap.org/mailarchive/git/2007/4/15/243541\n>\n> The patch never applied.  I wonder why.  Was it just Dscho's comment?\n>\n\nLikely. And that sane_ctype Junio mentioned, which still has 5 bits free\n"},{"id":"88981","messageId":"ojPuT0s3trguL5yp3hozXVxP1WsidV5hbSISvFZjv5JUCO31lWTzEw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"7vhc95dldz.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-28T21:01:58Z","receivedAt":"2008-08-28T21:01:58Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Junio C Hamano wrote:\n\n> I do not mind taking this patch.  While it would not hurt (because the\n> code is readable with or without the change) to convert the trivial ones\n> like this patch addresses, it would not help portability if there are more\n> nontrivial dependance to c99 constructs in other places in the code.  Are\n> there known ones?\n\nOnly one other \"c99\" issue that I have encountered (while using a c99 compiler\nno less) and it is similarly trivial:\n\n------->8-------\nFrom: Brandon Casey <casey@nrlssc.navy.mil>\nDate: Wed, 13 Aug 2008 11:09:33 -0700\nSubject: [PATCH] unpack-trees.c: work around run-time array initialization flaw on IRIX 6.5\n\nThe c99 MIPSpro Compiler version 7.4.4m on IRIX 6.5 does not properly\ninitialize run-time initialized arrays. An array which is initialized with\nfewer elements than the length of the array should have the uninitialized\nelements initialized to zero. This compiler does perform proper\ninitialization when static initialization parameters are used. So, work\naround this by using compile time initialization.\n---\n unpack-trees.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex cba0aca..de7cb0b 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -143,7 +143,8 @@ static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_o\n\n static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o)\n {\n-\tstruct cache_entry *src[5] = { ce, };\n+\tstruct cache_entry *src[5] = { NULL, };\n+\tsrc[0] = ce;\n\n \to->pos++;\n \tif (ce_stage(ce)) {\n-- \n1.6.0.1.119.gcb7f\n------->8-------\n\n\nThe above patch, along with minor changes to git-compat-util.h and a new entry in\nMakefile allow me to compile on IRIX 6.5. (note: the dir.c patch is not necessary\non IRIX 6.5).\n\nThe dir.c patch along with two removals of the const modifier from option\nstructures and a few tweaks in Makefile allow me to compile using the SUNWspro\ncompiler on Solaris 7. I'm not sure if it is a c99 issue, but I get the following\nerrors when compiling without the following patches (which follow the errors):\n\n\"builtin-cat-file.c\", line 121: warning: non-constant initializer: op \"NAME\"\n\"builtin-cat-file.c\", line 217: warning: non-constant initializer: op \"U&\"\n\"builtin-cat-file.c\", line 217: left operand must be modifiable lvalue: op \"=\"\n\"builtin-cat-file.c\", line 218: left operand must be modifiable lvalue: op \"=\"\n\"builtin-cat-file.c\", line 219: left operand must be modifiable lvalue: op \"=\"\n\"builtin-cat-file.c\", line 221: left operand must be modifiable lvalue: op \"=\"\n\"builtin-cat-file.c\", line 222: left operand must be modifiable lvalue: op \"=\"\n\"builtin-cat-file.c\", line 224: left operand must be modifiable lvalue: op \"=\"\ncc: acomp failed for builtin-cat-file.c\n\nand similar errors for builtin-reset.c.\n\n----->8-----\ndiff --git a/builtin-cat-file.c b/builtin-cat-file.c\nindex 7441a56..d954c09 100644\n--- a/builtin-cat-file.c\n+++ b/builtin-cat-file.c\n@@ -212,7 +212,7 @@ int cmd_cat_file(int argc, const char **argv, const char *pr\n \tint opt = 0, batch = 0;\n \tconst char *exp_type = NULL, *obj_name = NULL;\n \n-\tconst struct option options[] = {\n+\tstruct option options[] = {\n \t\tOPT_GROUP(\"<type> can be one of: blob, tree, commit, tag\"),\n \t\tOPT_SET_INT('t', NULL, &opt, \"show object type\", 't'),\n \t\tOPT_SET_INT('s', NULL, &opt, \"show object size\", 's'),\ndiff --git a/builtin-reset.c b/builtin-reset.c\nindex 4d246c3..28b633f 100644\n--- a/builtin-reset.c\n+++ b/builtin-reset.c\n@@ -176,7 +176,7 @@ int cmd_reset(int argc, const char **argv, const char *prefi\n\t\t\t\t*old_orig = NULL, sha1_old_orig[20];\n \tstruct commit *commit;\n \tchar *reflog_action, msg[1024];\n-\tconst struct option options[] = {\n+\tstruct option options[] = {\n \t\tOPT_SET_INT(0, \"mixed\", &reset_type,\n \t\t\t\t\t\t\"reset HEAD and index\", MIXED),\n \t\tOPT_SET_INT(0, \"soft\", &reset_type, \"reset only HEAD\", SOFT),\n \n----->8-----\n\nRunning the tests with ksh on these two platforms requires a work around for ksh's\nunique handling of trap within a function (which I do not yet have a pretty solution\nfor).\n\n-brandon\n"},{"id":"88993","messageId":"81b0412b0808281412j2a5643ceu49a49cf62002f0be@mail.gmail.com","threadId":"15077","inReplyTo":"ojPuT0s3trguL5yp3hozXVxP1WsidV5hbSISvFZjv5JUCO31lWTzEw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-28T21:12:46Z","receivedAt":"2008-08-28T21:12:46Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/8/28 Brandon Casey <casey@nrlssc.navy.mil>:\n> diff --git a/builtin-cat-file.c b/builtin-cat-file.c\n> index 7441a56..d954c09 100644\n> --- a/builtin-cat-file.c\n> +++ b/builtin-cat-file.c\n> @@ -212,7 +212,7 @@ int cmd_cat_file(int argc, const char **argv, const char *pr\n>        int opt = 0, batch = 0;\n>        const char *exp_type = NULL, *obj_name = NULL;\n>\n> -       const struct option options[] = {\n> +       struct option options[] = {\n>                OPT_GROUP(\"<type> can be one of: blob, tree, commit, tag\"),\n\n#ifdef HAVE_CONST\n#define gitconst const\n#else\n#define gitconst\n#endif\n\n-\tconst struct option options[] = {\n+\tgitconst struct option options[] = {\n\n?\n"},{"id":"89018","messageId":"4KsgvHQW6DRyM-ubFIcJEblIIJPpRQFHIc-4QMPGe5YzXAU8P5wWCA@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"81b0412b0808281412j2a5643ceu49a49cf62002f0be@mail.gmail.com","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-28T21:45:33Z","receivedAt":"2008-08-28T21:45:33Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Alex Riesen wrote:\n> 2008/8/28 Brandon Casey <casey@nrlssc.navy.mil>:\n>> diff --git a/builtin-cat-file.c b/builtin-cat-file.c\n>> index 7441a56..d954c09 100644\n>> --- a/builtin-cat-file.c\n>> +++ b/builtin-cat-file.c\n>> @@ -212,7 +212,7 @@ int cmd_cat_file(int argc, const char **argv, const char *pr\n>>        int opt = 0, batch = 0;\n>>        const char *exp_type = NULL, *obj_name = NULL;\n>>\n>> -       const struct option options[] = {\n>> +       struct option options[] = {\n>>                OPT_GROUP(\"<type> can be one of: blob, tree, commit, tag\"),\n> \n> #ifdef HAVE_CONST\n> #define gitconst const\n> #else\n> #define gitconst\n> #endif\n> \n> -\tconst struct option options[] = {\n> +\tgitconst struct option options[] = {\n> \n> ?\n\nThe problem is not that the const modifier is unrecognized. You can see in\nthe above patch that the const modifier was not removed from exp_type or\nobj_name.\n\nI think the warning on line 217 is the most important where it complains\nabout a non-constant initializer, followed by complaints that the left\noperand must be a modifiable lvalue.\n\nI notice now that some functions have the 'struct option' and all of its\nparameters declared static. I think this would satisfy the compiler, but\nthen the options would not be reinitialized if the function was called\nagain. Or are cmd_*() functions defined to only ever be called once?\n\n-brandon\n"},{"id":"89027","messageId":"DvgiWt6vf5dOJWwhJg6Uvvb1c1lr9AZ9KS6iObwhTbjxnzKL45PkCw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"7vwsi0dh61.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2] dir.c: Avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-28T22:47:22Z","receivedAt":"2008-08-28T22:47:22Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The following syntax:\n\n        char foo[] = {\n                [0] = 1,\n                [7] = 2,\n                [15] = 3\n        };\n\nis a c99 construct which some compilers do not support even though they\nsupport other c99 constructs. This construct can be avoided by folding\nthese 'special' test cases into the sane_ctype array and making use of\nthe related infrastructure.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nJunio C Hamano wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n>> > I am reminded of a year old thread with my patch to this:\n>> >\n>> >   http://kerneltrap.org/mailarchive/git/2007/4/15/243541\n>> >\n>> > The patch never applied.  I wonder why.  Was it just Dscho's comment?\n> \n> I think it was an unanswered question about stealing one bit from\n> ctype.c::sane_ctype[] that kept the discussion in limbo.\n\nThat seems easy enough. Anybody got a 5 character abbreviation for special?\n\n-brandon\n\n\n ctype.c           |   10 ++++++----\n dir.c             |    7 +------\n git-compat-util.h |   16 +++++++++-------\n 3 files changed, 16 insertions(+), 17 deletions(-)\n\ndiff --git a/ctype.c b/ctype.c\nindex d2bd38e..acb5f0f 100644\n--- a/ctype.c\n+++ b/ctype.c\n@@ -9,18 +9,20 @@\n #undef SS\n #undef AA\n #undef DD\n+#undef GS\n \n #define SS GIT_SPACE\n #define AA GIT_ALPHA\n #define DD GIT_DIGIT\n+#define GS GIT_SPECIAL  /* \\0, *, ?, [, \\\\ */\n \n unsigned char sane_ctype[256] = {\n-\t 0,  0,  0,  0,  0,  0,  0,  0,  0, SS, SS,  0,  0, SS,  0,  0,\t\t/* 0-15 */\n+\tGS,  0,  0,  0,  0,  0,  0,  0,  0, SS, SS,  0,  0, SS,  0,  0,\t\t/* 0-15 */\n \t 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\t\t/* 16-15 */\n-\tSS,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\t\t/* 32-15 */\n-\tDD, DD, DD, DD, DD, DD, DD, DD, DD, DD,  0,  0,  0,  0,  0,  0,\t\t/* 48-15 */\n+\tSS,  0,  0,  0,  0,  0,  0,  0,  0,  0, GS,  0,  0,  0,  0,  0,\t\t/* 32-15 */\n+\tDD, DD, DD, DD, DD, DD, DD, DD, DD, DD,  0,  0,  0,  0,  0, GS,\t\t/* 48-15 */\n \t 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA,\t\t/* 64-15 */\n-\tAA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA,  0,  0,  0,  0,  0,\t\t/* 80-15 */\n+\tAA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, GS, GS,  0,  0,  0,\t\t/* 80-15 */\n \t 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA,\t\t/* 96-15 */\n \tAA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA,  0,  0,  0,  0,  0,\t\t/* 112-15 */\n \t/* Nothing in the 128.. range */\ndiff --git a/dir.c b/dir.c\nindex 92452eb..e6a2556 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n  */\n static int simple_length(const char *match)\n {\n-\tconst char special[256] = {\n-\t\t[0] = 1, ['?'] = 1,\n-\t\t['\\\\'] = 1, ['*'] = 1,\n-\t\t['['] = 1\n-\t};\n \tint len = -1;\n \n \tfor (;;) {\n \t\tunsigned char c = *match++;\n \t\tlen++;\n-\t\tif (special[c])\n+\t\tif (isspecial(c))\n \t\t\treturn len;\n \t}\n }\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 6ee3255..ac22409 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -326,14 +326,16 @@ static inline int has_extension(const char *filename, const char *ext)\n #undef tolower\n #undef toupper\n extern unsigned char sane_ctype[256];\n-#define GIT_SPACE 0x01\n-#define GIT_DIGIT 0x02\n-#define GIT_ALPHA 0x04\n+#define GIT_SPACE   0x01\n+#define GIT_DIGIT   0x02\n+#define GIT_ALPHA   0x04\n+#define GIT_SPECIAL 0x08\n #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)\n-#define isspace(x) sane_istest(x,GIT_SPACE)\n-#define isdigit(x) sane_istest(x,GIT_DIGIT)\n-#define isalpha(x) sane_istest(x,GIT_ALPHA)\n-#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)\n+#define isspace(x)   sane_istest(x,GIT_SPACE)\n+#define isdigit(x)   sane_istest(x,GIT_DIGIT)\n+#define isalpha(x)   sane_istest(x,GIT_ALPHA)\n+#define isalnum(x)   sane_istest(x,GIT_ALPHA | GIT_DIGIT)\n+#define isspecial(x) sane_istest(x,GIT_SPECIAL)\n #define tolower(x) sane_case((unsigned char)(x), 0x20)\n #define toupper(x) sane_case((unsigned char)(x), 0)\n \n-- \n1.6.0.21.g35a2e\n"},{"id":"89028","messageId":"81b0412b0808281556x24fe1446l738310daf74d619f@mail.gmail.com","threadId":"15077","inReplyTo":"DvgiWt6vf5dOJWwhJg6Uvvb1c1lr9AZ9KS6iObwhTbjxnzKL45PkCw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2] dir.c: Avoid c99 array initialization","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-28T22:56:19Z","receivedAt":"2008-08-28T22:56:19Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/8/29 Brandon Casey <casey@nrlssc.navy.mil>:\n>>\n>> I think it was an unanswered question about stealing one bit from\n>> ctype.c::sane_ctype[] that kept the discussion in limbo.\n>\n> That seems easy enough. Anybody got a 5 character abbreviation for special?\n>\n\nSPECL :)\n"},{"id":"89032","messageId":"PoNr7CsqaC77b7na-0n9ocrQHgIwPZQYjCwhtbz7ydhXjU05wVKI5w@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"DvgiWt6vf5dOJWwhJg6Uvvb1c1lr9AZ9KS6iObwhTbjxnzKL45PkCw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2] dir.c: Avoid c99 array initialization","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-08-28T23:03:53Z","receivedAt":"2008-08-28T23:03:53Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n> The following syntax:\n> \n>         char foo[] = {\n>                 [0] = 1,\n>                 [7] = 2,\n>                 [15] = 3\n>         };\n> \n> is a c99 construct which some compilers do not support even though they\n> support other c99 constructs. This construct can be avoided by folding\n> these 'special' test cases into the sane_ctype array and making use of\n> the related infrastructure.\n\nYou probably would want to squash this in:\n\ndiff --git a/dir.c b/dir.c\nindex e6a2556..acf1001 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -52,11 +52,6 @@ int common_prefix(const char **pathspec)\n\treturn prefix;\n }\n \n-static inline int special_char(unsigned char c1)\n-{\n-\treturn !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\\\';\n-}\n-\n /*\n  * Does 'match' matches the given name?\n  * A match is found if\n@@ -80,7 +75,7 @@ static int match_one(const char *match, const char *name, int \n \tfor (;;) {\n \t\tunsigned char c1 = *match;\n \t\tunsigned char c2 = *name;\n-\t\tif (special_char(c1))\n+\t\tif (isspecial(c1))\n \t\t\tbreak;\n \t\tif (c1 != c2)\n \t\t\treturn 0;\n"},{"id":"89119","messageId":"alpine.DEB.1.00.0808291306420.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15077","inReplyTo":"20080828201657.GH21072@spearce.org","subject":"Re: [PATCH] dir.c: avoid c99 array initialization","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-29T11:08:13Z","receivedAt":"2008-08-29T11:08:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 28 Aug 2008, Shawn O. Pearce wrote:\n\n> Alex Riesen <raa.lkml@gmail.com> wrote:\n> > \n> > For just these 5 values it is likely more effective to just use\n> > a conditional statement (less stack requested, less likely\n> > some stupid compiler tries to optimize it wrongly).\n> > And just as readable.\n> > \n> > diff --git a/dir.c b/dir.c\n> > index 92452eb..1cf5985 100644\n> > --- a/dir.c\n> > +++ b/dir.c\n> > @@ -680,17 +680,12 @@ static int cmp_name(const void *p1, const void *p2)\n> >   */\n> >  static int simple_length(const char *match)\n> >  {\n> > -\tconst char special[256] = {\n> > -\t\t[0] = 1, ['?'] = 1,\n> > -\t\t['\\\\'] = 1, ['*'] = 1,\n> > -\t\t['['] = 1\n> > -\t};\n> >  \tint len = -1;\n> > \n> >  \tfor (;;) {\n> >  \t\tunsigned char c = *match++;\n> >  \t\tlen++;\n> > -\t\tif (special[c])\n> > +\t\tif (!c || '?' == c || '\\\\' == c || '*' == c || '[' == c)\n> \n> I am reminded of a year old thread with my patch to this:\n> \n>   http://kerneltrap.org/mailarchive/git/2007/4/15/243541\n> \n> The patch never applied.  I wonder why.  Was it just Dscho's comment?\n\nIf it was, I am very sorry.\n\nBut I still think that a lookup for something that is called potentially a \nmillion times per second is better than a switch statement (except when \nthere are less than, say, 4 cases).\n\nCiao,\nDscho\n"},{"id":"90731","messageId":"48CE4CFE.1010106@statsbiblioteket.dk","threadId":"15077","inReplyTo":"iZMIxnwnUBIGAGz2GMS0uwCvMMo9aaYd2Arx4fbxk9NusvUC5LUNVg@cipher.nrlssc.navy.mil","subject":"Re: [PATCH FYI] t9700/test.pl: backwards compatibility improvements","fromName":"Tom G. Christensen","fromEmail":"tgc@statsbiblioteket.dk","sentAt":"2008-09-15T11:54:38Z","receivedAt":"2008-09-15T11:54:38Z","isPatch":true,"sender":{"key":"tgc@statsbiblioteket.dk","avatar":"https://avatars.githubusercontent.com/u/912180?v=4"},"body":"Brandon Casey wrote:\n> Some versions of perl complain when 'STDERR' is used as the third argument\n> in the 3-argument form of open(). Convert to the 2-argument form which is\n> described for duping STDERR in my second edition camel book.\n> \n> The object oriented version of File::Temp is a rather new incarnation it\n> seems. The File::Temp man page for v5.8.0 says \"(NOT YET IMPLEMENTED)\" in\n> the 'Objects' section. These can be converted to use File::Temp::tempfile().\n> \n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n >\nTested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>\n\nWithout this patch the testsuite will fail with perl 5.8.0:\nt9700$ ./test.pl\nok 1 - use Git;\nBareword \"STDERR\" not allowed while \"strict subs\" in use at ./test.pl \nline 41.\nExecution of ./test.pl aborted due to compilation errors.\n1..1\n# Looks like your test died just after 1.\n\n\nCould we please get this patch in?\n\n-tgc\n"},{"id":"90746","messageId":"ryvGcG_Sg9kftPIp7uWA1JVCd0inSiqB61VnfUuxRUZJg6W7SWhmOQ@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"48CE4CFE.1010106@statsbiblioteket.dk","subject":"Re: [PATCH FYI] t9700/test.pl: backwards compatibility improvements","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-15T16:20:08Z","receivedAt":"2008-09-15T16:20:08Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Tom G. Christensen wrote:\n> Brandon Casey wrote:\n>> Some versions of perl complain when 'STDERR' is used as the third\n>> argument\n>> in the 3-argument form of open(). Convert to the 2-argument form which is\n>> described for duping STDERR in my second edition camel book.\n>>\n>> The object oriented version of File::Temp is a rather new incarnation it\n>> seems. The File::Temp man page for v5.8.0 says \"(NOT YET IMPLEMENTED)\" in\n>> the 'Objects' section. These can be converted to use\n>> File::Temp::tempfile().\n>>\n>> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n>>\n> Tested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>\n> \n> Without this patch the testsuite will fail with perl 5.8.0:\n> t9700$ ./test.pl\n> ok 1 - use Git;\n> Bareword \"STDERR\" not allowed while \"strict subs\" in use at ./test.pl\n> line 41.\n> Execution of ./test.pl aborted due to compilation errors.\n> 1..1\n> # Looks like your test died just after 1.\n> \n> \n> Could we please get this patch in?\n\nJunio had asked me to follow up on that patch at a later time, so\nthanks for prodding.\n\nHere is an alternative which _removes_ the File::Temp requirement.\n\n-brandon\n"},{"id":"90747","messageId":"T5Id5zYBlKyKEhZkMsE3QTI2aU3XMiwpfpsPq89cvXrakbyGShLtQw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"48CE4CFE.1010106@statsbiblioteket.dk","subject":"[PATCH 1/3] t9700/test.pl: no longer requires File::Basename","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-15T16:20:54Z","receivedAt":"2008-09-15T16:20:54Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Since ff30fff3 removed the call to basename(), we don't need to\n'use File::Basename'.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t9700/test.pl |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex 851cea4..732133e 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -8,7 +8,6 @@ use strict;\n use Test::More qw(no_plan);\n \n use Cwd;\n-use File::Basename;\n use File::Temp;\n \n BEGIN { use_ok('Git') }\n-- \n1.6.0.1.244.gdc19\n"},{"id":"90748","messageId":"uWiPWIPu6IKkVafz9wdZ-sRK84QZuJQNOZM80bkfw24NxsVT-Z3J9g@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"T5Id5zYBlKyKEhZkMsE3QTI2aU3XMiwpfpsPq89cvXrakbyGShLtQw@cipher.nrlssc.navy.mil","subject":"[PATCH 2/3] t9700/test.pl: avoid bareword 'STDERR' in 3-argument open()","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-15T16:23:24Z","receivedAt":"2008-09-15T16:23:24Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Some versions of perl complain when 'STDERR' is used as the third argument\nin the 3-argument form of open(). Convert to the 2-argument form which is\ndescribed for duping STDERR in my second edition camel book.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t9700/test.pl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex 732133e..f777b08 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -34,7 +34,7 @@ is($r->get_color(\"color.test.slot1\", \"red\"), $ansi_green, \"get_color\");\n # Failure cases for config:\n # Save and restore STDERR; we will probably extract this into a\n # \"dies_ok\" method and possibly move the STDERR handling to Git.pm.\n-open our $tmpstderr, \">&\", STDERR or die \"cannot save STDERR\"; close STDERR;\n+open our $tmpstderr, \">&STDERR\" or die \"cannot save STDERR\"; close STDERR;\n eval { $r->config(\"test.dupstring\") };\n ok($@, \"config: duplicate entry in scalar context fails\");\n eval { $r->config_bool(\"test.boolother\") };\n-- \n1.6.0.1.244.gdc19\n"},{"id":"90749","messageId":"dQSOPLs4uHkUBp4B1ZT4QbBf2xm6SluHuVl0M4fikzSgHUtgDcJXiQ@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"uWiPWIPu6IKkVafz9wdZ-sRK84QZuJQNOZM80bkfw24NxsVT-Z3J9g@cipher.nrlssc.navy.mil","subject":"[PATCH 3/3] t9700/test.pl: remove File::Temp requirement","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-15T16:25:22Z","receivedAt":"2008-09-15T16:25:22Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The object oriented version of File::Temp is a rather new incarnation it\nseems. The File::Temp man page for v5.8.0 says \"(NOT YET IMPLEMENTED)\" in\nthe 'Objects' section. Instead of creating a file with a unique name in\nthe system TMPDIR, we can create our own temporary file with a static\nname and use that instead.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t9700/test.pl |   23 +++++++++++++----------\n 1 files changed, 13 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex f777b08..9908109 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -8,7 +8,6 @@ use strict;\n use Test::More qw(no_plan);\n \n use Cwd;\n-use File::Temp;\n \n BEGIN { use_ok('Git') }\n \n@@ -65,21 +64,25 @@ is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n \n # objects and hashes\n ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n-our $tmpfile = File::Temp->new;\n-is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n+my $tmpfile = \"file.tmp\";\n+open TEMPFILE, \"+>$tmpfile\" or die \"Can't open $tmpfile: $!\";\n+is($r->cat_blob($file1hash, \\*TEMPFILE), 15, \"cat_blob: size\");\n our $blobcontents;\n-{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; }\n is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n-seek $tmpfile, 0, 0;\n+close TEMPFILE or die \"Failed writing to $tmpfile: $!\";\n is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n-$tmpfile = File::Temp->new();\n-print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n+open TEMPFILE, \">$tmpfile\" or die \"Can't open $tmpfile: $!\";\n+print TEMPFILE my $test_text = \"test blob, to be inserted\\n\";\n+close TEMPFILE or die \"Failed writing to $tmpfile: $!\";\n like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n      \"hash_and_insert_object: returns hash\");\n-$tmpfile = File::Temp->new;\n-is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n-{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+open TEMPFILE, \"+>$tmpfile\" or die \"Can't open $tmpfile: $!\";\n+is($r->cat_blob($newhash, \\*TEMPFILE), length $test_text, \"cat_blob: roundtrip size\");\n+{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; }\n is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n+close TEMPFILE;\n+unlink $tmpfile;\n \n # paths\n is($r->repo_path, \"./.git\", \"repo_path\");\n-- \n1.6.0.1.244.gdc19\n"},{"id":"90752","messageId":"09qgg4unycS30_7pwn2Wta9qvq_AZfJtOulxZ777VMoGd1_s7A5ikw@cipher.nrlssc.navy.mil","threadId":"15077","inReplyTo":"ryvGcG_Sg9kftPIp7uWA1JVCd0inSiqB61VnfUuxRUZJg6W7SWhmOQ@cipher.nrlssc.navy.mil","subject":"Re: [PATCH FYI] t9700/test.pl: backwards compatibility improvements","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-15T16:32:52Z","receivedAt":"2008-09-15T16:32:52Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n> Tom G. Christensen wrote:\n\n>> Tested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>\n\n> Here is an alternative which _removes_ the File::Temp requirement.\n\nA Tested-by for this new series would be appreciated.\n\n-brandon\n"},{"id":"90758","messageId":"48CEA916.9000103@statsbiblioteket.dk","threadId":"15077","inReplyTo":"dQSOPLs4uHkUBp4B1ZT4QbBf2xm6SluHuVl0M4fikzSgHUtgDcJXiQ@cipher.nrlssc.navy.mil","subject":"Re: [PATCH 3/3] t9700/test.pl: remove File::Temp requirement","fromName":"Tom G. Christensen","fromEmail":"tgc@statsbiblioteket.dk","sentAt":"2008-09-15T18:27:34Z","receivedAt":"2008-09-15T18:27:34Z","isPatch":true,"sender":{"key":"tgc@statsbiblioteket.dk","avatar":"https://avatars.githubusercontent.com/u/912180?v=4"},"body":"Brandon Casey wrote:\n> The object oriented version of File::Temp is a rather new incarnation it\n> seems. The File::Temp man page for v5.8.0 says \"(NOT YET IMPLEMENTED)\" in\n> the 'Objects' section. Instead of creating a file with a unique name in\n> the system TMPDIR, we can create our own temporary file with a static\n> name and use that instead.\n> \n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n >\nTested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>\n\nI applied all three patches and ran the testsuite with perl 5.8.0 \n(RHEL3). It now passes t9700 and runs to completion as expected.\n\n-tgc\n"}]}