src: more clang-format
This commit is contained in:
+7
-6
@@ -76,14 +76,15 @@ ifeq ($(shell uname),Linux)
|
||||
CLANG_FORMAT_FILES += bele.h bele_policy.h
|
||||
CLANG_FORMAT_FILES += c_file.cpp c_init.cpp c_none.cpp c_screen.cpp
|
||||
CLANG_FORMAT_FILES += compress_lzma.cpp compress_ucl.cpp compress_zlib.cpp
|
||||
CLANG_FORMAT_FILES += except.cpp except.h
|
||||
CLANG_FORMAT_FILES += console.h except.cpp except.h
|
||||
CLANG_FORMAT_FILES += file.cpp file.h lefile.cpp lefile.h
|
||||
CLANG_FORMAT_FILES += linker.cpp linker.h packhead.cpp packmast.cpp packmast.h
|
||||
CLANG_FORMAT_FILES += main.cpp options.cpp options.h packer.cpp packer.h
|
||||
CLANG_FORMAT_FILES += p_armpe.cpp p_armpe.h
|
||||
CLANG_FORMAT_FILES += p_com.cpp p_com.h p_djgpp2.cpp p_djgpp2.h p_exe.cpp p_exe.h p_ps1.cpp p_ps1.h
|
||||
CLANG_FORMAT_FILES += p_sys.cpp p_sys.h p_tmt.cpp p_tmt.h p_tos.cpp p_tos.h p_wcle.cpp p_wcle.h
|
||||
CLANG_FORMAT_FILES += linker.cpp linker.h main.cpp msg.cpp options.cpp options.h
|
||||
CLANG_FORMAT_FILES += p_armpe.cpp p_armpe.h p_com.cpp p_com.h p_djgpp2.cpp p_djgpp2.h
|
||||
CLANG_FORMAT_FILES += p_exe.cpp p_exe.h p_ps1.cpp p_ps1.h p_sys.cpp p_sys.h
|
||||
CLANG_FORMAT_FILES += p_tmt.cpp p_tmt.h p_tos.cpp p_tos.h
|
||||
CLANG_FORMAT_FILES += p_w32pe.h p_w64pep.h
|
||||
CLANG_FORMAT_FILES += p_wcle.cpp p_wcle.h
|
||||
CLANG_FORMAT_FILES += packer.cpp packer.h packhead.cpp packmast.cpp packmast.h
|
||||
CLANG_FORMAT_FILES += s_djgpp2.cpp s_object.cpp s_vcsa.cpp s_win32.cpp screen.h
|
||||
CLANG_FORMAT_FILES += ui.cpp ui.h work.cpp
|
||||
CLANG_FORMAT_FILES += $(wildcard util/[a-ln-z]*.[ch]* util/mem*.[ch]*)
|
||||
|
||||
+3
-23
@@ -25,8 +25,6 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
@@ -66,7 +64,6 @@
|
||||
#define USE_SCREEN_WIN32 1
|
||||
#endif
|
||||
|
||||
|
||||
#if 0 || (NO_ANSI)
|
||||
#undef USE_ANSI
|
||||
#endif
|
||||
@@ -80,7 +77,6 @@
|
||||
#undef USE_FRAMES
|
||||
#endif
|
||||
|
||||
|
||||
#if 0 || (USE_ANSI) || (USE_SCREEN)
|
||||
#define USE_CONSOLE 1
|
||||
#endif
|
||||
@@ -94,37 +90,23 @@
|
||||
#undef USE_FRAMES
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
enum {
|
||||
CON_INIT,
|
||||
CON_NONE,
|
||||
CON_FILE,
|
||||
CON_ANSI_MONO,
|
||||
CON_ANSI_COLOR,
|
||||
CON_SCREEN,
|
||||
CON_UNUSED
|
||||
};
|
||||
|
||||
enum { CON_INIT, CON_NONE, CON_FILE, CON_ANSI_MONO, CON_ANSI_COLOR, CON_SCREEN, CON_UNUSED };
|
||||
|
||||
#if (USE_CONSOLE)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int (*init)(FILE *f, int, int);
|
||||
int (*set_fg)(FILE *f, int fg);
|
||||
void (*print0)(FILE *f, const char *s);
|
||||
bool (*intro)(FILE *f);
|
||||
}
|
||||
console_t;
|
||||
|
||||
} console_t;
|
||||
|
||||
void con_fprintf(FILE *f, const char *format, ...) attribute_format(2, 3);
|
||||
|
||||
|
||||
#define FG_BLACK 0x00
|
||||
#define FG_BLUE 0x01
|
||||
#define FG_GREEN 0x02
|
||||
@@ -153,7 +135,6 @@ void con_fprintf(FILE *f, const char *format, ...) attribute_format(2, 3);
|
||||
|
||||
#endif /* USE_CONSOLE */
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
@@ -172,7 +153,6 @@ extern console_t console_ansi_mono;
|
||||
extern console_t console_ansi_color;
|
||||
extern console_t console_screen;
|
||||
|
||||
|
||||
#define con_fg(f, x) con->set_fg(f, x)
|
||||
|
||||
#else
|
||||
|
||||
+26
-61
@@ -25,10 +25,8 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// FIXME: if stdout is redirected to a file and stderr is not, should
|
||||
// we write all error messages to both stderr and stdout ?
|
||||
@@ -36,17 +34,11 @@
|
||||
|
||||
static int pr_need_nl = 0;
|
||||
|
||||
void printSetNl(int need_nl) { pr_need_nl = need_nl; }
|
||||
|
||||
void printSetNl(int need_nl)
|
||||
{
|
||||
pr_need_nl = need_nl;
|
||||
}
|
||||
|
||||
void printClearLine(FILE *f)
|
||||
{
|
||||
void printClearLine(FILE *f) {
|
||||
static char clear_line_msg[1 + 79 + 1 + 1];
|
||||
if (!clear_line_msg[0])
|
||||
{
|
||||
if (!clear_line_msg[0]) {
|
||||
char *msg = clear_line_msg;
|
||||
msg[0] = '\r';
|
||||
memset(msg + 1, ' ', 79);
|
||||
@@ -54,7 +46,8 @@ void printClearLine(FILE *f)
|
||||
msg[81] = 0;
|
||||
}
|
||||
|
||||
fflush(stdout); fflush(stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
if (f == nullptr)
|
||||
f = stdout;
|
||||
con_fprintf(f, "%s", clear_line_msg);
|
||||
@@ -62,24 +55,21 @@ void printClearLine(FILE *f)
|
||||
printSetNl(0);
|
||||
}
|
||||
|
||||
|
||||
static void pr_print(bool c, const char *msg)
|
||||
{
|
||||
static void pr_print(bool c, const char *msg) {
|
||||
if (c && !opt->to_stdout)
|
||||
con_fprintf(stderr, "%s", msg);
|
||||
else
|
||||
fprintf(stderr, "%s", msg);
|
||||
}
|
||||
|
||||
static void pr_error(const char *iname, const char *msg, bool is_warning)
|
||||
{
|
||||
fflush(stdout); fflush(stderr);
|
||||
static void pr_error(const char *iname, const char *msg, bool is_warning) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
char buf[1024];
|
||||
buf[0] = 0;
|
||||
if (pr_need_nl == 2)
|
||||
printClearLine(stdout);
|
||||
else if (pr_need_nl)
|
||||
{
|
||||
else if (pr_need_nl) {
|
||||
buf[0] = '\n';
|
||||
buf[1] = 0;
|
||||
printSetNl(0);
|
||||
@@ -99,16 +89,15 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
|
||||
//(void)con_fg(stderr,FG_BRTRED);
|
||||
pr_print(c, msg);
|
||||
pr_print(c, "\n");
|
||||
fflush(stdout); fflush(stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fg = con_fg(stderr, fg);
|
||||
|
||||
UNUSED(is_warning);
|
||||
UNUSED(fg);
|
||||
}
|
||||
|
||||
|
||||
void printErr(const char *iname, const Throwable *e)
|
||||
{
|
||||
void printErr(const char *iname, const Throwable *e) {
|
||||
char buf[1024];
|
||||
size_t l;
|
||||
|
||||
@@ -130,9 +119,7 @@ void printErr(const char *iname, const Throwable *e)
|
||||
pr_error(iname, buf, e->isWarning());
|
||||
}
|
||||
|
||||
|
||||
void printErr(const char *iname, const char *format, ...)
|
||||
{
|
||||
void printErr(const char *iname, const char *format, ...) {
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
@@ -143,9 +130,7 @@ void printErr(const char *iname, const char *format, ...)
|
||||
pr_error(iname, buf, false);
|
||||
}
|
||||
|
||||
|
||||
void printWarn(const char *iname, const char *format, ...)
|
||||
{
|
||||
void printWarn(const char *iname, const char *format, ...) {
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
|
||||
@@ -156,38 +141,30 @@ void printWarn(const char *iname, const char *format, ...)
|
||||
pr_error(iname, buf, true);
|
||||
}
|
||||
|
||||
|
||||
void printUnhandledException(const char *iname, const std::exception *e)
|
||||
{
|
||||
void printUnhandledException(const char *iname, const std::exception *e) {
|
||||
if (e)
|
||||
printErr(iname, "unhandled exception: %s\n", prettyName(e->what()));
|
||||
else
|
||||
printErr(iname, "internal error: unhandled exception!\n");
|
||||
if (opt->cmd != CMD_COMPRESS)
|
||||
{
|
||||
if (opt->cmd != CMD_COMPRESS) {
|
||||
printErr(iname, " this file has possibly been modified/hacked; take care!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// FIXME: should use colors and a consistent layout here
|
||||
**************************************************************************/
|
||||
|
||||
static int info_header = 0;
|
||||
|
||||
|
||||
static void info_print(const char *msg)
|
||||
{
|
||||
static void info_print(const char *msg) {
|
||||
if (opt->info_mode <= 0)
|
||||
return;
|
||||
FILE *f = opt->to_stdout ? stderr : stdout;
|
||||
if (pr_need_nl)
|
||||
{
|
||||
if (pr_need_nl) {
|
||||
printClearLine(f);
|
||||
con_fprintf(f, "%s\n", msg);
|
||||
}
|
||||
else if (pr_need_nl)
|
||||
} else if (pr_need_nl)
|
||||
con_fprintf(f, "\n%s\n", msg);
|
||||
else
|
||||
con_fprintf(f, "%s\n", msg);
|
||||
@@ -195,14 +172,9 @@ static void info_print(const char *msg)
|
||||
printSetNl(0);
|
||||
}
|
||||
|
||||
void infoHeader() { info_header = 0; }
|
||||
|
||||
void infoHeader()
|
||||
{
|
||||
info_header = 0;
|
||||
}
|
||||
|
||||
void infoHeader(const char *format, ...)
|
||||
{
|
||||
void infoHeader(const char *format, ...) {
|
||||
if (opt->info_mode <= 0)
|
||||
return;
|
||||
va_list args;
|
||||
@@ -214,9 +186,7 @@ void infoHeader(const char *format, ...)
|
||||
info_header = 1;
|
||||
}
|
||||
|
||||
|
||||
void info(const char *format, ...)
|
||||
{
|
||||
void info(const char *format, ...) {
|
||||
if (opt->info_mode <= 0)
|
||||
return;
|
||||
va_list args;
|
||||
@@ -229,11 +199,8 @@ void info(const char *format, ...)
|
||||
info_print(buf);
|
||||
}
|
||||
|
||||
|
||||
void infoWarning(const char *format, ...)
|
||||
{
|
||||
if (opt->info_mode <= 0)
|
||||
{
|
||||
void infoWarning(const char *format, ...) {
|
||||
if (opt->info_mode <= 0) {
|
||||
// FIXME - should still print something here
|
||||
return;
|
||||
}
|
||||
@@ -245,9 +212,7 @@ void infoWarning(const char *format, ...)
|
||||
info("[WARNING] %s\n", buf);
|
||||
}
|
||||
|
||||
|
||||
void infoWriting(const char *what, long size)
|
||||
{
|
||||
void infoWriting(const char *what, long size) {
|
||||
if (opt->info_mode <= 0)
|
||||
return;
|
||||
info("Writing %s: %ld bytes", what, size);
|
||||
|
||||
Reference in New Issue
Block a user