Changeset: b702080d4d99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b702080d4d99
Removed Files:
common/utils/mstring.c
Modified Files:
clients/examples/C/Makefile.ag
clients/mapiclient/Makefile.ag
clients/odbc/driver/Makefile.ag
clients/odbc/setup/Makefile.ag
common/utils/Makefile.ag
common/utils/mstring.h
Branch: default
Log Message:
Turn functions str{cpy,concat}_len into static inline functions.
This makes it a log easier to compile (and link) on Windows.
diffs (163 lines):
diff --git a/clients/examples/C/Makefile.ag b/clients/examples/C/Makefile.ag
--- a/clients/examples/C/Makefile.ag
+++ b/clients/examples/C/Makefile.ag
@@ -14,6 +14,5 @@ BINS = {
smack00.c smack01.c
LIBS = ../../mapilib/libmapi \
../../../common/stream/libstream \
- ../../../common/utils/libmutils \
$(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
}
diff --git a/clients/mapiclient/Makefile.ag b/clients/mapiclient/Makefile.ag
--- a/clients/mapiclient/Makefile.ag
+++ b/clients/mapiclient/Makefile.ag
@@ -52,9 +52,9 @@ bin_tachograph = {
bin_tomograph = {
SOURCES = tomograph.c
LIBS = libmcutil \
+ ../../common/utils/libmutils \
../mapilib/libmapi \
../../common/stream/libstream \
- ../../common/utils/libmutils \
$(SOCKET_LIBS) $(zlib_LIBS) $(bzip2_LIBS) $(snappy_LIBS)
$(lz4_LIBS) $(liblzma_LIBS) $(curl_LIBS) $(LTLIBICONV) $(openssl_LIBS)
}
diff --git a/clients/odbc/driver/Makefile.ag b/clients/odbc/driver/Makefile.ag
--- a/clients/odbc/driver/Makefile.ag
+++ b/clients/odbc/driver/Makefile.ag
@@ -107,7 +107,7 @@ lib_MonetODBC = {
SQLTransact.c \
driver.rc \
ODBC.syms
- LIBS = ../../mapilib/libmapi ../../../common/stream/libstream
../../../common/utils/libmutils $(LTLIBICONV) $(ODBCINST_LIBS) $(SOCKET_LIBS)
$(openssl_LIBS)
+ LIBS = ../../mapilib/libmapi ../../../common/stream/libstream
$(LTLIBICONV) $(ODBCINST_LIBS) $(SOCKET_LIBS) $(openssl_LIBS)
}
EXTRA_DIST = Copyright
diff --git a/clients/odbc/setup/Makefile.ag b/clients/odbc/setup/Makefile.ag
--- a/clients/odbc/setup/Makefile.ag
+++ b/clients/odbc/setup/Makefile.ag
@@ -10,6 +10,5 @@ INCLUDES = $(ODBC_INCS) ../../../common/
lib_MonetODBCs = {
MODULE
- LIBS = ../../../common/utils/libmutils
SOURCES = drvcfg.c drvcfg.h
}
diff --git a/common/utils/Makefile.ag b/common/utils/Makefile.ag
--- a/common/utils/Makefile.ag
+++ b/common/utils/Makefile.ag
@@ -20,7 +20,7 @@ headers_h = {
lib_mutils = {
NOINST
- SOURCES = mutils.h mutils.c prompt.c mprompt.h revision.c mstring.h
mstring.c
+ SOURCES = mutils.h mutils.c prompt.c mprompt.h revision.c mstring.h
}
lib_mcrypt = {
diff --git a/common/utils/mstring.c b/common/utils/mstring.c
deleted file mode 100644
--- a/common/utils/mstring.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
- */
-
-#include "monetdb_config.h"
-#include <string.h>
-#include "mstring.h"
-
-/* copy at most (n-1) bytes from src to dst and add a terminating NULL
- * byte; return length of src (i.e. can be more than what is copied) */
-size_t
-strcpy_len(char *restrict dst, const char *restrict src, size_t n)
-{
- size_t i = 0;
- if (dst) {
- while (i < n) {
- if ((dst[i] = src[i]) == 0)
- return i;
- i++;
- }
- if (i > 0)
- dst[i - 1] = 0;
- }
- return i + strlen(src + i);
-}
-
-/* copy the NULL terminated list of src strings with a maximum of n
- * bytes to dst; return the combined length of the src strings */
-size_t
-strconcat_len(char *restrict dst, size_t n, const char *restrict src, ...)
-{
- va_list ap;
- size_t i = 0;
-
- va_start(ap, src);
- while (src) {
- size_t l;
- if (dst && i < n)
- l = strcpy_len(dst + i, src, n - i);
- else
- l = strlen(src);
- i += l;
- src = va_arg(ap, const char *);
- }
- va_end(ap);
- return i;
-}
diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -6,5 +6,43 @@
* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
*/
-size_t strcpy_len(char *restrict dst, const char *restrict src, size_t n);
-size_t strconcat_len(char *restrict dst, size_t n, const char *restrict src,
...);
+
+/* copy at most (n-1) bytes from src to dst and add a terminating NULL
+ * byte; return length of src (i.e. can be more than what is copied) */
+static inline size_t
+strcpy_len(char *restrict dst, const char *restrict src, size_t n)
+{
+ size_t i = 0;
+ if (dst) {
+ while (i < n) {
+ if ((dst[i] = src[i]) == 0)
+ return i;
+ i++;
+ }
+ if (i > 0)
+ dst[i - 1] = 0;
+ }
+ return i + strlen(src + i);
+}
+
+/* copy the NULL terminated list of src strings with a maximum of n
+ * bytes to dst; return the combined length of the src strings */
+static inline size_t
+strconcat_len(char *restrict dst, size_t n, const char *restrict src, ...)
+{
+ va_list ap;
+ size_t i = 0;
+
+ va_start(ap, src);
+ while (src) {
+ size_t l;
+ if (dst && i < n)
+ l = strcpy_len(dst + i, src, n - i);
+ else
+ l = strlen(src);
+ i += l;
+ src = va_arg(ap, const char *);
+ }
+ va_end(ap);
+ return i;
+}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list