commit 2f89a81a9831fa9c31aab9285bffd1a72d1260f3
parent fefad43845f8366294c0b5a9789d9cfedead9193
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 24 Dec 2021 23:16:15 +0200
fix bug in cleanDispose* for smallArray, smallDict and smallJson, add LOG_PROGNFUNC, add prog name in LOG_VERBOSE, fix warning in print_m
The program name in LOG_VERBOSE allows distinguishing the source of
printouts in stdout when multiple programs run in parallel and sharing
some of the same source files
release/json/libsheepyCSmallArray.h | 2 +-
release/json/libsheepyCSmallDict.h | 2 +-
release/json/libsheepyCSmallJson.h | 2 +-
release/libsheepy.c | 9 +++++++--
release/libsheepy.h | 11 ++++++++---
src/json/libsheepyCSmallArray.c | 6 +++---
src/json/libsheepyCSmallArray.h | 2 +-
src/json/libsheepyCSmallDict.c | 6 +++---
src/json/libsheepyCSmallDict.h | 2 +-
src/json/libsheepyCSmallJson.c | 6 +++---
src/json/libsheepyCSmallJson.h | 2 +-
src/json/libsheepyObject.c | 7 +++++++
src/libsheepy.c | 9 +++++++--
src/libsheepy.h | 11 ++++++++---
14 files changed, 52 insertions(+), 25 deletions(-)
Diffstat:
14 files changed, 52 insertions(+), 25 deletions(-)
diff --git a/release/json/libsheepyCSmallArray.h b/release/json/libsheepyCSmallArray.h
@@ -1934,7 +1934,7 @@ void cleanUpSmallArrayFreeG(smallArrayt **val);
void cleanUpSmallArrayFinishG(smallArrayt **val);
// dispose smallArrayt val when it is out of scope
-void cleanUpSmallArrayDisposeG(smallArrayt **val);
+void cleanUpSmallArrayDisposeG(smallArrayt *val);
// smash smallArrayt val when it is out of scope
void cleanUpSmallArraySmashG(smallArrayt **val);
diff --git a/release/json/libsheepyCSmallDict.h b/release/json/libsheepyCSmallDict.h
@@ -1106,7 +1106,7 @@ void cleanUpSmallDictFreeG(smallDictt **val);
void cleanUpSmallDictFinishG(smallDictt **val);
// dispose smallDictt val when it is out of scope
-void cleanUpSmallDictDisposeG(smallDictt **val);
+void cleanUpSmallDictDisposeG(smallDictt *val);
// smash smallDictt val when it is out of scope
void cleanUpSmallDictSmashG(smallDictt **val);
diff --git a/release/json/libsheepyCSmallJson.h b/release/json/libsheepyCSmallJson.h
@@ -3550,7 +3550,7 @@ void cleanUpSmallJsonFreeG(smallJsont **val);
void cleanUpSmallJsonFinishG(smallJsont **val);
// dispose smallJsont val when it is out of scope
-void cleanUpSmallJsonDisposeG(smallJsont **val);
+void cleanUpSmallJsonDisposeG(smallJsont *val);
// smash smallJsont val when it is out of scope
void cleanUpSmallJsonSmashG(smallJsont **val);
diff --git a/release/libsheepy.c b/release/libsheepy.c
@@ -1079,7 +1079,7 @@ void setLogMode(int mode) {
if (mode < 0 || mode >= LOG_INVALID_MODE) {
shPrintError
- shEPrintfS("The available log modes are: LOG_VERBOSE, LOG_CONCISE, LOG_DATE, LOG_FUNC, LOG_PROG, LOG_PROGNDATE, LOG_VOID and LOG_UTF8\n");
+ shEPrintfS("The available log modes are: LOG_VERBOSE, LOG_CONCISE, LOG_DATE, LOG_FUNC, LOG_PROG, LOG_PROGNDATE, LOG_PROGNFUNC, LOG_VOID and LOG_UTF8\n");
}
else {
_log_current_mode = mode;
@@ -1300,7 +1300,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
switch(_log_current_mode) {
case LOG_VERBOSE:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s() (%s:%d) at %s |\t", func, file, line, clock);
+ fprintf(_logging_files[i], "%s %s() (%s:%d) at %s |\t", progName ? progName : defaultProgName, func, file, line, clock);
}
break;
case LOG_FUNC:
@@ -1323,6 +1323,11 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
fprintf(_logging_files[i], "%s ", clock);
}
break;
+ case LOG_PROGNFUNC:
+ for (i=firstLogFile; i < _current_log_file; i++) {
+ fprintf(_logging_files[i], "%s %s %d: ", progName ? progName : defaultProgName, func, line);
+ }
+ break;
default:;
// don't print anything
}
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.7"
+#define LIBSHEEPY_VERSION "2.2.8"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -923,7 +923,7 @@ uint64_t shStopwatch(uint8_t op);
*/
/**
- * log symbol, filename, function, line, date
+ * log symbol, program name, filename, function, line, date
*/
#define LOG_VERBOSE 0
@@ -963,9 +963,14 @@ uint64_t shStopwatch(uint8_t op);
#define LOG_UTF8 7
/**
+ * log symbol, program name and function
+ */
+#define LOG_PROGNFUNC 8
+
+/**
* invalid
*/
-#define LOG_INVALID_MODE 8
+#define LOG_INVALID_MODE 9
// add a log file, maximum 15 files
FILE *SH_PREFIX(setLogFile)(char *filename);
diff --git a/src/json/libsheepyCSmallArray.c b/src/json/libsheepyCSmallArray.c
@@ -44,7 +44,7 @@ void cleanUpSmallArrayTerminateG(smallArrayt **val);
void cleanUpSmallArrayFreeLocalG(smallArrayt *val);
void cleanUpSmallArrayFreeG(smallArrayt **val);
void cleanUpSmallArrayFinishG(smallArrayt **val);
-void cleanUpSmallArrayDisposeG(smallArrayt **val);
+void cleanUpSmallArrayDisposeG(smallArrayt *val);
void cleanUpSmallArraySmashG(smallArrayt **val);
smallArrayt* createSAF(const char *paramType, ...);
void finalizeRecycleSmallArray(void *arg UNUSED);
@@ -1478,9 +1478,9 @@ void cleanUpSmallArrayFinishG(smallArrayt **val) {
finishO(*val);
}
-void cleanUpSmallArrayDisposeG(smallArrayt **val) {
+void cleanUpSmallArrayDisposeG(smallArrayt *val) {
- disposeO(*val);
+ disposeO(val);
}
void cleanUpSmallArraySmashG(smallArrayt **val) {
diff --git a/src/json/libsheepyCSmallArray.h b/src/json/libsheepyCSmallArray.h
@@ -1934,7 +1934,7 @@ void cleanUpSmallArrayFreeG(smallArrayt **val);
void cleanUpSmallArrayFinishG(smallArrayt **val);
// dispose smallArrayt val when it is out of scope
-void cleanUpSmallArrayDisposeG(smallArrayt **val);
+void cleanUpSmallArrayDisposeG(smallArrayt *val);
// smash smallArrayt val when it is out of scope
void cleanUpSmallArraySmashG(smallArrayt **val);
diff --git a/src/json/libsheepyCSmallDict.c b/src/json/libsheepyCSmallDict.c
@@ -43,7 +43,7 @@ void cleanUpSmallDictTerminateG(smallDictt **val);
void cleanUpSmallDictFreeLocalG(smallDictt *val);
void cleanUpSmallDictFreeG(smallDictt **val);
void cleanUpSmallDictFinishG(smallDictt **val);
-void cleanUpSmallDictDisposeG(smallDictt **val);
+void cleanUpSmallDictDisposeG(smallDictt *val);
void cleanUpSmallDictSmashG(smallDictt **val);
internal void freeSmallDict(smallDictt *self);
internal void terminateSmallDict(smallDictt **self);
@@ -1033,9 +1033,9 @@ void cleanUpSmallDictFinishG(smallDictt **val) {
finishO(*val);
}
-void cleanUpSmallDictDisposeG(smallDictt **val) {
+void cleanUpSmallDictDisposeG(smallDictt *val) {
- disposeO(*val);
+ disposeO(val);
}
void cleanUpSmallDictSmashG(smallDictt **val) {
diff --git a/src/json/libsheepyCSmallDict.h b/src/json/libsheepyCSmallDict.h
@@ -1106,7 +1106,7 @@ void cleanUpSmallDictFreeG(smallDictt **val);
void cleanUpSmallDictFinishG(smallDictt **val);
// dispose smallDictt val when it is out of scope
-void cleanUpSmallDictDisposeG(smallDictt **val);
+void cleanUpSmallDictDisposeG(smallDictt *val);
// smash smallDictt val when it is out of scope
void cleanUpSmallDictSmashG(smallDictt **val);
diff --git a/src/json/libsheepyCSmallJson.c b/src/json/libsheepyCSmallJson.c
@@ -50,7 +50,7 @@ void cleanUpSmallJsonTerminateG(smallJsont **val);
void cleanUpSmallJsonFreeLocalG(smallJsont *val);
void cleanUpSmallJsonFreeG(smallJsont **val);
void cleanUpSmallJsonFinishG(smallJsont **val);
-void cleanUpSmallJsonDisposeG(smallJsont **val);
+void cleanUpSmallJsonDisposeG(smallJsont *val);
void cleanUpSmallJsonSmashG(smallJsont **val);
internal void freeSmallJson(smallJsont *self);
internal void terminateSmallJson(smallJsont **self);
@@ -2686,9 +2686,9 @@ void cleanUpSmallJsonFinishG(smallJsont **val) {
finishO(*val);
}
-void cleanUpSmallJsonDisposeG(smallJsont **val) {
+void cleanUpSmallJsonDisposeG(smallJsont *val) {
- disposeO(*val);
+ disposeO(val);
}
void cleanUpSmallJsonSmashG(smallJsont **val) {
diff --git a/src/json/libsheepyCSmallJson.h b/src/json/libsheepyCSmallJson.h
@@ -3550,7 +3550,7 @@ void cleanUpSmallJsonFreeG(smallJsont **val);
void cleanUpSmallJsonFinishG(smallJsont **val);
// dispose smallJsont val when it is out of scope
-void cleanUpSmallJsonDisposeG(smallJsont **val);
+void cleanUpSmallJsonDisposeG(smallJsont *val);
// smash smallJsont val when it is out of scope
void cleanUpSmallJsonSmashG(smallJsont **val);
diff --git a/src/json/libsheepyObject.c b/src/json/libsheepyObject.c
@@ -729,7 +729,13 @@ int print_m(FILE *stream, const struct printf_info *info, const void *const *arg
o = *((baset*const*) args[0]);
// warning OK: toString discards const qualifier -Wdiscarded-qualifiers
+ _Pragma ("GCC diagnostic push")
+ _Pragma ("GCC diagnostic ignored \"-Wdiscarded-qualifiers\"") {
+ //#pragma GCC diagnostic push
+ //bug in cg_c - #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
b = toStringO(o);
+ _Pragma ("GCC diagnostic pop")
+ //#pragma GCC diagnostic pop
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
@@ -737,6 +743,7 @@ int print_m(FILE *stream, const struct printf_info *info, const void *const *arg
free(b);
return(len);
}
+ }
/**
* procress printf argument
diff --git a/src/libsheepy.c b/src/libsheepy.c
@@ -1135,7 +1135,7 @@ void setLogMode(int mode) {
if (mode < 0 || mode >= LOG_INVALID_MODE) {
shPrintError
- shEPrintfS("The available log modes are: LOG_VERBOSE, LOG_CONCISE, LOG_DATE, LOG_FUNC, LOG_PROG, LOG_PROGNDATE, LOG_VOID and LOG_UTF8\n");
+ shEPrintfS("The available log modes are: LOG_VERBOSE, LOG_CONCISE, LOG_DATE, LOG_FUNC, LOG_PROG, LOG_PROGNDATE, LOG_PROGNFUNC, LOG_VOID and LOG_UTF8\n");
}
else {
_log_current_mode = mode;
@@ -1356,7 +1356,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
switch(_log_current_mode) {
case LOG_VERBOSE:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s() (%s:%d) at %s |\t", func, file, line, clock);
+ fprintf(_logging_files[i], "%s %s() (%s:%d) at %s |\t", progName ? progName : defaultProgName, func, file, line, clock);
}
break;
case LOG_FUNC:
@@ -1379,6 +1379,11 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
fprintf(_logging_files[i], "%s ", clock);
}
break;
+ case LOG_PROGNFUNC:
+ for (i=firstLogFile; i < _current_log_file; i++) {
+ fprintf(_logging_files[i], "%s %s %d: ", progName ? progName : defaultProgName, func, line);
+ }
+ break;
default:;
// don't print anything
}
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.7"
+#define LIBSHEEPY_VERSION "2.2.8"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -923,7 +923,7 @@ uint64_t shStopwatch(uint8_t op);
*/
/**
- * log symbol, filename, function, line, date
+ * log symbol, program name, filename, function, line, date
*/
#define LOG_VERBOSE 0
@@ -963,9 +963,14 @@ uint64_t shStopwatch(uint8_t op);
#define LOG_UTF8 7
/**
+ * log symbol, program name and function
+ */
+#define LOG_PROGNFUNC 8
+
+/**
* invalid
*/
-#define LOG_INVALID_MODE 8
+#define LOG_INVALID_MODE 9
// add a log file, maximum 15 files
FILE *SH_PREFIX(setLogFile)(char *filename);