Subject: Re: bug#75451: scratch/igc: Enable CHECK_STRUCTS

From: Gerd Möllmann <[email-masked]>
Date: Sat, 01 Feb 2025 19:55:09 +0100

Pip Cet <[email-masked]> writes:

>> 5. Generate an sed script to adjust all hashes.  I think Emacs
>> developers are adults (or very precocious children) and can be trusted
>> with this powerful tool.
>
> Let's please do this!  I just bumped hashes by hand in two trees, and
>
> make -C src fix-hashes
>
> would have been more convenient.

I don't feel the pain as much :-).

  (defun my-update-hash ()
    (interactive)
    (let ((hash (thing-at-point 'symbol))
          new-hash)
      (unless (and (stringp hash)
		   (string-prefix-p "HASH_" hash))
	(error "Not on a hash: %s" hash))
      (setq hash (string-trim-right hash "_[0-9a-fA-F]+"))
      (unless (file-exists-p "dmpstruct.h")
	(if (y-or-n-p "Run 'gmake dmpstruct.h? ")
	    (shell-command "gmake dmpstruct.h")
	  (error "File dmpstruct.h does not exist. Run 'gmake dmpstruct.h'.")))
      (save-excursion
	(with-current-buffer (find-file-noselect "dmpstruct.h")
          (goto-char (point-min))
          (unless (search-forward hash nil t)
            (error "Hash for %s not found in dmpstruct.h"))
          (setq new-hash (thing-at-point 'symbol)))
	(backward-sexp)
	(kill-sexp)
	(insert new-hash))))

Put point on the hash and run it.

Not that I have something against that target.