Git development
 help / color / mirror / Atom feed
* [PATCH] progress.c: avoid use of dynamic-sized array
@ 2008-06-08 15:26 Boyd Lynn Gerber
  2008-06-08 19:30 ` Johannes Schindelin
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Boyd Lynn Gerber @ 2008-06-08 15:26 UTC (permalink / raw)
  To: Git List


Dynamically sized arrays are gcc and C99 construct.  Using them hurts
portability to older compilers, although using them is nice in this case
it is not desirable.  This patch removes the only use of the construct
in stop_progress_msg(); the function is about writing out a single line
of a message, and the existing callers of this function feed messages
of only bounded size anyway, so use of dynamic array is simply overkill.

Signed-off-by: Boyd Lynn Gerber <gerberb@zenez.com>

--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047

---
        Developer's Certificate of Origin 1.1

        By making a contribution to this project, I certify that:

        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or

        (b) The contribution is based upon previous work that, to the best
            of my knowledge, is covered under an appropriate open source
            license and I have the right under that license to submit that
            work with modifications, whether created in whole or in part
            by me, under the same open source license (unless I am
            permitted to submit under a different license), as indicated
            in the file; or

        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.

        (d) I understand and agree that this project and the contribution
            are public and that a record of the contribution (including all
            personal information I submit with it, including my sign-off) is
            maintained indefinitely and may be redistributed consistent with
            this project or the open source license(s) involved.

---
progress.c

diff --git a/progress.c b/progress.c
index d19f80c..55a8687 100644
--- a/progress.c
+++ b/progress.c
@@ -241,16 +241,21 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
 	*p_progress = NULL;
 	if (progress->last_value != -1) {
 		/* Force the last update */
-		char buf[strlen(msg) + 5];
+		char buf[128], *bufp;
+		size_t len = strlen(msg) + 5;
 		struct throughput *tp = progress->throughput;
+
+		bufp = (len < sizeof(buf)) ? buf : xmalloc(len + 1);
 		if (tp) {
 			unsigned int rate = !tp->avg_misecs ? 0 :
 					tp->avg_bytes / tp->avg_misecs;
 			throughput_string(tp, tp->curr_total, rate);
 		}
 		progress_update = 1;
-		sprintf(buf, ", %s.\n", msg);
-		display(progress, progress->last_value, buf);
+		sprintf(bufp, ", %s.\n", msg);
+		display(progress, progress->last_value, bufp);
+		if (buf != bufp)
+			free(bufp);
 	}
 	clear_progress_signal();
 	free(progress->throughput);
-- 
1.5.2.4


--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH] Port to 12 other Platforms.
@ 2008-06-08 15:28 Boyd Lynn Gerber
  2008-06-08 15:46 ` Jakub Narebski
  0 siblings, 1 reply; 9+ messages in thread
From: Boyd Lynn Gerber @ 2008-06-08 15:28 UTC (permalink / raw)
  To: Git List


This patch adds support to compile git on 12 additional platforms.
They are based on UNIX Systems Labs (USL)/Novell and SYS V
based OS's, SCO OpenServer 5.0.X, SCO UnixWare 7.1.4, OpenServer 6.0.X and
SCO pre OSR 5 OS's to build and run git.

Signed-off-by: Boyd Lynn Gerber <gerberb@zenez.com>

--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047

---
        Developer's Certificate of Origin 1.1

        By making a contribution to this project, I certify that:

        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or

        (b) The contribution is based upon previous work that, to the best
            of my knowledge, is covered under an appropriate open source
            license and I have the right under that license to submit that
            work with modifications, whether created in whole or in part
            by me, under the same open source license (unless I am
            permitted to submit under a different license), as indicated
            in the file; or

        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.

        (d) I understand and agree that this project and the contribution
            are public and that a record of the contribution (including all
            personal information I submit with it, including my sign-off) is
            maintained indefinitely and may be redistributed consistent with
            this project or the open source license(s) involved.

---
Makefile

Add changes for System V, UnixWare, SCO OS's

---
git-compat-util.h

__USLC__ indicates UNIX System Labs Corperation (USLC), or a Novell-derived
compiler and/or some SysV based OS's.

__M_UNIX indicates XENIX/SCO UNIX/OpenServer 5.0.7 and prior releases
of the SCO OS's.  It is used just like Apple and BSD, both of these
shouldn't have _XOPEN_SOURCE defined.

diff --git a/Makefile b/Makefile
index cce5a6e..026de2f 100644
--- a/Makefile
+++ b/Makefile
@@ -564,6 +564,45 @@ endif
 ifeq ($(uname_S),GNU/kFreeBSD)
 	NO_STRLCPY = YesPlease
 endif
+ifeq ($(uname_S),UnixWare)
+	CC=cc
+	NEEDS_SOCKET = YesPlease
+	NEEDS_NSL = YesPlease
+	NEEDS_SSL_WITH_CRYPTO = YesPlease
+	NEEDS_LIBICONV = YesPlease
+	SHELL_PATH = /usr/local/bin/bash
+	NO_IPV6 = YesPlease
+	NO_HSTRERROR = YesPlease
+	BASIC_CFLAGS += -Kthread
+	BASIC_CFLAGS += -I/usr/local/include
+	BASIC_LDFLAGS += -L/usr/local/lib
+	INSTALL = ginstall
+	TAR = gtar
+	NO_STRCASESTR = YesPlease
+	NO_MEMMEM = YesPlease
+endif
+ifeq ($(uname_S),SCO_SV)
+	ifeq ($(uname_R),3.2)
+		CFLAGS = -O2
+	endif
+	ifeq ($(uname_R),5)
+		CC=cc
+		BASIC_CFLAGS += -Kthread
+	endif
+	NEEDS_SOCKET = YesPlease
+	NEEDS_NSL = YesPlease
+	NEEDS_SSL_WITH_CRYPTO = YesPlease
+	NEEDS_LIBICONV = YesPlease
+	SHELL_PATH = /usr/bin/bash
+	NO_IPV6 = YesPlease
+	NO_HSTRERROR = YesPlease
+	BASIC_CFLAGS += -I/usr/local/include
+	BASIC_LDFLAGS += -L/usr/local/lib
+	NO_STRCASESTR = YesPlease
+	NO_MEMMEM = YesPlease
+	INSTALL = ginstall
+	TAR = gtar
+endif
 ifeq ($(uname_S),Darwin)
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
diff --git a/git-compat-util.h b/git-compat-util.h
index 01c4045..c04e8ba 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -39,7 +39,7 @@
 /* Approximation of the length of the decimal representation of this type. */
 #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
 
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
-- 
1.5.2.4


--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH] This patch is to allow 12 different OS's to compile and run git.
@ 2008-06-06 19:34 Boyd Lynn Gerber
  2008-06-06 19:39 ` Jeremy Maitin-Shepard
  0 siblings, 1 reply; 9+ messages in thread
From: Boyd Lynn Gerber @ 2008-06-06 19:34 UTC (permalink / raw)
  To: Git List

This patch has patches to

Makefile
git-compat-util.h
progress.c

This patch allows some older OS's, SCO OpenServer 5.0.X, SCO UnixWare 7.1.4,
and OpenServer 6.0.X to build and run git.

        Developer's Certificate of Origin 1.1

        By making a contribution to this project, I certify that:

        (a) The contribution was created in whole or in part by me and I
            have the right to submit it under the open source license
            indicated in the file; or

        (b) The contribution is based upon previous work that, to the best
            of my knowledge, is covered under an appropriate open source
            license and I have the right under that license to submit that
            work with modifications, whether created in whole or in part
            by me, under the same open source license (unless I am
            permitted to submit under a different license), as indicated
            in the file; or

        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.

	(d) I understand and agree that this project and the contribution
	    are public and that a record of the contribution (including all
	    personal information I submit with it, including my sign-off) is
	    maintained indefinitely and may be redistributed consistent with
	    this project or the open source license(s) involved.

Signed-off-by: Boyd Lynn Gerber <gerberb@zenez.com>

--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047


diff --git a/Makefile b/Makefile
index cce5a6e..6df008a 100644
--- a/Makefile
+++ b/Makefile
@@ -165,6 +165,20 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 CFLAGS = -g -O2 -Wall
+ifeq ($(uname_S),SCO_SV)
+  ifeq ($(uname_R),3.2)
+#    CFLAGS = -g -O2
+    CFLAGS = -g
+  endif
+  ifeq ($(uname_R),5)
+    CFLAGS = -g -O2 -Wall
+#    CFLAGS = -g -O2
+  endif
+endif
+ifeq ($(uname_S),UnixWare)
+    CFLAGS = -g -O2 -Wall
+#    CFLAGS = -g -O2
+endif
 LDFLAGS =
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
@@ -207,7 +221,8 @@ GITWEB_SITE_FOOTER =
 
 export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir
 
-CC = gcc
+#CC = gcc
+CC = "cc"
 AR = ar
 RM = rm -f
 TAR = tar
@@ -564,6 +579,42 @@ endif
 ifeq ($(uname_S),GNU/kFreeBSD)
 	NO_STRLCPY = YesPlease
 endif
+ifeq ($(uname_S),UnixWare)
+	NEEDS_SOCKET = YesPlease
+#	NEEDS_NSL = YesPlease
+	NEEDS_SSL_WITH_CRYPTO = YesPlease
+	NEEDS_LIBICONV = YesPlease
+	SHELL_PATH = /usr/local/bin/bash
+	NO_IPV6 = YesPlease
+	NO_HSTRERROR = YesPlease
+#	BASIC_CFLAGS +=  -E -H
+	BASIC_CFLAGS +=  -Kalloca -Kthread
+	BASIC_CFLAGS += -I/usr/local/include
+	BASIC_LDFLAGS += -L/usr/local/lib
+	INSTALL = ginstall
+	TAR = gtar
+	NO_STRCASESTR = YesPlease
+	NO_MEMMEM = YesPlease
+endif
+ifeq ($(uname_S),SCO_SV)
+	NEEDS_SOCKET = YesPlease
+#	NEEDS_NSL = YesPlease
+	NEEDS_SSL_WITH_CRYPTO = YesPlease
+	NEEDS_LIBICONV = YesPlease
+	SHELL_PATH = /usr/bin/bash
+	NO_IPV6 = YesPlease
+#	NO_HSTRERROR = YesPlease
+#	BASIC_CFLAGS +=  -E -H
+      ifeq ($(uname_R),5)
+	BASIC_CFLAGS +=  -Kalloca -Kthread
+      endif
+#	BASIC_CFLAGS += -I/usr/local/include
+#	BASIC_LDFLAGS += -L/usr/local/lib
+	NO_STRCASESTR = YesPlease
+	NO_MEMMEM = YesPlease
+	INSTALL = ginstall
+	TAR = gtar
+endif
 ifeq ($(uname_S),Darwin)
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
diff --git a/git-compat-util.h b/git-compat-util.h
index 01c4045..b57041c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -39,7 +39,7 @@
 /* Approximation of the length of the decimal representation of this type. */
 #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
 
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__ ) && !defined(__USLC__) && !defined(_M_UNIX)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
@@ -89,6 +89,10 @@
 #include <grp.h>
 #define _ALL_SOURCE 1
 #endif
+#if defined(__USLC__)
+#undef _XOPEN_SOURCE
+#include <grp.h>
+#endif
 
 #ifndef NO_ICONV
 #include <iconv.h>
@@ -206,12 +210,15 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
 #endif
 
 #ifdef FREAD_READS_DIRECTORIES
+#if !defined (__USLC__)
 #ifdef fopen
 #undef fopen
 #endif
 #define fopen(a,b) git_fopen(a,b)
 extern FILE *git_fopen(const char*, const char*);
 #endif
+#endif
+#endif
 
 #ifdef SNPRINTF_RETURNS_BOGUS
 #define snprintf git_snprintf
diff --git a/progress.c b/progress.c
index d19f80c..11a0841 100644
--- a/progress.c
+++ b/progress.c
@@ -241,7 +241,8 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
 	*p_progress = NULL;
 	if (progress->last_value != -1) {
 		/* Force the last update */
-		char buf[strlen(msg) + 5];
+		/* char buf[strlen(msg) + 5]; */
+		char *buf = malloc (strlen(msg) + 5 );
 		struct throughput *tp = progress->throughput;
 		if (tp) {
 			unsigned int rate = !tp->avg_misecs ? 0 :
-- 
1.5.2.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-06-08 22:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-08 15:26 [PATCH] progress.c: avoid use of dynamic-sized array Boyd Lynn Gerber
2008-06-08 19:30 ` Johannes Schindelin
2008-06-08 19:52   ` Boyd Lynn Gerber
2008-06-08 21:34 ` Alex Riesen
2008-06-08 21:50 ` しらいしななこ
2008-06-08 22:02   ` Junio C Hamano
     [not found] ` <200806082151.m58Lp6sH014324@mi0.bluebottle.com>
2008-06-08 21:53   ` Boyd Lynn Gerber
  -- strict thread matches above, loose matches on Subject: below --
2008-06-08 15:28 [PATCH] Port to 12 other Platforms Boyd Lynn Gerber
2008-06-08 15:46 ` Jakub Narebski
2008-06-08 16:04   ` Boyd Lynn Gerber
2008-06-08 18:52     ` Junio C Hamano
2008-06-08 20:47       ` Boyd Lynn Gerber
2008-06-08 21:19         ` Junio C Hamano
2008-06-08 21:37           ` [PATCH] progress.c: avoid use of dynamic-sized array Boyd Lynn Gerber
2008-06-06 19:34 [PATCH] This patch is to allow 12 different OS's to compile and run git Boyd Lynn Gerber
2008-06-06 19:39 ` Jeremy Maitin-Shepard
2008-06-06 20:02   ` Boyd Lynn Gerber
2008-06-06 23:08     ` Junio C Hamano
2008-06-06 23:23       ` Boyd Lynn Gerber
2008-06-07  0:38         ` [PATCH] 0002 " Boyd Lynn Gerber
2008-06-07  0:47           ` Daniel Barkalow
2008-06-07  1:25             ` [PATCH] 0003 " Boyd Lynn Gerber
2008-06-07  2:12               ` Junio C Hamano
2008-06-07  2:40                 ` Boyd Lynn Gerber
2008-06-07  3:40                   ` Daniel Barkalow
2008-06-08  3:46                     ` Boyd Lynn Gerber
2008-06-08  7:45                       ` Junio C Hamano
2008-06-08 16:57                         ` [PATCH] progress.c: avoid use of dynamic-sized array Boyd Lynn Gerber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox