Patch 8.2.3714
Problem: Some unused assignments and ugly code in xxd.
Solution: Leave out assignments. Use marcro for fprintf(). (closes #9246)
Files: src/xxd/xxd.c
*** ../vim-8.2.3713/src/xxd/xxd.c 2021-11-26 13:59:22.533650233 +0000
--- src/xxd/xxd.c 2021-12-01 11:19:42.077694765 +0000
***************
*** 275,286 ****
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);
! }
static void
fclose_or_die(FILE *fpi, FILE *fpo)
--- 275,282 ----
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,383 ****
have_off = base_off + want_off;
#endif
if (base_off + want_off < have_off)
! error_exit(5, "sorry, cannot seek backwards.");
for (; have_off < base_off + want_off; have_off++)
putc_or_die(0, fpo);
}
--- 373,379 ----
have_off = base_off + want_off;
#endif
if (base_off + want_off < have_off)
! error_exit(5, "Sorry, cannot seek backwards.");
for (; have_off < base_off + want_off; have_off++)
putc_or_die(0, fpo);
}
***************
*** 714,720 ****
if (revert)
{
if (hextype && (hextype != HEX_POSTSCRIPT))
! error_exit(-1, "sorry, cannot revert this type of hexdump");
return huntype(fp, fpo, cols, hextype,
negseek ? -seekoff : seekoff);
}
--- 710,716 ----
if (revert)
{
if (hextype && (hextype != HEX_POSTSCRIPT))
! error_exit(-1, "Sorry, cannot revert this type of hexdump");
return huntype(fp, fpo, cols, hextype,
negseek ? -seekoff : seekoff);
}
***************
*** 728,734 ****
e = fseek(fp, negseek ? -seekoff : seekoff,
negseek ? SEEK_END : SEEK_SET);
if (e < 0 && negseek)
! error_exit(4, "sorry cannot seek.");
if (e >= 0)
seekoff = ftell(fp);
else
--- 724,730 ----
e = fseek(fp, negseek ? -seekoff : seekoff,
negseek ? SEEK_END : SEEK_SET);
if (e < 0 && negseek)
! error_exit(4, "Sorry, cannot seek.");
if (e >= 0)
seekoff = ftell(fp);
else
***************
*** 737,745 ****
long s = seekoff;
while (s--)
! if ((c = getc_or_die(fp)) == EOF)
{
! error_exit(4, "sorry cannot seek.");
}
}
}
--- 733,741 ----
long s = seekoff;
while (s--)
! if (getc_or_die(fp) == EOF)
{
! error_exit(4, "Sorry, cannot seek.");
}
}
}
***************
*** 748,754 ****
{
if (fp != stdin)
{
! fprintf_or_die(fpo, "unsigned char %s", isdigit((int)argv[1][0]) ? "__" : "", 0);
for (e = 0; (c = argv[1][e]) != 0; e++)
putc_or_die(isalnum(c) ? CONDITIONAL_CAPITALIZE(c) : '_', fpo);
fputs_or_die("[] = {\n", fpo);
--- 744,750 ----
{
if (fp != stdin)
{
! 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,765 ****
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);
p++;
}
--- 754,761 ----
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));
p++;
}
***************
*** 769,778 ****
if (fp != stdin)
{
fputs_or_die("};\n", fpo);
! fprintf_or_die(fpo, "unsigned int %s", isdigit((int)argv[1][0]) ? "__" : "", 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);
}
fclose_or_die(fp, fpo);
--- 765,774 ----
if (fp != stdin)
{
fputs_or_die("};\n", fpo);
! 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));
}
fclose_or_die(fp, fpo);
***************
*** 782,788 ****
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);
--- 778,783 ----
***************
*** 807,813 ****
else /* hextype == HEX_BITS */
grplen = 8 * octspergrp + 1;
- e = 0;
while ((length < 0 || n < length) && (e = getc_or_die(fp)) != EOF)
{
int x;
--- 802,807 ----
*** ../vim-8.2.3713/src/version.c 2021-12-01 10:54:21.034251519 +0000
--- src/version.c 2021-12-01 11:24:02.456705599 +0000
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 3714,
/**/
--
ARTHUR: Be quiet! I order you to shut up.
OLD WOMAN: Order, eh -- who does he think he is?
ARTHUR: I am your king!
OLD WOMAN: Well, I didn't vote for you.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///