Skip to content
pi-c Artifact [a1dbbc7ce8]
Login

Artifact [a1dbbc7ce8]

Artifact a1dbbc7ce8ae6648ed06c2a8d7f8a6b76aae2cd0b6fcb435ecb003239d8c8f7e:


#!/bin/sh
# CHANGELOG.md as C, for src/changelog.inc: the text pic's /changelog shows,
# compiled in so the binary needs no file. The text is the elements of a
# NULL-terminated array of chunks of at most 3500 bytes, split at line ends
# (C11 promises string literals of 4095 bytes); the reader joins them.
set -eu
awk 'BEGIN { print "/* Generated from CHANGELOG.md by tools/changelog-inc.sh; do not edit. */"; size = 0 }
     {
         line = $0
         if (size > 0 && size + length(line) + 1 > 3500) { printf ",\n"; size = 0 }
         size += length(line) + 1
         gsub(/\\/, "\\\\", line); gsub(/"/, "\\\"", line); gsub(/\?\?/, "?\\?", line)
         printf "%s\"%s\\n\"", (size == length($0) + 1 ? "" : "\n"), line
     }
     END { printf ",\nNULL\n" }' "${1:-CHANGELOG.md}"