hewei.it 5 лет назад
Родитель
Сommit
18b75e4fc3
7 измененных файлов с 13 добавлено и 15 удалено
  1. 1 2
      Makefile
  2. 3 4
      base/hdir.cpp
  3. 1 1
      docs/apis.md
  4. 1 1
      examples/hmain_test.cpp
  5. 2 2
      hconfig.h
  6. 4 4
      hconfig.h.in
  7. 1 1
      unittest/CMakeLists.txt

+ 1 - 2
Makefile

@@ -2,7 +2,6 @@ include config.mk
 include Makefile.vars
 
 MAKEF=$(MAKE) -f Makefile.in
-
 ALL_SRCDIRS=. base utils event protocol http http/client http/server consul examples
 
 LIBHV_SRCDIRS = . base utils event
@@ -101,7 +100,7 @@ unittest: prepare
 	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/hstring_test      unittest/hstring_test.cpp     base/hstring.cpp base/hbase.c
 	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/threadpool_test   unittest/threadpool_test.cpp  -pthread
 	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/objectpool_test   unittest/objectpool_test.cpp  -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/ls                unittest/listdir_test.cpp     base/hdir.cpp base/hbase.c
+	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/ls                unittest/listdir_test.cpp     base/hdir.cpp
 	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/ifconfig          unittest/ifconfig_test.cpp    base/ifconfig.cpp
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/nslookup          unittest/nslookup_test.c      protocol/dns.c
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/ping              unittest/ping_test.c          protocol/icmp.c base/hsocket.c base/htime.c -DPRINT_DEBUG

+ 3 - 4
base/hdir.cpp

@@ -3,7 +3,6 @@
 #include <string.h>
 
 #include "hplatform.h"
-#include "hbase.h"
 
 #ifdef OS_WIN
 //FILETIME starts from 1601-01-01 UTC, epoch from 1970-01-01 UTC
@@ -42,8 +41,8 @@ int listdir(const char* dir, std::list<hdir_t>& dirs) {
     hdir_t tmp;
     while (readdir_r(dp, &de, &result) == 0 && result) {
         memset(&tmp, 0, sizeof(hdir_t));
-        strlcpy(tmp.name, result->d_name, sizeof(tmp.name));
-        strlcpy(path+dirlen, result->d_name, sizeof(path)-dirlen);
+        strncpy(tmp.name, result->d_name, sizeof(tmp.name));
+        strncpy(path+dirlen, result->d_name, sizeof(path)-dirlen);
         if (lstat(path, &st) == 0) {
             if (S_ISREG(st.st_mode))        tmp.type = 'f';
             else if (S_ISDIR(st.st_mode))   tmp.type = 'd';
@@ -73,7 +72,7 @@ int listdir(const char* dir, std::list<hdir_t>& dirs) {
     hdir_t tmp;
     do {
         memset(&tmp, 0, sizeof(hdir_t));
-        strlcpy(tmp.name, data.cFileName, sizeof(tmp.name));
+        strncpy(tmp.name, data.cFileName, sizeof(tmp.name));
         tmp.type = 'f';
         if (data.dwFileAttributes & _A_SUBDIR) {
             tmp.type = 'd';

+ 1 - 1
docs/apis.md

@@ -26,7 +26,7 @@
 - FLOAT_EQUAL_ZERO
 - IN, OUT, INOUT
 - INFINITE
-- IS_ALPHA, IS_NUM, IS_NUM
+- IS_ALPHA, IS_NUM, IS_ALPHANUM
 - IS_CNTRL, IS_GRAPH
 - IS_HEX
 - IS_LOWER, IS_UPPER

+ 1 - 1
examples/hmain_test.cpp

@@ -279,6 +279,6 @@ void worker_fn(void* userdata) {
     long num = (long)(intptr_t)(userdata);
     while (1) {
         printf("num=%ld pid=%ld tid=%ld\n", num, hv_getpid(), hv_gettid());
-        sleep(60);
+        hv_delay(10000);
     }
 }

+ 2 - 2
hconfig.h

@@ -34,11 +34,11 @@
 #endif
 
 #ifndef HAVE_STRLCPY
-#define HAVE_STRLCPY 1
+#define HAVE_STRLCPY 0
 #endif
 
 #ifndef HAVE_STRLCAT
-#define HAVE_STRLCAT 1
+#define HAVE_STRLCAT 0
 #endif
 
 #ifndef HAVE_CLOCK_GETTIME

+ 4 - 4
hconfig.h.in

@@ -1,14 +1,14 @@
 #ifndef HV_CONFIG_H_
 #define HV_CONFIG_H_
 
-#ifndef HAVE_STDINT_H
-#define HAVE_STDINT_H @HAVE_STDINT_H@
-#endif
-
 #ifndef HAVE_STDBOOL_H
 #define HAVE_STDBOOL_H @HAVE_STDBOOL_H@
 #endif
 
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H @HAVE_STDINT_H@
+#endif
+
 #ifndef HAVE_SYS_TYPES_H
 #define HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
 #endif

+ 1 - 1
unittest/CMakeLists.txt

@@ -31,7 +31,7 @@ add_executable(objectpool_test objectpool_test.cpp)
 target_include_directories(objectpool_test PRIVATE .. ../base)
 target_link_libraries(objectpool_test -lpthread)
 
-add_executable(ls listdir_test.cpp ../base/hdir.cpp ../base/hbase.c)
+add_executable(ls listdir_test.cpp ../base/hdir.cpp)
 target_include_directories(ls PRIVATE .. ../base)
 
 add_executable(ifconfig ifconfig_test.cpp ../base/ifconfig.cpp)