rm \n from print stmts

This commit is contained in:
James Cherry
2020-12-28 09:04:57 -08:00
parent 7337e6e099
commit 20f01e417b
41 changed files with 507 additions and 477 deletions
+25 -30
View File
@@ -48,6 +48,10 @@ public:
void print(const char *fmt,
...) const
__attribute__((format (printf, 2, 3)));
void reportLine(const char *what,
const char *fmt,
...) const
__attribute__((format (printf, 3, 4)));
protected:
Report *&report_;
@@ -70,63 +74,54 @@ debugCheck(const Debug *debug,
// Inlining a varargs function would eval the args, which can
// be expensive, so use macros.
#define debugPrint0(debug, what, level, msg) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: %s", what, msg); \
#define debugPrint0(debug, what, level, msg) \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, "%s", msg); \
}
#define debugPrint1(debug, what, level, fmt, arg1) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1); \
}
#define debugPrint2(debug, what, level, fmt, arg1, arg2) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2); \
}
#define debugPrint3(debug, what, level, fmt, arg1, arg2, arg3) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3); \
}
#define debugPrint4(debug, what, level, fmt, arg1, arg2, arg3, arg4) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4); \
}
#define debugPrint5(debug, what, level, fmt, arg1, arg2, arg3, arg4, arg5) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4, arg5); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4, arg5); \
}
#define debugPrint6(debug,what,level,fmt,arg1,arg2,arg3,arg4,arg5,arg6) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4, arg5, arg6); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4, arg5, arg6); \
}
#define debugPrint7(debug,what,level,fmt,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
}
#define debugPrint8(debug,what,level,fmt,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
}
#define debugPrint9(debug,what,level,fmt,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \
if (sta::debug_on && debug->check(what, level)) { \
debug->print("%s: ", what); \
debug->print(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
if (debug_on && debug->check(what, level)) { \
debug->reportLine(what, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
}
} // namespace
+4 -2
View File
@@ -42,13 +42,13 @@ public:
// Return the number of characters written.
virtual size_t printString(const char *buffer,
size_t length);
virtual void print(const char *fmt, ...);
virtual void vprint(const char *fmt,
va_list args);
void print(const string *str);
void print(const string &str);
// Print line with return.
virtual void printLine(const char *line);
virtual void reportLine(const char *fmt, ...);
virtual void reportLineString(const char *line);
////////////////////////////////////////////////////////////////
@@ -148,6 +148,8 @@ protected:
std::mutex buffer_lock_;
static Report *default_;
friend class Debug;
private:
DISALLOW_COPY_AND_ASSIGN(Report);
};
+5 -2
View File
@@ -48,7 +48,8 @@ public:
virtual void setTclInterp(Tcl_Interp *interp);
protected:
virtual size_t printConsole(const char *buffer, size_t length);
virtual size_t printConsole(const char *buffer,
size_t length);
void flush();
private:
@@ -56,7 +57,9 @@ private:
Tcl_ChannelType *makeEncapChannelType(Tcl_Channel channel,
char *channel_name,
Tcl_DriverOutputProc output_proc);
size_t printTcl(Tcl_Channel channel, const char *buffer, size_t length);
size_t printTcl(Tcl_Channel channel,
const char *buffer,
size_t length);
Tcl_Interp *interp_;
// The original tcl channels.