0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.3714: some unused assignments and ugly code in xxd

Problem:    Some unused assignments and ugly code in xxd.
Solution:   Leave out assignments.  Use marcro for fprintf(). (closes #9246)
This commit is contained in:
DungSaga
2021-12-01 11:24:52 +00:00
committed by Bram Moolenaar
parent 0b226f60be
commit 7e5503c17a
2 changed files with 14 additions and 18 deletions

View File

@@ -753,6 +753,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3714,
/**/
3713,
/**/

View File

@@ -275,12 +275,8 @@ fputs_or_die(char *s, FILE *fpo)
perror_exit(3);
}
static void
fprintf_or_die(FILE *fpo, char *format, char *s, int d)
{
if (fprintf(fpo, format, s, d) < 0)
perror_exit(3);
}
/* Use a macro to allow for different arguments. */
#define FPRINTF_OR_DIE(args) if (fprintf args < 0) perror_exit(3)
static void
fclose_or_die(FILE *fpi, FILE *fpo)
@@ -377,7 +373,7 @@ huntype(
have_off = base_off + want_off;
#endif
if (base_off + want_off < have_off)
error_exit(5, "sorry, cannot seek backwards.");
error_exit(5, "Sorry, cannot seek backwards.");
for (; have_off < base_off + want_off; have_off++)
putc_or_die(0, fpo);
}
@@ -714,7 +710,7 @@ main(int argc, char *argv[])
if (revert)
{
if (hextype && (hextype != HEX_POSTSCRIPT))
error_exit(-1, "sorry, cannot revert this type of hexdump");
error_exit(-1, "Sorry, cannot revert this type of hexdump");
return huntype(fp, fpo, cols, hextype,
negseek ? -seekoff : seekoff);
}
@@ -728,7 +724,7 @@ main(int argc, char *argv[])
e = fseek(fp, negseek ? -seekoff : seekoff,
negseek ? SEEK_END : SEEK_SET);
if (e < 0 && negseek)
error_exit(4, "sorry cannot seek.");
error_exit(4, "Sorry, cannot seek.");
if (e >= 0)
seekoff = ftell(fp);
else
@@ -737,9 +733,9 @@ main(int argc, char *argv[])
long s = seekoff;
while (s--)
if ((c = getc_or_die(fp)) == EOF)
if (getc_or_die(fp) == EOF)
{
error_exit(4, "sorry cannot seek.");
error_exit(4, "Sorry, cannot seek.");
}
}
}
@@ -748,7 +744,7 @@ main(int argc, char *argv[])
{
if (fp != stdin)
{
fprintf_or_die(fpo, "unsigned char %s", isdigit((int)argv[1][0]) ? "__" : "", 0);
FPRINTF_OR_DIE((fpo, "unsigned char %s", isdigit((int)argv[1][0]) ? "__" : ""));
for (e = 0; (c = argv[1][e]) != 0; e++)
putc_or_die(isalnum(c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo);
fputs_or_die("[] = {\n", fpo);
@@ -758,8 +754,8 @@ main(int argc, char *argv[])
c = 0;
while ((length < 0 || p < length) && (c = getc_or_die(fp)) != EOF)
{
fprintf_or_die(fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",
(p % cols) ? ", " : (!p ? " " : ",\n "), c);
FPRINTF_OR_DIE((fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",
(p % cols) ? ", " : (!p ? " " : ",\n "), c));
p++;
}
@@ -769,10 +765,10 @@ main(int argc, char *argv[])
if (fp != stdin)
{
fputs_or_die("};\n", fpo);
fprintf_or_die(fpo, "unsigned int %s", isdigit((int)argv[1][0]) ? "__" : "", 0);
FPRINTF_OR_DIE((fpo, "unsigned int %s", isdigit((int)argv[1][0]) ? "__" : ""));
for (e = 0; (c = argv[1][e]) != 0; e++)
putc_or_die(isalnum(c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo);
fprintf_or_die(fpo, "_%s = %d;\n", capitalize ? "LEN" : "len", p);
FPRINTF_OR_DIE((fpo, "_%s = %d;\n", capitalize ? "LEN" : "len", p));
}
fclose_or_die(fp, fpo);
@@ -782,7 +778,6 @@ main(int argc, char *argv[])
if (hextype == HEX_POSTSCRIPT)
{
p = cols;
e = 0;
while ((length < 0 || n < length) && (e = getc_or_die(fp)) != EOF)
{
putc_or_die(hexx[(e >> 4) & 0xf], fpo);
@@ -807,7 +802,6 @@ main(int argc, char *argv[])
else /* hextype == HEX_BITS */
grplen = 8 * octspergrp + 1;
e = 0;
while ((length < 0 || n < length) && (e = getc_or_die(fp)) != EOF)
{
int x;