logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

makecrc-write-to-file.patch (850B)


  1. SPDX-FileCopyrightText: 2023 Paul Dersey <pdersey@gmail.com>
  2. SPDX-License-Identifier: GPL-2.0-or-later
  3. Modify makecrc so that it outputs C code to a file that
  4. can be appended to util.c
  5. --- gzip-1.2.4/sample/makecrc.c
  6. +++ gzip-1.2.4/sample/makecrc.c
  7. @@ -47,7 +47,9 @@ main()
  8. e |= 1L << (31 - p[i]);
  9. /* Compute and print table of CRC's, five per line */
  10. - printf(" 0x00000000L");
  11. + FILE *output = fopen("crc.c", "w");
  12. + fprintf(output, "ulg crc_32_tab[] = {\n");
  13. + fprintf(output," 0x00000000L");
  14. for (i = 1; i < 256; i++)
  15. {
  16. c = i;
  17. @@ -56,8 +58,8 @@ main()
  18. */
  19. for (k = 8; k; k--)
  20. c = c & 1 ? (c >> 1) ^ e : c >> 1;
  21. - printf(i % 5 ? ", 0x%08lxL" : ",\n 0x%08lxL", c);
  22. + fprintf(output, i % 5 ? ", 0x%08lxL" : ",\n 0x%08lxL", c);
  23. }
  24. - putchar('\n');
  25. + fprintf(output,"\n};\n");
  26. return 0;
  27. }