Julius Pfrommer лет назад: 8
Родитель
Сommit
f828edd2a0
2 измененных файлов с 11 добавлено и 21 удалено
  1. 6 7
      deps/libc_string.c
  2. 5 14
      tools/amalgamate.py

+ 6 - 7
deps/libc_string.c

@@ -6,15 +6,15 @@
 #include "ua_config.h"
 
 void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n) {
-	unsigned char *d = dest;
-	const unsigned char *s = src;
-	while(n--)
+    unsigned char *d = dest;
+    const unsigned char *s = src;
+    while(n--)
         *d++ = *s++;
-	return dest;
+    return dest;
 }
 
 void *memset(void *dest, int c, size_t n) {
-    unsigned char c8 = n;
+    unsigned char c8 = (unsigned char)c;
     unsigned char *target = dest;
     while(n--)
         *target++ = c8;
@@ -23,8 +23,7 @@ void *memset(void *dest, int c, size_t n) {
 
 size_t strlen(const char *str) {
     size_t len = 0;
-    for(const char *s = str; *s; s++)
-        len += 1;
+    for(const char *s = str; *s; s++, len++);
     return len;
 }
 

+ 5 - 14
tools/amalgamate.py

@@ -24,12 +24,12 @@ includes = []
 print ("Starting amalgamating file "+ args.outfile)
 
 file = io.open(args.outfile, 'w')
-file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES 
+file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES
  * visit http://open62541.org/ for information about this software
  * Git-Revision: %s
  */
- 
- /*
+
+/*
  * Copyright (C) 2015 the contributors as stated in the AUTHORS file
  *
  * This file is part of open62541. open62541 is free software: you can
@@ -42,8 +42,7 @@ file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN6
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * details.
- */\n\n
- """ % args.version)
+ */\n\n""" % args.version)
 
 if not is_c:
     file.write(u'''#ifndef %s
@@ -51,20 +50,12 @@ if not is_c:
 
 #ifdef __cplusplus
 extern "C" {
-#endif\n\n''' % (outname.upper() + u"_H_", outname.upper() + u"_H_") )
+#endif\n''' % (outname.upper() + u"_H_", outname.upper() + u"_H_") )
 
 if not is_c:
     for inc in includes:
         file.write(u"#include " + inc + "\n")
 else:
-    file.write(u'''#ifndef UA_DYNAMIC_LINKING
-# define UA_DYNAMIC_LINKING
-#endif
-
-#ifndef UA_INTERNAL
-#define UA_INTERNAL
-#endif
-\n''')
     file.write(u"#include \"" + outname + ".h\"\n")
 
 for fname in args.inputs: