From 4a4154acc0f51f42d5865b613a053fb1e8d74006 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Tue, 15 Jan 2002 21:32:07 +0000 Subject: [PATCH] Fixed mbsetup '%' output --- ChangeLog | 2 ++ lib/mangle.c | 6 ++--- mbfido/magic.c | 67 +++++++++++++++++++++++++------------------------ mbfido/tic.c | 2 +- mbsetup/ledit.c | 12 ++++++++- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index f865b0b0..fdefe6fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4310,6 +4310,8 @@ v0.33.19 26-Oct-2001 Rewrote calling of the color editor for Sparc systems. Added setup items in global and message areas to limit the fetching of newsgroups headers. + The edit field now shows the contents correctly if the field + contains the % character. mbsebbs: Added menu 317, change FS editor shortcut keys to (Emacs/ diff --git a/lib/mangle.c b/lib/mangle.c index 0546c0cf..f594cab8 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -4,7 +4,7 @@ * Purpose ...............: Mangle a unix name to DOS 8.3 filename * ***************************************************************************** - * Copyright (C) 1997-2001 + * Copyright (C) 1997-2002 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -391,7 +391,7 @@ void mangle_name_83(char *s) for (i = 0; i < strlen(q); i++) *p++ = q[i]; *p++ = '\0'; - Syslog('f', "name with new extension => \"%s\"", s); +// Syslog('f', "name with new extension => \"%s\"", s); } /* @@ -474,7 +474,7 @@ void name_mangle(char *OutName) tu(OutName); } - Syslog('f',"name_mangle(%s) ==> [%s]", p, OutName); +// Syslog('f',"name_mangle(%s) ==> [%s]", p, OutName); free(p); } diff --git a/mbfido/magic.c b/mbfido/magic.c index 932baa2f..98672bea 100644 --- a/mbfido/magic.c +++ b/mbfido/magic.c @@ -48,7 +48,7 @@ int Magics = 0; /* Processed magics */ char *Magic_Macro(int); char *Magic_Macro(int C) { - static char buf[81]; + static char buf[PATH_MAX]; buf[0] = '\0'; switch(toupper(C)) { @@ -197,6 +197,7 @@ void MagicResult(char *format, ...) } + void Magic_CheckCompile(void); void Magic_CheckCompile(void) { @@ -224,7 +225,7 @@ void Magic_ExecCommand(void) { int i, j, k, Err, First = TRUE; char Line[256]; - char Temp[81]; + char Temp[PATH_MAX]; char *cmd, *opts; while (GetMagicRec(MG_EXEC, First)) { @@ -273,8 +274,8 @@ void Magic_CopyFile(void) int First = TRUE; char *From, *To; - From = calloc(256, sizeof(char)); - To = calloc(256, sizeof(char)); + From = calloc(PATH_MAX, sizeof(char)); + To = calloc(PATH_MAX, sizeof(char)); while (GetMagicRec(MG_COPY, First)) { First = FALSE; @@ -296,38 +297,38 @@ void Magic_CopyFile(void) void Magic_UnpackFile(void) { - int rc, First = TRUE; - char *buf = NULL, *unarc = NULL, *cmd = NULL; - char Fn[128]; + int rc, First = TRUE; + char *buf = NULL, *unarc = NULL, *cmd = NULL; + char Fn[PATH_MAX]; - while (GetMagicRec(MG_UNPACK, First)) { - First = FALSE; - buf = calloc(PATH_MAX, sizeof(char)); /* 06-01-2001 MB. Test if NULL pointer free'd message goes away */ - getcwd(buf, 128); + while (GetMagicRec(MG_UNPACK, First)) { + First = FALSE; + buf = calloc(PATH_MAX, sizeof(char)); + getcwd(buf, 128); - if (chdir(magic.Path) == 0) { - sprintf(Fn, "%s/%s", TIC.BBSpath, TIC.NewName); - if ((unarc = unpacker(Fn)) != NULL) { - if (getarchiver(unarc)) { - cmd = xstrcpy(archiver.funarc); - if (strlen(cmd)) { - rc = execute(cmd, Fn, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); - if (rc) - WriteError("$Magic: unpack in %s, error %d", magic.Path, rc); - else - MagicResult((char *)"unpacked in %s", magic.Path); - } - free(cmd); - } - } + if (chdir(magic.Path) == 0) { + sprintf(Fn, "%s/%s", TIC.BBSpath, TIC.NewName); + if ((unarc = unpacker(Fn)) != NULL) { + if (getarchiver(unarc)) { + cmd = xstrcpy(archiver.funarc); + if (strlen(cmd)) { + rc = execute(cmd, Fn, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); + if (rc) + WriteError("$Magic: unpack in %s, error %d", magic.Path, rc); + else + MagicResult((char *)"unpacked in %s", magic.Path); + } + free(cmd); + } + } - chdir(buf); - Magic_CheckCompile(); - } else - WriteError("$Magic: unpack: can't chdir \"%s\"", magic.Path); + chdir(buf); + Magic_CheckCompile(); + } else + WriteError("$Magic: unpack: can't chdir \"%s\"", magic.Path); - free(buf); - } + free(buf); + } } @@ -358,7 +359,7 @@ void Magic_AdoptFile(void) char *temp; FILE *Tf; - temp = calloc(256, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); while (GetMagicRec(MG_ADOPT, First)) { First = FALSE; diff --git a/mbfido/tic.c b/mbfido/tic.c index 0a908ecf..495b3354 100644 --- a/mbfido/tic.c +++ b/mbfido/tic.c @@ -200,7 +200,7 @@ int LoadTic(char *inb, char *tfn) } Temp[j] = '\0'; - Syslog('f', "TIC: %s", Temp); +// Syslog('f', "TIC: %s", Temp); if (strncasecmp(Temp, "hatch", 5) == 0) { TIC.TicIn.Hatch = TRUE; diff --git a/mbsetup/ledit.c b/mbsetup/ledit.c index a1523999..3487c53c 100644 --- a/mbsetup/ledit.c +++ b/mbsetup/ledit.c @@ -94,9 +94,19 @@ void errmsg(const char *format, ...) +/* + * Safe field display, does not format % characters but displays it. + */ void show_field(int y, int x, char *str, int length, int fill) { - mvprintw(y, x, padleft(str, length, fill)); + int i; + + locate(y, x); + for (i = 0; i < strlen(str); i++) + putchar(str[i]); + if (strlen(str) < length) + for (i = strlen(str); i < length; i++) + putchar(fill); }