commit 43fcda0c8eafa2c7bfc0a416a48b223c6fec4d87 (HEAD, refs/remotes/origin/master) Author: Jim Porter Date: Tue Dec 17 21:24:00 2024 -0800 ; * etc/NEWS (Eshell): Fix example for restoring old history search. diff --git a/etc/NEWS b/etc/NEWS index f9ed0dd17e7..7529778378d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -449,10 +449,11 @@ is freed for normal search commands. If you would like to restore the previous key-bindings for the non-incremental search commands, put in your configuration: - (keymap-set eshell-hist-mode-map "M-r" - #'eshell-previous-matching-input) - (keymap-set eshell-hist-mode-map "M-s" - #'eshell-next-matching-input) + (with-eval-after-load 'em-hist + (keymap-set eshell-hist-mode-map "M-r" + #'eshell-previous-matching-input) + (keymap-set eshell-hist-mode-map "M-s" + #'eshell-next-matching-input)) +++ *** New user option 'eshell-history-isearch' commit 14a3dd6a30f7a720f29d51f2df8f8ab8138989a0 Author: Stefan Kangas Date: Wed Dec 18 04:14:25 2024 +0100 New user option browse-url-transform-alist * lisp/net/browse-url.el (browse-url-transform-alist): New user option. (browse-url): Transform URL before loading if above new option is set. diff --git a/etc/NEWS b/etc/NEWS index d73d654d5fb..f9ed0dd17e7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -331,6 +331,12 @@ modal editing packages. ** Browse URL +*** New user option 'browse-url-transform-alist'. +This user option is an alist that allows transforming URLs before asking +a web browser to load them. For example, it could be used like this: + (add-to-list 'browse-url-transform-alist + '("www.google.com" . "www.duckduckgo.com")) + *** New function 'browse-url-qutebrowser' for the Qutebrowser. For better integration with the Qutebrowser, set 'browse-url(-secondary)-browser-function' to 'browse-url-qutebrowser'. diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 8d9046f77b0..b83a9db61aa 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -263,6 +263,23 @@ be used instead." :version "31.1" :type 'regexp) +(defcustom browse-url-transform-alist nil + "Alist of transformations to apply to URLs before loading it. +Each element has the form (ORIG . REPLACEMENT), where ORIG is a regular +expression and REPLACEMENT is the replacement text. Every element will +be tested in turn, allowing more than one transformation to be made. + +Note that ORIG and REPLACEMENT are passed as arguments to +`string-match', so you can, for example, use match groups in ORIG and +backreferences in REPLACEMENT." + :type '(choice + (const :tag "None" nil) + (alist + :tag "Alist mapping from regexp to replacement" + :key-type (regexp :tag "Regexp") + :value-type (regexp :tag "Replacement"))) + :version "31.1") + (defcustom browse-url-browser-display nil "The X display for running the browser, if not same as Emacs's." :type '(choice string (const :tag "Default" nil))) @@ -923,6 +940,10 @@ invert the prefix arg instead." (interactive (browse-url-interactive-arg "URL: ")) (unless (called-interactively-p 'interactive) (setq args (or args (list browse-url-new-window-flag)))) + (when browse-url-transform-alist + (dolist (trans browse-url-transform-alist) + (when (string-match (car trans) url) + (setq url (replace-match (cdr trans) nil t url))))) (when (and url-handler-mode (not (file-name-absolute-p url)) (not (string-match "\\`[a-z]+:" url))) commit 3d3c1094604ceb6133a15226aec9b568f7923ee7 Author: Stefan Kangas Date: Wed Dec 18 03:46:04 2024 +0100 Make font-lock face variables obsolete Using these variables as "another mechanism for changing face appearance" never really worked, since mode authors were free to use the face instead of the variable (i.e. quoting the symbol). This means that when users customized the variables, it would change its appearance only in some cases, which is a rather surprising interface. Indeed, it turns out that some modes have not always been consistent, and mixed using the variable and the face, increasing the confusion even further. Thus, the only thing users could rely on to always work was to leave the variables at their default value, and to customize the face. We now recommend customizing the face, and are obsoleting these variables. This will lead to some minor code-churn, but it is believed that it will be ultimately worth it. To fix existing Lisp code, you should typically only need to quote the symbol, as this commit shows. It might be the case that we will have to keep the obsolete variables, that have been with us since Emacs 19, around for a longer time-period than normal, to allow package authors to adapt. * lisp/font-lock.el (font-lock-comment-face) (font-lock-comment-delimiter-face, font-lock-string-face) (font-lock-doc-face, font-lock-doc-markup-face, font-lock-keyword-face) (font-lock-builtin-face, font-lock-function-name-face) (font-lock-variable-name-face, font-lock-type-face) (font-lock-constant-face, font-lock-warning-face) (font-lock-negation-char-face, font-lock-preprocessor-face): Make face variables obsolete in favor of customizing the faces directly instead. (Bug#71469) * doc/lispref/modes.texi (Faces for Font Lock): Don't document above obsolete variables. * lisp/cedet/data-debug.el (data-debug-insert-hash-table) (data-debug-insert-widget-properties, data-debug-insert-string) (data-debug-insert-number): * lisp/emacs-lisp/lisp-mode.el (elisp--font-lock-backslash) (lisp-font-lock-syntactic-face-function): * lisp/emacs-lisp/package.el (describe-package-1): * lisp/generic-x.el (rc-generic-mode, rul-generic-mode): * lisp/org/org-table.el (org-table-edit-formulas): * lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes) (c-maybe-font-lock-wrong-style-comments, c-font-lock-declarators) (c-font-lock-c++-lambda-captures, c-font-lock-c++-modules): * lisp/progmodes/cperl-mode.el (cperl-find-sub-attrs) (cperl-look-at-leading-count, cperl-process-here-doc) (cperl-find-pods-heres): * lisp/progmodes/gdb-mi.el (gdb-init-1, gdb-update, gdb-running) (gdb-starting, gdb-stopped, gdb-internals) (gdb-breakpoints--add-breakpoint-row, gdb-locals-handler-custom) (gdb-registers-handler-custom, gdb-get-source-file): * lisp/progmodes/js.el (js--font-lock-keywords-1) (js--font-lock-keywords-2, js-font-lock-syntactic-face-function): * lisp/progmodes/lua-ts-mode.el (lua-ts--comment-font-lock): * lisp/progmodes/meta-mode.el (meta-indent-in-string-p): * lisp/progmodes/prolog.el (prolog-font-lock-keywords): * lisp/progmodes/python.el (python-font-lock-syntactic-face-function): * lisp/progmodes/ruby-ts-mode.el (ruby-ts--comment-font-lock): * lisp/progmodes/sh-script.el (sh-font-lock-syntactic-face-function): * lisp/textmodes/tex-mode.el (doctex-font-lock-syntactic-face-function): * test/lisp/faces-tests.el (faces--test-color-at-point): * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-extra-delimiters) (cperl-test-bug-47112, cperl-test-bug-65834, cperl-test-bug-66145) (cperl-test-bug-66161, cperl-test-bug-69604): * test/lisp/progmodes/python-tests.el (python-ts-mode-compound-keywords-face) (python-ts-mode-named-assignment-face-1) (python-ts-mode-assignment-face-2, python-ts-mode-nested-types-face-1) (python-ts-mode-union-types-face-1, python-ts-mode-union-types-face-2) (python-ts-mode-types-face-1, python-ts-mode-types-face-2) (python-ts-mode-types-face-3, python-ts-mode-isinstance-type-face-1) (python-ts-mode-isinstance-type-face-2) (python-ts-mode-isinstance-type-face-3) (python-ts-mode-superclass-type-face, python-ts-mode-class-patterns-face) (python-ts-mode-dotted-decorator-face-1) (python-ts-mode-dotted-decorator-face-2) (python-ts-mode-builtin-call-face) (python-ts-mode-interpolation-nested-string) (python-ts-mode-level-fontification-wo-interpolation) (python-ts-mode-disabled-string-interpolation) (python-ts-mode-interpolation-doc-string): * test/lisp/progmodes/ruby-mode-tests.el (ruby-heredoc-font-lock, ruby-heredoc-highlights-interpolations) (ruby-exit!-font-lock, ruby-regexp-interpolation-is-highlighted) (ruby-recognize-symbols-starting-with-at-character) (ruby-hash-character-not-interpolation) (ruby-interpolation-suppresses-quotes-inside) (ruby-interpolation-suppresses-one-double-quote) (ruby-interpolation-inside-percent-literal) (ruby-interpolation-inside-percent-literal-with-paren) (ruby-interpolation-inside-another-interpolation) (ruby-interpolation-inside-double-quoted-percent-literals) (ruby-no-interpolation-in-single-quoted-literals): Don't use above obsolete variables. * lisp/progmodes/cc-fonts.el (font-lock-constant-face): Don't declare now-unused variable. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 4838a4d8ebb..2631769c51d 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -3905,10 +3905,6 @@ faces specifically for Font Lock to use to highlight text. These modes for syntactic highlighting outside of Font Lock mode (@pxref{Major Mode Conventions}). - Each of these symbols is both a face name, and a variable whose -default value is the symbol itself. Thus, the default value of -@code{font-lock-comment-face} is @code{font-lock-comment-face}. - The faces are listed with descriptions of their typical usage, and in order of greater to lesser prominence. If a mode's syntactic categories do not fit well with the usage descriptions, the faces can be diff --git a/etc/NEWS b/etc/NEWS index d686bd78667..d73d654d5fb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -50,6 +50,30 @@ enabled, you can disable mouse tracking by putting '(xterm-mouse-mode * Changes in Emacs 31.1 ++++ +** Several font-lock face variables are now obsolete. +The following variables are now obsolete: font-lock-comment-face, +font-lock-comment-delimiter-face, font-lock-string-face, +font-lock-doc-face, font-lock-doc-markup-face, font-lock-keyword-face, +font-lock-builtin-face, font-lock-function-name-face, +font-lock-variable-name-face, font-lock-type-face, +font-lock-constant-face, font-lock-warning-face, +font-lock-negation-char-face, and font-lock-preprocessor-face. + +These variables contributed both to confusion about the relation between +faces and variables, and to inconsistency when major mode authors used +one or the other (sometimes interchangeably). We always recommended +using faces directly, and not creating variables going by the same name. + +If you have customized these variables, you should now customize the +corresponding faces instead, using something like: + + M-x customize-face RET font-lock-string-face RET + +If you have been using these variables in Lisp code (for example, in +font-lock rules), simply quote the symbol, to use the face directly +instead of its now-obsolete variable. + ** Etags +++ diff --git a/lisp/cedet/data-debug.el b/lisp/cedet/data-debug.el index fda3edd602c..5411d69b037 100644 --- a/lisp/cedet/data-debug.el +++ b/lisp/cedet/data-debug.el @@ -392,10 +392,10 @@ PREBUTTONTEXT is some text between prefix and the stuff list button." (lambda (key value) (data-debug-insert-thing key prefix - (propertize "key " 'face font-lock-comment-face)) + (propertize "key " 'face 'font-lock-comment-face)) (data-debug-insert-thing value prefix - (propertize "val " 'face font-lock-comment-face))) + (propertize "val " 'face 'font-lock-comment-face))) hash-table)) (defun data-debug-insert-hash-table-from-point (point) @@ -446,7 +446,7 @@ in front of the button text." prefix (concat (propertize (format "%s" (car rest)) - 'face font-lock-comment-face) + 'face 'font-lock-comment-face) " : ")) (setq rest (cdr (cdr rest)))) )) @@ -682,7 +682,7 @@ PREBUTTONTEXT is some text between prefix and the thing." (setq newstr (replace-match "\\t" t t newstr))) (insert prefix prebuttontext (propertize (format "\"%s\"" newstr) - 'face font-lock-string-face) + 'face 'font-lock-string-face) "\n" ))) ;;; Number @@ -693,7 +693,7 @@ PREFIX is the text that precedes the button. PREBUTTONTEXT is some text between prefix and the thing." (insert prefix prebuttontext (propertize (format "%S" thing) - 'face font-lock-string-face) + 'face 'font-lock-string-face) "\n")) ;;; Lambda Expression diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 4b89eb91387..d0c32d238bc 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -308,7 +308,7 @@ This will generate compile-time constants from BINDINGS." (buffer-substring-no-properties beg0 end0))))) (buffer-substring-no-properties (1+ beg0) end0)) - `(face ,font-lock-warning-face + '(face font-lock-warning-face help-echo "This \\ has no effect")))) (defun lisp--match-confusable-symbol-character (limit) @@ -660,9 +660,9 @@ Lisp font lock syntactic face function." (let ((listbeg (nth 1 state))) (if (or (lisp-string-in-doc-position-p listbeg startpos) (lisp-string-after-doc-keyword-p listbeg startpos)) - font-lock-doc-face - font-lock-string-face)))) - font-lock-comment-face)) + 'font-lock-doc-face + 'font-lock-string-face)))) + 'font-lock-comment-face)) (defun lisp-adaptive-fill () "Return fill prefix found at point. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 438af781393..5f785071ea3 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2864,7 +2864,7 @@ Helper function for `describe-package'." 'action #'package-delete-button-action 'package-desc desc))) (incompatible-reason - (insert (propertize "Incompatible" 'font-lock-face font-lock-warning-face) + (insert (propertize "Incompatible" 'font-lock-face 'font-lock-warning-face) " because it depends on ") (if (stringp incompatible-reason) (insert "Emacs " incompatible-reason ".") diff --git a/lisp/font-lock.el b/lisp/font-lock.el index d2232f72c55..4c519ede88a 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -303,62 +303,96 @@ If a number, only buffers greater than this size have fontification messages." (other :tag "always" t)) :group 'font-lock :version "24.1") + +;; Obsolete face variables. -;; Originally these variable values were face names such as `bold' etc. -;; Now we create our own faces, but we keep these variables for compatibility -;; and they give users another mechanism for changing face appearance. -;; We now allow a FACENAME in `font-lock-keywords' to be any expression that -;; returns a face. So the easiest thing is to continue using these variables, -;; rather than sometimes evalling FACENAME and sometimes not. sm. - -;; Note that in new code, in the vast majority of cases there is no -;; need to create variables that specify face names. Simply using -;; faces directly is enough. Font-lock is not a template to be -;; followed in this area. +(make-obsolete-variable + 'font-lock-comment-face + "use the quoted symbol instead: \\='font-lock-comment-face" "31.1") (defvar font-lock-comment-face 'font-lock-comment-face "Face name to use for comments.") +(make-obsolete-variable + 'font-lock-comment-delimiter-face + "use the quoted symbol instead: \\='font-lock-comment-delimiter-face" "31.1") (defvar font-lock-comment-delimiter-face 'font-lock-comment-delimiter-face "Face name to use for comment delimiters.") +(make-obsolete-variable + 'font-lock-string-face + "use the quoted symbol instead: \\='font-lock-string-face" "31.1") (defvar font-lock-string-face 'font-lock-string-face "Face name to use for strings.") +(make-obsolete-variable + 'font-lock-doc-face + "use the quoted symbol instead: \\='font-lock-doc-face" "31.1") (defvar font-lock-doc-face 'font-lock-doc-face "Face name to use for documentation.") +(make-obsolete-variable + 'font-lock-doc-markup-face + "use the quoted symbol instead: \\='font-lock-doc-markup-face" "31.1") (defvar font-lock-doc-markup-face 'font-lock-doc-markup-face "Face name to use for documentation mark-up.") +(make-obsolete-variable + 'font-lock-keyword-face + "use the quoted symbol instead: \\='font-lock-keyword-face" "31.1") (defvar font-lock-keyword-face 'font-lock-keyword-face "Face name to use for keywords.") +(make-obsolete-variable + 'font-lock-builtin-face + "use the quoted symbol instead: \\='font-lock-builtin-face" "31.1") (defvar font-lock-builtin-face 'font-lock-builtin-face "Face name to use for builtins.") +(make-obsolete-variable + 'font-lock-function-name-face + "use the quoted symbol instead: \\='font-lock-function-name-face" "31.1") (defvar font-lock-function-name-face 'font-lock-function-name-face "Face name to use for function names.") +(make-obsolete-variable + 'font-lock-variable-name-face + "use the quoted symbol instead: \\='font-lock-variable-name-face" "31.1") (defvar font-lock-variable-name-face 'font-lock-variable-name-face "Face name to use for variable names.") +(make-obsolete-variable + 'font-lock-type-face + "use the quoted symbol instead: \\='font-lock-type-face" "31.1") (defvar font-lock-type-face 'font-lock-type-face "Face name to use for type and class names.") +(make-obsolete-variable + 'font-lock-constant-face + "use the quoted symbol instead: \\='font-lock-constant-face" "31.1") (defvar font-lock-constant-face 'font-lock-constant-face "Face name to use for constant and label names.") +(make-obsolete-variable + 'font-lock-warning-face + "use the quoted symbol instead: \\='font-lock-warning-face" "31.1") (defvar font-lock-warning-face 'font-lock-warning-face "Face name to use for things that should stand out.") +(make-obsolete-variable + 'font-lock-negation-char-face + "use the quoted symbol instead: \\='font-lock-negation-char-face" "31.1") (defvar font-lock-negation-char-face 'font-lock-negation-char-face "Face name to use for easy to overlook negation. This can be an \"!\" or the \"n\" in \"ifndef\".") +(make-obsolete-variable + 'font-lock-preprocessor-face + "use the quoted symbol instead: \\='font-lock-preprocessor-face" "31.1") (defvar font-lock-preprocessor-face 'font-lock-preprocessor-face "Face name to use for preprocessor directives.") + ;; Fontification variables: (defvar font-lock-keywords nil diff --git a/lisp/generic-x.el b/lisp/generic-x.el index 373bfad92dd..d2f3ad30245 100644 --- a/lisp/generic-x.el +++ b/lisp/generic-x.el @@ -702,9 +702,9 @@ like an INI file. You can add this hook to `find-file-hook'." "FILETYPE" "FILEVERSION" "PRODUCTVERSION") 'symbols) - 1 font-lock-type-face) + 1 'font-lock-type-face) (list (regexp-opt '("BEGIN" "BLOCK" "END" "VALUE") 'symbols) - 1 font-lock-function-name-face) + 1 'font-lock-function-name-face) '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face) '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face) '("^#[ \t]*\\(elif\\|if\\)\\>" @@ -1323,22 +1323,22 @@ like an INI file. You can add this hook to `find-file-hook'." (list (concat "[^_]" (regexp-opt installshield-system-variables-list 'symbols) "[^_]") - 1 font-lock-variable-name-face) + 1 'font-lock-variable-name-face) ;; system functions (list (concat "[^_]" (regexp-opt installshield-system-functions-list 'symbols) "[^_]") - 1 font-lock-function-name-face) + 1 'font-lock-function-name-face) ;; type keywords (list (concat "[^_]" (regexp-opt installshield-types-list 'symbols) "[^_]") - 1 font-lock-type-face) + 1 'font-lock-type-face) ;; function argument constants (list (concat "[^_]" (regexp-opt installshield-funarg-constants-list 'symbols) "[^_]") - 1 font-lock-variable-name-face))) ; is this face the best choice? + 1 'font-lock-variable-name-face))) ; is this face the best choice? '("\\.[rR][uU][lL]\\'") '(generic-rul-mode-setup-function) "Generic mode for InstallShield RUL files.") diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 222bc7d9658..9f4421deef4 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -3412,7 +3412,7 @@ Parameters get priority." (when title (unless (bobp) (insert "\n")) (insert - (org-add-props (cdr title) nil 'face font-lock-comment-face)) + (org-add-props (cdr title) nil 'face 'font-lock-comment-face)) (setq titles (remove title titles))) (when (equal key (car entry)) (setq startline (org-current-line))) (let ((s (concat diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 83afe081b85..b18561667f8 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -122,8 +122,6 @@ 'font-lock-reference-face) (t 'font-lock-constant-face))) -(cc-bytecomp-defvar font-lock-constant-face) - (defconst c-label-face-name (cond ((c-face-name-p 'font-lock-label-face) ;; If it happens to occur in the future. (Well, the more @@ -712,7 +710,7 @@ stuff. Used on level 1 and higher." (< (point) end)) (if (and (equal (c-get-char-property (point) 'syntax-table) '(1)) (not (c-get-char-property (point) 'c-digit-separator))) - (c-put-font-lock-face (point) (1+ (point)) font-lock-warning-face)) + (c-put-font-lock-face (point) (1+ (point)) 'font-lock-warning-face)) (forward-char)) (parse-partial-sexp end limit nil nil state 'syntax-table))) nil) @@ -743,7 +741,7 @@ stuff. Used on level 1 and higher." ;; Font lock the block comment ender with warning face. (when (not (nth 4 s)) (c-put-font-lock-face (- (point) (length c-block-comment-ender)) - (point) font-lock-warning-face))) + (point) 'font-lock-warning-face))) (t ; In a line comment, or a "valid" block comment (setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table)))) @@ -760,14 +758,14 @@ stuff. Used on level 1 and higher." (setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table))) ((nth 4 s) ; In an invalid comment ;; Fontify the invalid comment opener. - (c-put-font-lock-face (nth 8 s) (point) font-lock-warning-face) + (c-put-font-lock-face (nth 8 s) (point) 'font-lock-warning-face) ;; Move to end of comment or LIMIT. (setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table)) ;; Fontify an invalid block comment ender, if that's what we have. (when (and (not c-block-comment-flag) (not (nth 4 s))) ; We're outside the comment (c-put-font-lock-face (- (point) (length c-block-comment-ender)) - (point) font-lock-warning-face))))))) + (point) 'font-lock-warning-face))))))) nil) (c-lang-defconst c-basic-matchers-before @@ -1173,7 +1171,7 @@ casts and declarations are fontified. Used on level 2 and higher." (c-put-font-lock-face (point) (progn (c-forward-over-token) (point)) - font-lock-function-name-face))))) + 'font-lock-function-name-face))))) (and template-class (eq init-char ?=) ; C++ ""? (progn @@ -2066,7 +2064,7 @@ casts and declarations are fontified. Used on level 2 and higher." ((and capture-default (eq mode capture-default)) 'font-lock-warning-face) - ((eq mode ?=) font-lock-constant-face) + ((eq mode ?=) 'font-lock-constant-face) (t 'font-lock-variable-name-face)))) (c-syntactic-re-search-forward "," limit 'bound t)) @@ -2194,7 +2192,7 @@ casts and declarations are fontified. Used on level 2 and higher." (c-put-font-lock-face (1+ beg) (if end (1- end) (point)) font-lock-string-face) (c-put-font-lock-face - beg (or end (point)) font-lock-string-face)) + beg (or end (point)) 'font-lock-string-face)) (c-forward-syntactic-ws limit) t) (t nil))) @@ -2234,9 +2232,9 @@ casts and declarations are fontified. Used on level 2 and higher." c-reference-face-name))) ;; No semicolon, so put warning faces on any delimiters. (when beg - (c-put-font-lock-face beg (1+ beg) font-lock-warning-face)) + (c-put-font-lock-face beg (1+ beg) 'font-lock-warning-face)) (when end - (c-put-font-lock-face (1- end) end font-lock-warning-face)))))))) + (c-put-font-lock-face (1- end) end 'font-lock-warning-face)))))))) (c-lang-defconst c-simple-decl-matchers "Simple font lock matchers for types and declarations. These are used diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 87ff3e86a41..3c49466e7f4 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -4030,10 +4030,10 @@ an attribute. ST-L and POS are a cached from a previous call." (and (match-beginning 1) (cperl-postpone-fontification (match-beginning 0) (cperl-1+ (match-beginning 0)) - 'face font-lock-constant-face)) + 'face 'font-lock-constant-face)) (setq start1 (match-beginning 3) end1 (match-end 3)) (cperl-postpone-fontification start1 end1 - 'face font-lock-constant-face) + 'face 'font-lock-constant-face) (goto-char end1) ; end or before `(' (if (match-end 4) ; Have attribute arguments... (progn @@ -4102,7 +4102,7 @@ If IS-X-REX is non-nil, then process a regular expression which has an (if (eq ?\{ (preceding-char)) nil (cperl-postpone-fontification (1- (point)) (point) - 'face font-lock-warning-face)))) + 'face 'font-lock-warning-face)))) ;; Do some smarter-highlighting ;; XXXX Currently ignores alphanum/dash delims, @@ -4219,7 +4219,7 @@ END-OF-HERE-DOC is the end of a previous here-doc in the same line, or nil if this is the first. DELIM-BEGIN and DELIM-END are the positions where the here-document's delimiter has been found. This is part of `cperl-find-pods-heres' (below)." - (let* ((my-cperl-delimiters-face font-lock-constant-face) + (let* ((my-cperl-delimiters-face 'font-lock-constant-face) (delimiter (buffer-substring-no-properties delim-begin delim-end)) (qtag (regexp-quote delimiter)) (use-syntax-state (and cperl-syntax-state @@ -4358,23 +4358,18 @@ recursive calls in starting lines of here-documents." (cdr cperl-syntax-state))) ;; (st-l '(nil)) (err-l '(nil)) ; Would overwrite - propagates from a function call to a function call! (st-l (list nil)) (err-l (list nil)) - ;; Somehow font-lock may be not loaded yet... - ;; (e.g., when building TAGS via command-line call) - (font-lock-string-face (if (boundp 'font-lock-string-face) - font-lock-string-face - 'font-lock-string-face)) - (my-cperl-delimiters-face - font-lock-constant-face) + (my-cperl-delimiters-face + 'font-lock-constant-face) (my-cperl-REx-spec-char-face ; [] ^.$ and wrapper-of ({}) - font-lock-function-name-face) + 'font-lock-function-name-face) (my-cperl-REx-0length-face ; 0-length, (?:)etc, non-literal \ - font-lock-builtin-face) + 'font-lock-builtin-face) (my-cperl-REx-ctl-face ; (|) - font-lock-keyword-face) + 'font-lock-keyword-face) (my-cperl-REx-modifiers-face ; //gims 'cperl-nonoverridable-face) (my-cperl-REx-length1-face ; length=1 escaped chars, POSIX classes - font-lock-type-face) + 'font-lock-type-face) (stop-point (if ignore-max (point-max) max)) @@ -4639,7 +4634,7 @@ recursive calls in starting lines of here-documents." (end-of-line) ;; Highlight the format line (cperl-postpone-fontification b1 (point) - 'face font-lock-string-face) + 'face 'font-lock-string-face) (cperl-commentify b1 (point) nil) (cperl-put-do-not-fontify b1 (point) t)))) ;; We do not search to max, since we may be called from @@ -4650,7 +4645,7 @@ recursive calls in starting lines of here-documents." (progn ;; Highlight the ending delimiter (cperl-postpone-fontification (point) (+ (point) 1) - 'face font-lock-string-face) + 'face 'font-lock-string-face) (cperl-commentify (point) (+ (point) 1) nil) (cperl-put-do-not-fontify (point) (+ (point) 1) t)) (setq warning-message @@ -4921,7 +4916,7 @@ recursive calls in starting lines of here-documents." (not (looking-at "split\\>"))) (error t)))) (cperl-postpone-fontification - b e 'face font-lock-warning-face) + b e 'face 'font-lock-warning-face) (if (or i2 ; Has 2 args (and cperl-fontify-m-as-s (or @@ -5037,8 +5032,8 @@ recursive calls in starting lines of here-documents." (eq (char-after (1+ (point))) ?\?)) my-cperl-REx-0length-face my-cperl-REx-ctl-face) - font-lock-warning-face)) - (error font-lock-warning-face))) + 'font-lock-warning-face)) + (error 'font-lock-warning-face))) ((eq was-subgr ?\| ) my-cperl-REx-ctl-face) ((eq was-subgr ?\$ ) @@ -5052,7 +5047,7 @@ recursive calls in starting lines of here-documents." (1+ b)) (eq (point) (1- e))) 1 t))) - font-lock-variable-name-face) + 'font-lock-variable-name-face) my-cperl-REx-spec-char-face)) ((memq was-subgr (append "^." nil) ) my-cperl-REx-spec-char-face) @@ -5080,7 +5075,7 @@ recursive calls in starting lines of here-documents." (- (point) 2) (- (point) 1) 'face (if (memq qtag (append "ghijkmoqvFHIJKMORTVY" nil)) - font-lock-warning-face + 'font-lock-warning-face my-cperl-REx-0length-face)) (if (and (eq (char-after b) qtag) (memq qtag (append ".])^$|*?+" nil))) @@ -5221,7 +5216,7 @@ recursive calls in starting lines of here-documents." (while tag (cperl-postpone-fontification (car (car tag)) (cdr (car tag)) - 'face font-lock-variable-name-face) ;my-cperl-REx-length1-face + 'face 'font-lock-variable-name-face) ;my-cperl-REx-length1-face (setq tag (cdr tag))) (setq was-subgr nil)) ; did facing already ;; Now rare stuff: @@ -5239,7 +5234,7 @@ recursive calls in starting lines of here-documents." 'syntax-table cperl-st-punct)) (cperl-postpone-fontification (1- (point)) (point) - 'face font-lock-warning-face)) + 'face 'font-lock-warning-face)) ((match-beginning 5) ; before (?{}) (??{}) (setq tag (match-end 0)) (if (or (setq qtag @@ -5255,7 +5250,7 @@ recursive calls in starting lines of here-documents." (format "%s" qtag))) (cperl-postpone-fontification (1- tag) (1- (point)) - 'face font-lock-variable-name-face) + 'face 'font-lock-variable-name-face) (cperl-postpone-fontification REx-subgr-start (1- tag) 'face my-cperl-REx-spec-char-face) @@ -5293,7 +5288,7 @@ recursive calls in starting lines of here-documents." REx-subgr-start REx-subgr-end nil) (cperl-postpone-fontification REx-subgr-start REx-subgr-end - 'face font-lock-comment-face)))))) + 'face 'font-lock-comment-face)))))) (if (and is-REx is-x-REx) (put-text-property (1+ b) (1- e) 'syntax-subtype 'x-REx))) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index b60e21ff0ae..3ac603109dc 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1102,7 +1102,7 @@ detailed description of this mode. (setq gdb-buffer-type 'gdbmi) ;; (gdb-force-mode-line-update - (propertize "initializing..." 'face font-lock-variable-name-face)) + (propertize "initializing..." 'face 'font-lock-variable-name-face)) ;; This needs to be done before we ask GDB for anything that might ;; trigger questions about debuginfod queries. @@ -2122,7 +2122,7 @@ If `gdb-thread-number' is nil, just wrap NAME in asterisks." If NO-PROC is non-nil, do not try to contact the GDB process." (when gdb-first-prompt (gdb-force-mode-line-update - (propertize "initializing..." 'face font-lock-variable-name-face)) + (propertize "initializing..." 'face 'font-lock-variable-name-face)) (gdb-init-1) (setq gdb-first-prompt nil)) @@ -2678,7 +2678,7 @@ Sets `gdb-thread-number' to new id." (setq gdb-frame-number nil))) (setq gdb-inferior-status "running") (gdb-force-mode-line-update - (propertize gdb-inferior-status 'face font-lock-type-face)) + (propertize gdb-inferior-status 'face 'font-lock-type-face)) (when (not gdb-non-stop) (setq gud-running t)) (setq gdb-active-process t)) @@ -2697,7 +2697,7 @@ Sets `gdb-thread-number' to new id." (setq gud-async-running nil)) (gdb-force-mode-line-update - (propertize gdb-inferior-status 'face font-lock-type-face)) + (propertize gdb-inferior-status 'face 'font-lock-type-face)) (setq gdb-active-process t) (setq gud-running t) (gud-hide-current-line-indicator nil)) @@ -2734,7 +2734,7 @@ current thread and update GDB buffers." (setq gdb-inferior-status (or reason "unknown")) (gdb-force-mode-line-update - (propertize gdb-inferior-status 'face font-lock-warning-face)) + (propertize gdb-inferior-status 'face 'font-lock-warning-face)) (if (string-equal reason "exited-normally") (setq gdb-active-process nil)) @@ -2795,7 +2795,7 @@ current thread and update GDB buffers." (gdb-mi--c-string-from-string output-field))) (put-text-property 0 (length error-message) - 'face font-lock-warning-face + 'face 'font-lock-warning-face error-message) error-message))))) @@ -3205,10 +3205,10 @@ See `def-gdb-auto-update-handler'." (if (string-equal flag "y") (eval-when-compile (propertize "y" 'font-lock-face - font-lock-warning-face)) + 'font-lock-warning-face)) (eval-when-compile (propertize "n" 'font-lock-face - font-lock-comment-face)))) + 'font-lock-comment-face)))) addr (or (gdb-mi--field bkpt 'times) "") (if (and type (string-match ".*watchpoint" type)) @@ -3218,7 +3218,7 @@ See `def-gdb-auto-update-handler'." (concat "in " (propertize (or func "unknown") 'font-lock-face - font-lock-function-name-face) + 'font-lock-function-name-face) (gdb-frame-location bkpt))))) ;; Add clickable properties only for ;; breakpoints with file:line information @@ -4565,8 +4565,8 @@ left-to-right display order of the properties." local-map ,gdb-edit-locals-map-1) value)) (setf (gdb-table-right-align table) t) - (setq name (propertize name 'font-lock-face font-lock-variable-name-face)) - (setq type (propertize type 'font-lock-face font-lock-type-face)) + (setq name (propertize name 'font-lock-face 'font-lock-variable-name-face)) + (setq type (propertize type 'font-lock-face 'font-lock-type-face)) (gdb-table-add-row table (gdb-locals-table-columns-list `((name . ,name) @@ -4685,9 +4685,9 @@ executes FUNCTION." table (list (propertize register-name - 'font-lock-face font-lock-variable-name-face) + 'font-lock-face 'font-lock-variable-name-face) (if (member register-number gdb-changed-registers) - (propertize value 'font-lock-face font-lock-warning-face) + (propertize value 'font-lock-face 'font-lock-warning-face) value)) `(mouse-face highlight help-echo "mouse-2: edit value" @@ -5320,7 +5320,7 @@ buffers, if required." gdb-main-file (display-buffer (gud-find-file gdb-main-file)))) (gdb-force-mode-line-update - (propertize "ready" 'face font-lock-variable-name-face))) + (propertize "ready" 'face 'font-lock-variable-name-face))) ;;from put-image (defun gdb-put-string (putstring pos &optional dprop &rest sprops) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index b044dc44560..5515b58269a 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -299,15 +299,15 @@ Match group 1 is the name of the macro.") (defconst js--font-lock-keywords-1 (list "\\_" - (list js--function-heading-1-re 1 font-lock-function-name-face) - (list js--function-heading-2-re 1 font-lock-function-name-face)) + (list js--function-heading-1-re 1 'font-lock-function-name-face) + (list js--function-heading-2-re 1 'font-lock-function-name-face)) "Level one font lock keywords for `js-mode'.") (defconst js--font-lock-keywords-2 (append js--font-lock-keywords-1 - (list (list js--keyword-re 1 font-lock-keyword-face) - (cons js--basic-type-re font-lock-type-face) - (cons js--constant-re font-lock-constant-face))) + (list (list js--keyword-re 1 'font-lock-keyword-face) + (cons js--basic-type-re 'font-lock-type-face) + (cons js--constant-re 'font-lock-constant-face))) "Level two font lock keywords for `js-mode'.") ;; js--pitem is the basic building block of the lexical @@ -1854,12 +1854,12 @@ This performs fontification according to `js--class-styles'." (defun js-font-lock-syntactic-face-function (state) "Return syntactic face given STATE." (if (nth 3 state) - font-lock-string-face + 'font-lock-string-face (if (save-excursion (goto-char (nth 8 state)) (looking-at "/\\*\\*")) - font-lock-doc-face - font-lock-comment-face))) + 'font-lock-doc-face + 'font-lock-comment-face))) (defconst js--syntax-propertize-regexp-regexp (rx diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 24be7f1a09c..9d2969d6ac4 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -153,11 +153,11 @@ values of OVERRIDE." (string-match "\\`--" node-text)) (treesit-fontify-with-override node-start delimiter-end - font-lock-comment-delimiter-face + 'font-lock-comment-delimiter-face override)) (treesit-fontify-with-override (max delimiter-end start) (min node-end end) - font-lock-comment-face + 'font-lock-comment-face override))) (defvar lua-ts--font-lock-settings diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el index 6b34997799f..20806876592 100644 --- a/lisp/progmodes/meta-mode.el +++ b/lisp/progmodes/meta-mode.el @@ -535,7 +535,7 @@ If the list was changed, sort the list and remove duplicates first." (defun meta-indent-in-string-p () "Tell if the point is in a string." (or (nth 3 (syntax-ppss)) - (eq (get-text-property (point) 'face) font-lock-string-face))) + (eq (get-text-property (point) 'face) 'font-lock-string-face))) (defun meta-indent-looking-at-code (regexp) "Same as `looking-at' but checks that the point is not in a string." diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el index 97f08a79ccd..56e79f9e595 100644 --- a/lisp/progmodes/prolog.el +++ b/lisp/progmodes/prolog.el @@ -1922,12 +1922,12 @@ Argument BOUND is a buffer position limiting searching." ;; "Native" Prolog patterns (head-predicates (list (format "^\\(%s\\)\\((\\|[ \t]*:-\\)" prolog-atom-regexp) - 1 font-lock-function-name-face)) + 1 'font-lock-function-name-face)) ;(list (format "^%s" prolog-atom-regexp) ; 0 font-lock-function-name-face)) (head-predicates-1 (list (format "\\.[ \t]*\\(%s\\)" prolog-atom-regexp) - 1 font-lock-function-name-face) ) + 1 'font-lock-function-name-face)) (variables '("\\<\\([_A-Z][a-zA-Z0-9_]*\\)" 1 font-lock-variable-name-face)) @@ -1941,7 +1941,7 @@ Argument BOUND is a buffer position limiting searching." (predspecs ; module:predicate/cardinality (list (format "\\<\\(%s:\\|\\)%s/[0-9]+" prolog-atom-regexp prolog-atom-regexp) - 0 font-lock-function-name-face 'prepend)) + 0 'font-lock-function-name-face 'prepend)) (keywords ; directives (queries) (list (if (eq prolog-system 'mercury) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index de1c6f551c4..a383690ba6d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -569,9 +569,9 @@ The type returned can be `comment', `string' or `paren'." "Return syntactic face given STATE." (if (nth 3 state) (if (python-info-docstring-p state) - font-lock-doc-face - font-lock-string-face) - font-lock-comment-face)) + 'font-lock-doc-face + 'font-lock-string-face) + 'font-lock-comment-face)) (defconst python--f-string-start-regexp (rx bow diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 7d108ed9841..58a7eab0d1a 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -223,9 +223,9 @@ values of OVERRIDE." (<= plus-1 end) (string-match-p "\\`#" text)) (treesit-fontify-with-override node-start plus-1 - font-lock-comment-delimiter-face override)) + 'font-lock-comment-delimiter-face override)) (treesit-fontify-with-override (max plus-1 start) (min node-end end) - font-lock-comment-face override))) + 'font-lock-comment-face override))) (defun ruby-ts--font-lock-settings (language) "Tree-sitter font-lock settings for Ruby." diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index eb024ddc475..a230d2fa5c7 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1128,9 +1128,9 @@ subshells can nest." (let ((q (nth 3 state))) (if q (if (characterp q) - (if (eq q ?\`) 'sh-quoted-exec font-lock-string-face) + (if (eq q ?\`) 'sh-quoted-exec 'font-lock-string-face) 'sh-heredoc) - font-lock-comment-face))) + 'font-lock-comment-face))) (defgroup sh-indentation nil "Variables controlling indentation in shell scripts. diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index c82e589632e..e30f13c0644 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -3070,7 +3070,7 @@ There might be text before point." '(?\n nil)))) ;; Anything else is just as for LaTeX. (tex-font-lock-syntactic-face-function state) - font-lock-doc-face)) + 'font-lock-doc-face)) (eval-when-compile (defconst doctex-syntax-propertize-rules diff --git a/test/lisp/faces-tests.el b/test/lisp/faces-tests.el index 529eb846bbd..db199bdd5b7 100644 --- a/test/lisp/faces-tests.el +++ b/test/lisp/faces-tests.el @@ -58,6 +58,17 @@ "" :group 'faces--test) +(defmacro faces---with-tmp-face (face bg fg &rest body) + (declare (indent 3)) + `(let ((old-fg (face-foreground ,face)) + (old-bg (face-background ,face))) + (unwind-protect + (progn (set-face-foreground ,face ,fg) + (set-face-background ,face ,bg) + ,@body) + (set-face-foreground ,face old-fg) + (set-face-background ,face old-bg)))) + (ert-deftest faces--test-color-at-point () (with-temp-buffer (insert (propertize "STRING" 'face '(faces--test2 faces--test1))) @@ -71,16 +82,16 @@ (should (equal (foreground-color-at-point) "black"))) (with-temp-buffer (emacs-lisp-mode) - (setq-local font-lock-comment-face 'faces--test1) - (setq-local font-lock-constant-face 'faces--test2) - (insert ";; `symbol'") - (font-lock-fontify-region (point-min) (point-max)) - (goto-char (point-min)) - (should (equal (background-color-at-point) "black")) - (should (equal (foreground-color-at-point) "black")) - (goto-char 6) - (should (equal (background-color-at-point) "black")) - (should (equal (foreground-color-at-point) "black")))) + (faces---with-tmp-face 'font-lock-comment-face "black" "black" + (faces---with-tmp-face 'font-lock-constant-face "black" "black" + (insert ";; `symbol'") + (font-lock-fontify-region (point-min) (point-max)) + (goto-char (point-min)) + (should (equal (background-color-at-point) "black")) + (should (equal (foreground-color-at-point) "black")) + (goto-char 6) + (should (equal (background-color-at-point) "black")) + (should (equal (foreground-color-at-point) "black")))))) (ert-deftest faces--test-face-id () ;; Face ID of 0 is the 'default' face; no face should have the same ID. diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 7a6e0b3b64a..e51ad2ec2d5 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -925,26 +925,26 @@ have extra paired delimiters." (goto-char (point-min)) (search-forward-regexp "\\(label:\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-constant-face)) + 'font-lock-constant-face)) (search-forward-regexp "\\(comment\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-comment-face)) + 'font-lock-comment-face)) (search-forward-regexp "\\(sanity\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-variable-name-face)) + 'font-lock-variable-name-face)) ;; Now switch off the minor mode and redo (cperl-extra-paired-delimiters-mode -1) (font-lock-ensure) (goto-char (point-min)) (search-forward-regexp "\\(label:\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-string-face)) + 'font-lock-string-face)) (search-forward-regexp "\\(comment\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-string-face)) + 'font-lock-string-face)) (search-forward-regexp "\\(sanity\\)") (should (equal (get-text-property (match-beginning 1) 'face) - font-lock-variable-name-face)))) + 'font-lock-variable-name-face)))) ;;; Function test: Building an index for imenu @@ -1364,13 +1364,13 @@ as that quote like operator." (search-forward "bar") (should (equal (get-text-property (match-beginning 0) 'face) 'font-lock-string-face)) - ; perl-mode doesn't highlight + ;; perl-mode doesn't highlight (when (eq cperl-test-mode #'cperl-mode) (search-forward "_") (should (equal (get-text-property (match-beginning 0) 'face) (if (eq cperl-test-mode #'cperl-mode) 'font-lock-constant-face - font-lock-string-face)))))) + 'font-lock-string-face)))))) (ert-deftest cperl-test-hyperactive-electric-else () "Demonstrate cperl-electric-else behavior. @@ -1511,10 +1511,10 @@ detected as left-shift operator." (font-lock-ensure) (search-forward "retur") ; leaves point before the "n" (should (equal (get-text-property (point) 'face) - font-lock-keyword-face)) + 'font-lock-keyword-face)) (search-forward "# comm") ; leaves point before "ent" (should (equal (get-text-property (point) 'face) - font-lock-comment-face)))) + 'font-lock-comment-face)))) (ert-deftest cperl-test-bug-66145 () "Verify that hashes and arrays are only fontified in code. @@ -1528,7 +1528,7 @@ beginning with `cperl-test-unicode`." ("comment" . font-lock-comment-face) ("here" . ,(if (equal cperl-test-mode 'perl-mode) 'perl-heredoc - font-lock-string-face))))) + 'font-lock-string-face))))) (with-temp-buffer (insert-file-contents (ert-resource-file "cperl-bug-66145.pl")) (funcall cperl-test-mode) @@ -1552,7 +1552,7 @@ cperl-mode fontifies text after the delimiter as Perl code." (font-lock-ensure) (search-forward "TODO") ; leaves point before the colon (should (equal (get-text-property (point) 'face) - font-lock-comment-face)))) + 'font-lock-comment-face)))) (ert-deftest cperl-test-bug-69604 () "Verify that $\" in a double-quoted string does not end the string. @@ -1571,7 +1571,7 @@ not appropriate." (goto-char (point-min)) (search-forward "in string") (should (equal (get-text-property (point) 'face) - font-lock-string-face)))))) + 'font-lock-string-face)))))) (ert-deftest cperl-test-bug-72296 () "Verify that the perl modes correctly handle the flip-flop operator. diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index ac17c5b1263..8e99ab7aa60 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -7673,14 +7673,14 @@ always located at the beginning of buffer." (python-ts-tests-with-temp-buffer (concat "t " test " t") (forward-to-word 1) - (should (eq (face-at-point) font-lock-keyword-face)) + (should (eq (face-at-point) 'font-lock-keyword-face)) (forward-to-word 1) - (should (eq (face-at-point) font-lock-keyword-face))))) + (should (eq (face-at-point) 'font-lock-keyword-face))))) (ert-deftest python-ts-mode-named-assignment-face-1 () (python-ts-tests-with-temp-buffer "var := 3" - (should (eq (face-at-point) font-lock-variable-name-face)))) + (should (eq (face-at-point) 'font-lock-variable-name-face)))) (ert-deftest python-ts-mode-assignment-face-2 () (python-ts-tests-with-temp-buffer @@ -7688,14 +7688,14 @@ always located at the beginning of buffer." (dolist (test '("var" "rest")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-variable-name-face)))) + (should (eq (face-at-point) 'font-lock-variable-name-face)))) (python-ts-tests-with-temp-buffer "def func(*args):" (dolist (test '("args")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-variable-name-face)))))) + (should (not (eq (face-at-point) 'font-lock-variable-name-face)))))) (ert-deftest python-ts-mode-nested-types-face-1 () (python-ts-tests-with-temp-buffer @@ -7703,7 +7703,7 @@ always located at the beginning of buffer." (dolist (test '("dict" "list" "tuple" "str" "int" "None" "None")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-union-types-face-1 () (python-ts-tests-with-temp-buffer @@ -7711,7 +7711,7 @@ always located at the beginning of buffer." (dolist (test '("tuple" "tuple" "list" "Lvl1" "Lvl2" "Lvl3" "Lvl4" "Lvl5" "None" "Lvl2")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-union-types-face-2 () (python-ts-tests-with-temp-buffer @@ -7719,24 +7719,24 @@ always located at the beginning of buffer." (dolist (test '("Type0" "Type1" "Type2" "Type3" "Type4" "None")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))) + (should (eq (face-at-point) 'font-lock-type-face))) (goto-char (point-min)) (dolist (test '("pack0" "pack1" "pack2")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))))) + (should (not (eq (face-at-point) 'font-lock-type-face)))))) (ert-deftest python-ts-mode-types-face-1 () (python-ts-tests-with-temp-buffer "def f(val: Callable[[Type0], (Type1, Type2)]):" (search-forward "val") (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-variable-name-face)) + (should (eq (face-at-point) 'font-lock-variable-name-face)) (dolist (test '("Callable" "Type0" "Type1" "Type2")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-types-face-2 () (python-ts-tests-with-temp-buffer @@ -7744,12 +7744,12 @@ always located at the beginning of buffer." (dolist (test '("Type0" "Type1")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))) + (should (eq (face-at-point) 'font-lock-type-face))) (goto-char (point-min)) (dolist (test '("pack0" "pack1" "pack2" "pack3")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))))) + (should (not (eq (face-at-point) 'font-lock-type-face)))))) (ert-deftest python-ts-mode-types-face-3 () (python-ts-tests-with-temp-buffer @@ -7757,12 +7757,12 @@ always located at the beginning of buffer." (dolist (test '("Iterator" "Type0")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))) + (should (eq (face-at-point) 'font-lock-type-face))) (goto-char (point-min)) (dolist (test '("collections" "abc")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))))) + (should (not (eq (face-at-point) 'font-lock-type-face)))))) (ert-deftest python-ts-mode-isinstance-type-face-1 () (python-ts-tests-with-temp-buffer @@ -7774,13 +7774,13 @@ always located at the beginning of buffer." (let ((case-fold-search nil)) (search-forward test)) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))) + (should (not (eq (face-at-point) 'font-lock-type-face)))) (goto-char (point-min)) (dolist (test '("Type0" "str" "dict" "Type1")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-isinstance-type-face-2 () (python-ts-tests-with-temp-buffer @@ -7788,7 +7788,7 @@ always located at the beginning of buffer." (dolist (test '("int" "list" "Iterable")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-isinstance-type-face-3 () (python-ts-tests-with-temp-buffer @@ -7799,13 +7799,13 @@ always located at the beginning of buffer." (dolist (test '("typevar1" "typevar2" "pkg0" "self" "typevar3" "typevar4")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))) + (should (not (eq (face-at-point) 'font-lock-type-face)))) (goto-char (point-min)) (dolist (test '("Type1" "tuple" "Coll" "Type2")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-superclass-type-face () (python-ts-tests-with-temp-buffer @@ -7814,13 +7814,13 @@ always located at the beginning of buffer." (dolist (test '("Base1" "Base2" "Sequence" "T1" "T2")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))) + (should (eq (face-at-point) 'font-lock-type-face))) (goto-char (point-min)) (dolist (test '("pack0")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))))) + (should (not (eq (face-at-point) 'font-lock-type-face)))))) (ert-deftest python-ts-mode-class-patterns-face () (python-ts-tests-with-temp-buffer @@ -7835,13 +7835,13 @@ always located at the beginning of buffer." (dolist (test '("str" "Type0" "bytes" "Type1" "int" "float")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))) + (should (eq (face-at-point) 'font-lock-type-face))) (goto-char (point-min)) (dolist (test '("pack0" "pack1")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-type-face)))))) + (should (not (eq (face-at-point) 'font-lock-type-face)))))) (ert-deftest python-ts-mode-dotted-decorator-face-1 () (python-ts-tests-with-temp-buffer @@ -7852,7 +7852,7 @@ always located at the beginning of buffer." (dolist (test '("pytest" "mark" "skip" "pytest" "mark" "skip")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-dotted-decorator-face-2 () (python-ts-tests-with-temp-buffer @@ -7863,14 +7863,14 @@ always located at the beginning of buffer." (dolist (test '("pytest" "mark" "skip")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-type-face))))) + (should (eq (face-at-point) 'font-lock-type-face))))) (ert-deftest python-ts-mode-builtin-call-face () (python-ts-tests-with-temp-buffer "all()" ;; enable 'function' feature from 4th level (setopt treesit-font-lock-level 4) - (should (eq (face-at-point) font-lock-builtin-face)))) + (should (eq (face-at-point) 'font-lock-builtin-face)))) (ert-deftest python-ts-mode-interpolation-nested-string () (python-ts-tests-with-temp-buffer @@ -7878,20 +7878,20 @@ always located at the beginning of buffer." (search-forward "True") (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-constant-face)) + (should (eq (face-at-point) 'font-lock-constant-face)) (goto-char (point-min)) (dolist (test '("f" "{" "+" "}")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-string-face)))) + (should (not (eq (face-at-point) 'font-lock-string-face)))) (goto-char (point-min)) (dolist (test '("beg" "'string'" "\"")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-string-face))))) + (should (eq (face-at-point) 'font-lock-string-face))))) (ert-deftest python-ts-mode-level-fontification-wo-interpolation () (python-ts-tests-with-temp-buffer @@ -7900,12 +7900,12 @@ always located at the beginning of buffer." (setopt treesit-font-lock-level 2) (search-forward "f") (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-string-face))) + (should (not (eq (face-at-point) 'font-lock-string-face))) (dolist (test '("\"" "beg" "{" "True" "var" "}" "\"")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-string-face))))) + (should (eq (face-at-point) 'font-lock-string-face))))) (ert-deftest python-ts-mode-disabled-string-interpolation () (python-ts-tests-with-temp-buffer @@ -7919,12 +7919,12 @@ always located at the beginning of buffer." (search-forward "f") (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-string-face))) + (should (not (eq (face-at-point) 'font-lock-string-face))) (dolist (test '("\"" "beg" "{" "True" "var" "}" "\"")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-string-face)))) + (should (eq (face-at-point) 'font-lock-string-face)))) (setf (nth 2 treesit-font-lock-feature-list) (append (nth 2 treesit-font-lock-feature-list) '(string-interpolation)))))) @@ -7935,25 +7935,25 @@ always located at the beginning of buffer." (search-forward "True") (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-constant-face)) + (should (eq (face-at-point) 'font-lock-constant-face)) (goto-char (point-min)) (dolist (test '("f" "{" "+" "}")) (search-forward test) (goto-char (match-beginning 0)) - (should (not (eq (face-at-point) font-lock-string-face)))) + (should (not (eq (face-at-point) 'font-lock-string-face)))) (goto-char (point-min)) (dolist (test '("\"\"\"" "beg" "end" "\"\"\"")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-doc-face))) + (should (eq (face-at-point) 'font-lock-doc-face))) (goto-char (point-min)) (dolist (test '("'s1'" "'s2'")) (search-forward test) (goto-char (match-beginning 0)) - (should (eq (face-at-point) font-lock-string-face))))) + (should (eq (face-at-point) 'font-lock-string-face))))) (provide 'python-tests) diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index c9cde791baa..737b4e7d9c6 100644 --- a/test/lisp/progmodes/ruby-mode-tests.el +++ b/test/lisp/progmodes/ruby-mode-tests.el @@ -87,14 +87,14 @@ VALUES-PLIST is a list with alternating index and value elements." (ert-deftest ruby-heredoc-font-lock () (let ((s "foo <
  • #{@files.join(\"
  • \")}
  • \"")) (ruby-assert-state s 8 nil) - (ruby-assert-face s 9 font-lock-string-face) - (ruby-assert-face s 10 font-lock-variable-name-face) - (ruby-assert-face s 41 font-lock-string-face))) + (ruby-assert-face s 9 'font-lock-string-face) + (ruby-assert-face s 10 'font-lock-variable-name-face) + (ruby-assert-face s 41 'font-lock-string-face))) (ert-deftest ruby-interpolation-suppresses-one-double-quote () (let ((s "\"foo#{'\"'}\"")) (ruby-assert-state s 8 nil) - (ruby-assert-face s 8 font-lock-variable-name-face) - (ruby-assert-face s 11 font-lock-string-face))) + (ruby-assert-face s 8 'font-lock-variable-name-face) + (ruby-assert-face s 11 'font-lock-string-face))) (ert-deftest ruby-interpolation-suppresses-one-backtick () (let ((s "`as#{'`'}das`")) @@ -469,39 +469,39 @@ VALUES-PLIST is a list with alternating index and value elements." (ert-deftest ruby-interpolation-inside-percent-literal () (let ((s "%( #{boo} )")) - (ruby-assert-face s 1 font-lock-string-face) - (ruby-assert-face s 4 font-lock-variable-name-face) - (ruby-assert-face s 10 font-lock-string-face) + (ruby-assert-face s 1 'font-lock-string-face) + (ruby-assert-face s 4 'font-lock-variable-name-face) + (ruby-assert-face s 10 'font-lock-string-face) (ruby-assert-state s 8 nil))) (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () :expected-result :failed (let ((s "%(^#{\")\"}^)")) - (ruby-assert-face s 3 font-lock-string-face) - (ruby-assert-face s 4 font-lock-variable-name-face) - (ruby-assert-face s 10 font-lock-string-face) + (ruby-assert-face s 3 'font-lock-string-face) + (ruby-assert-face s 4 'font-lock-variable-name-face) + (ruby-assert-face s 10 'font-lock-string-face) ;; It's confused by the closing paren in the middle. (ruby-assert-state s 8 nil))) (ert-deftest ruby-interpolation-inside-another-interpolation () :expected-result :failed (let ((s "\"#{[a, b, c].map { |v| \"#{v}\" }.join}\"")) - (ruby-assert-face s 1 font-lock-string-face) - (ruby-assert-face s 2 font-lock-variable-name-face) - (ruby-assert-face s 38 font-lock-string-face) + (ruby-assert-face s 1 'font-lock-string-face) + (ruby-assert-face s 2 'font-lock-variable-name-face) + (ruby-assert-face s 38 'font-lock-string-face) (ruby-assert-state s 8 nil))) (ert-deftest ruby-interpolation-inside-double-quoted-percent-literals () - (ruby-assert-face "%Q{foo #@bar}" 8 font-lock-variable-name-face) - (ruby-assert-face "%W{foo #@bar}" 8 font-lock-variable-name-face) - (ruby-assert-face "%r{foo #@bar}" 8 font-lock-variable-name-face) - (ruby-assert-face "%x{foo #@bar}" 8 font-lock-variable-name-face)) + (ruby-assert-face "%Q{foo #@bar}" 8 'font-lock-variable-name-face) + (ruby-assert-face "%W{foo #@bar}" 8 'font-lock-variable-name-face) + (ruby-assert-face "%r{foo #@bar}" 8 'font-lock-variable-name-face) + (ruby-assert-face "%x{foo #@bar}" 8 'font-lock-variable-name-face)) (ert-deftest ruby-no-interpolation-in-single-quoted-literals () - (ruby-assert-face "'foo #@bar'" 7 font-lock-string-face) - (ruby-assert-face "%q{foo #@bar}" 8 font-lock-string-face) - (ruby-assert-face "%w{foo #@bar}" 8 font-lock-string-face) - (ruby-assert-face "%s{foo #@bar}" 8 font-lock-string-face)) + (ruby-assert-face "'foo #@bar'" 7 'font-lock-string-face) + (ruby-assert-face "%q{foo #@bar}" 8 'font-lock-string-face) + (ruby-assert-face "%w{foo #@bar}" 8 'font-lock-string-face) + (ruby-assert-face "%s{foo #@bar}" 8 'font-lock-string-face)) (ert-deftest ruby-interpolation-after-dollar-sign () (ruby-assert-face "\"$#{balance}\"" 2 'font-lock-string-face) commit 03249f78153a34aab70b30f23d26210c1e7ff2a3 Author: Po Lu Date: Wed Dec 18 09:39:45 2024 +0800 Fix the DJGPP build * msdos/sedlibmk.inp (LIB_SELINUX, USE_SELINUX_SELINUX_H): Define to 0. * src/conf_post.h (_GL_DIT_NOTDIR, ENOTSUP) [MSDOS]: Define to appropriate values. diff --git a/msdos/sedlibmk.inp b/msdos/sedlibmk.inp index 624983798c4..15939c85547 100644 --- a/msdos/sedlibmk.inp +++ b/msdos/sedlibmk.inp @@ -278,6 +278,7 @@ s/@PACKAGE@/emacs/ /^LDFLAGS *=/s/@[^@\n]*@// /^LD_FIRSTFLAG *=/s/@[^@\n]*@// /^LIB_PTHREAD *=/s/@[^@\n]*@// +/^LIB_SELINUX *=/s/@[^@\n]*@// /^LIBS *=/s/@[^@\n]*@// /^MAKEINFO *=/s/@MAKEINFO@/makeinfo/ # MKDIR_P lines are edited further below @@ -367,6 +368,7 @@ s/@PACKAGE@/emacs/ /^UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS *=/s/@[^@\n]*@/0/ /^UNISTD_H_DEFINES_STRUCT_TIMESPEC *=/s/@[^@\n]*@/0/ /^UNDEFINE_STRTOK_R *=/s/@UNDEFINE_STRTOK_R@/0/ +/^USE_SELINUX_SELINUX_H *=/s/@USE_SELINUX_SELINUX_H@/0/ /^WCHAR_T_SUFFIX *=/s/@WCHAR_T_SUFFIX@/h/ /^WINT_T_SUFFIX *=/s/@WINT_T_SUFFIX@// /^GNULIBHEADERS_OVERRIDE_WINT_T *=/s/@[^@\n]*@/0/ diff --git a/src/conf_post.h b/src/conf_post.h index f2353803074..e68d5a56d9b 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -475,3 +475,10 @@ extern int emacs_setenv_TZ (char const *); /* Emacs does not need glibc strftime behavior for AM and PM indicators. */ #define REQUIRE_GNUISH_STRFTIME_AM_PM false + +#ifdef MSDOS +/* These are required by file-has-acl.c but defined in dirent.h and + errno.h, which are not generated on DOS. */ +#define _GL_DT_NOTDIR 0x100 /* Not a directory */ +#define ENOTSUP 2007 +#endif /* MSDOS */ commit b1e5f6d6ef8432a9cce0664238de72d387730bd1 Author: Paul Eggert Date: Tue Dec 17 14:02:41 2024 -0800 Update from Gnulib by running admin/merge-gnulib * admin/merge-gnulib (AVOIDED_MODULES): Avoid gnulib-i18n. * lib/stdlib.c, m4/selinux-selinux-h.m4: New files, taken from Gnulib. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 0c7de65a323..7b718809ae0 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -53,7 +53,7 @@ GNULIB_MODULES=' ' AVOIDED_MODULES=' - access btowc chmod close crypto/af_alg dup fchdir fstat + access btowc chmod close crypto/af_alg dup fchdir fstat gnulib-i18n iswblank iswctype iswdigit iswxdigit langinfo libgmp-mpq localename-unsafe-limited lock mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo diff --git a/build-aux/install-sh b/build-aux/install-sh index b1d7a6f67f6..8a76989bbc4 100755 --- a/build-aux/install-sh +++ b/build-aux/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2024-06-19.01; # UTC +scriptversion=2024-12-03.03; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -533,7 +533,7 @@ do done # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp nil t) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/lib/acl-internal.c b/lib/acl-internal.c index ae5398306af..b729126118a 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c @@ -19,10 +19,12 @@ #include -#include "acl.h" - +/* Specification. */ +#define ACL_INTERNAL_INLINE _GL_EXTERN_INLINE #include "acl-internal.h" +#include "acl.h" + #if defined __CYGWIN__ # include # include diff --git a/lib/acl.h b/lib/acl.h index 475231c2db7..1d52345c668 100644 --- a/lib/acl.h +++ b/lib/acl.h @@ -32,9 +32,68 @@ extern "C" { #endif +/* file_has_acl flags guaranteed to not collide with any + DT_* or _GL_DT_* value. */ +enum + { + /* Get scontext information as well. */ + ACL_GET_SCONTEXT = 0x10000, + + /* Follow symlinks. */ + ACL_SYMLINK_FOLLOW = 0x20000, + }; + +/* Information about an ACL. */ +struct aclinfo +{ + /* If 'size' is nonnegative, a buffer holding the concatenation + of extended attribute names, each terminated by NUL + (either u.__gl_acl_ch, or heap-allocated). */ + char *buf; + + /* The number of useful bytes at the start of buf, counting trailing NULs. + If negative, there was an error in getting the ACL info, + and u.err is the corresponding errno. */ + ssize_t size; + + /* Security context string. Do not modify its contents. */ + char *scontext; + /* Security context errno value. It is zero if there was no + error getting the security context. When nonzero, scontext is "?". */ + int scontext_err; + + union + { + /* An errno value, when there was an error getting the ACL info. */ + int err; + + /* A small array of char, big enough for most listxattr results. + The size is somewhat arbitrary; it equals the max length of a + trivial NFSv4 ACL (a size used by file-has-acl.c in 2023-2024 + but no longer relevant now), and a different value might be + better once experience is gained. For internal use only. */ + char __gl_acl_ch[152]; + } u; +}; bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; int file_has_acl (char const *, struct stat const *); +int file_has_aclinfo (char const *restrict, struct aclinfo *restrict, int); + +#if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR +bool aclinfo_has_xattr (struct aclinfo const *, char const *) + _GL_ATTRIBUTE_PURE; +void aclinfo_free (struct aclinfo *); +#else +# define aclinfo_has_xattr(ai, xattr) false +# define aclinfo_free(ai) ((void) 0) +#endif +#if (HAVE_LINUX_XATTR_H && HAVE_LISTXATTR \ + && (HAVE_SMACK || USE_SELINUX_SELINUX_H)) +void aclinfo_scontext_free (char *); +#else +# define aclinfo_scontext_free(s) ((void) 0) +#endif int qset_acl (char const *, int, mode_t); int xset_acl (char const *, int, mode_t); diff --git a/lib/dirent.in.h b/lib/dirent.in.h index 7ba8fc64d89..a0ac39b4968 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -46,20 +46,95 @@ struct dirent char d_type; char d_name[1]; }; -/* Possible values for 'd_type'. */ -# define DT_UNKNOWN 0 -# define DT_FIFO 1 /* FIFO */ -# define DT_CHR 2 /* character device */ -# define DT_DIR 4 /* directory */ -# define DT_BLK 6 /* block device */ -# define DT_REG 8 /* regular file */ -# define DT_LNK 10 /* symbolic link */ -# define DT_SOCK 12 /* socket */ -# define DT_WHT 14 /* whiteout */ # define GNULIB_defined_struct_dirent 1 # endif #endif +/* 'd_type' macros specified in GNU, i.e., POSIX.1-2024 plus DT_WHT, + but not (yet) DT_MQ, DT_SEM, DT_SHM, DT_TMO. + These macros can be useful even on platforms that do not support + d_type or the corresponding file types. + The values of these macros are all in the 'unsigned char' range. + Default to the Linux values which are also popular elsewhere, + and check that all macros have distinct values. */ +#ifndef DT_UNKNOWN +# define DT_UNKNOWN 0 +#endif +#ifndef DT_FIFO +# define DT_FIFO 1 /* FIFO */ +#endif +#ifndef DT_CHR +# define DT_CHR 2 /* character device */ +#endif +#ifndef DT_DIR +# define DT_DIR 4 /* directory */ +#endif +#ifndef DT_BLK +# define DT_BLK 6 /* block device */ +#endif +#ifndef DT_REG +# define DT_REG 8 /* regular file */ +#endif +#ifndef DT_LNK +# define DT_LNK 10 /* symbolic link */ +#endif +#ifndef DT_SOCK +# define DT_SOCK 12 /* socket */ +#endif +#ifndef DT_WHT +# define DT_WHT 14 /* whiteout */ +#endif +static_assert (DT_UNKNOWN != DT_FIFO && DT_UNKNOWN != DT_CHR + && DT_UNKNOWN != DT_BLK && DT_UNKNOWN != DT_REG + && DT_UNKNOWN != DT_LNK && DT_UNKNOWN != DT_SOCK + && DT_UNKNOWN != DT_WHT + && DT_FIFO != DT_CHR && DT_FIFO != DT_BLK && DT_FIFO != DT_REG + && DT_FIFO != DT_LNK && DT_FIFO != DT_SOCK && DT_FIFO != DT_WHT + && DT_CHR != DT_BLK && DT_CHR != DT_REG && DT_CHR != DT_LNK + && DT_CHR != DT_SOCK && DT_CHR != DT_WHT + && DT_BLK != DT_REG && DT_BLK != DT_LNK && DT_BLK != DT_SOCK + && DT_BLK != DT_WHT + && DT_REG != DT_LNK && DT_REG != DT_SOCK && DT_REG != DT_WHT + && DT_LNK != DT_SOCK && DT_LNK != DT_WHT + && DT_SOCK != DT_WHT); + +/* Other optional information about a directory entry. */ +#define _GL_DT_NOTDIR 0x100 /* Not a directory */ + +/* Conversion between S_IF* and DT_* file types. */ +#if ! (defined IFTODT && defined DTTOIF) +# include +# ifdef S_ISWHT +# define _GL_DIRENT_S_ISWHT(mode) S_ISWHT(mode) +# else +# define _GL_DIRENT_S_ISWHT(mode) 0 +# endif +# ifdef S_IFWHT +# define _GL_DIRENT_S_IFWHT S_IFWHT +# else +# define _GL_DIRENT_S_IFWHT (DT_WHT << 12) /* just a guess */ +# endif +#endif +/* Conversion from a 'stat' mode to a DT_* value. */ +#ifndef IFTODT +# define IFTODT(mode) \ + (S_ISREG (mode) ? DT_REG : S_ISDIR (mode) ? DT_DIR \ + : S_ISLNK (mode) ? DT_LNK : S_ISBLK (mode) ? DT_BLK \ + : S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \ + : S_ISSOCK (mode) ? DT_SOCK \ + : _GL_DIRENT_S_ISWHT (mode) ? DT_WHT : DT_UNKNOWN) +#endif +/* Conversion from a DT_* value to a 'stat' mode. */ +#ifndef DTTOIF +# define DTTOIF(dirtype) \ + ((dirtype) == DT_REG ? S_IFREG : (dirtype) == DT_DIR ? S_IFDIR \ + : (dirtype) == DT_LNK ? S_IFLNK : (dirtype) == DT_BLK ? S_IFBLK \ + : (dirtype) == DT_CHR ? S_IFCHR : dirtype == DT_FIFO ? S_IFIFO \ + : (dirtype) == DT_SOCK ? S_IFSOCK \ + : (dirtype) == DT_WHT ? _GL_DIRENT_S_IFWHT \ + : (dirtype) << 12 /* just a guess */) +#endif + #if !@DIR_HAS_FD_MEMBER@ # if !GNULIB_defined_DIR /* struct gl_directory is a type with a field 'int fd_to_close'. diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 06759a4948c..7c29f201589 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -27,12 +27,30 @@ #include "acl.h" +#include +#include + #include "acl-internal.h" #include "attribute.h" #include "minmax.h" -#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR +/* Check the assumption that UCHAR_MAX < INT_MAX. */ +static_assert (ACL_SYMLINK_FOLLOW & ~ (unsigned char) -1); + +static char const UNKNOWN_SECURITY_CONTEXT[] = "?"; + +#if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR +# define USE_LINUX_XATTR true +#else +# define USE_LINUX_XATTR false +#endif + +#if USE_LINUX_XATTR +# if USE_SELINUX_SELINUX_H +# include +# endif # include +# include # include # include # include @@ -47,26 +65,186 @@ # define XATTR_NAME_POSIX_ACL_DEFAULT "system.posix_acl_default" # endif +# ifdef HAVE_SMACK +# include +# else +static char const * +smack_smackfs_path (void) +{ + return NULL; +} +static ssize_t +smack_new_label_from_path (MAYBE_UNUSED const char *path, + MAYBE_UNUSED const char *xattr, + MAYBE_UNUSED int follow, MAYBE_UNUSED char **label) +{ + return -1; +} +# endif +static bool +is_smack_enabled (void) +{ + return !!smack_smackfs_path (); +} + enum { /* ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000, */ ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001, ACE4_IDENTIFIER_GROUP = 0x00000040 }; -/* Return true if ATTR is in the set represented by the NUL-terminated - strings in LISTBUF, which is of size LISTSIZE. */ +/* Does AI's xattr set contain XATTR? */ -ATTRIBUTE_PURE static bool -have_xattr (char const *attr, char const *listbuf, ssize_t listsize) +bool +aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr) { - char const *blim = listbuf + listsize; - for (char const *b = listbuf; b < blim; b += strlen (b) + 1) - for (char const *a = attr; *a == *b; a++, b++) - if (!*a) - return true; + if (0 < ai->size) + { + char const *blim = ai->buf + ai->size; + for (char const *b = ai->buf; b < blim; b += strlen (b) + 1) + for (char const *a = xattr; *a == *b; a++, b++) + if (!*a) + return true; + } return false; } +/* Get attributes of the file NAME into AI, if USE_ACL. + If FLAGS & ACL_GET_SCONTEXT, also get security context. + If FLAGS & ACL_SYMLINK_FOLLOW, follow symbolic links. */ +static void +get_aclinfo (char const *name, struct aclinfo *ai, int flags) +{ + int scontext_err = ENOTSUP; + ai->buf = ai->u.__gl_acl_ch; + ssize_t acl_alloc = sizeof ai->u.__gl_acl_ch; + + if (! (USE_ACL || flags & ACL_GET_SCONTEXT)) + ai->size = 0; + else + { + ssize_t (*lsxattr) (char const *, char *, size_t) + = (flags & ACL_SYMLINK_FOLLOW ? listxattr : llistxattr); + while (true) + { + ai->size = lsxattr (name, ai->buf, acl_alloc); + if (0 < ai->size) + break; + ai->u.err = ai->size < 0 ? errno : 0; + if (! (ai->size < 0 && ai->u.err == ERANGE && acl_alloc < SSIZE_MAX)) + break; + + /* The buffer was too small. Find how large it should have been. */ + ssize_t size = lsxattr (name, NULL, 0); + if (size <= 0) + { + ai->size = size; + ai->u.err = size < 0 ? errno : 0; + break; + } + + /* Grow allocation to at least 'size'. Grow it by a nontrivial + amount, to defend against denial of service by an adversary + that fiddles with ACLs. */ + if (ai->buf != ai->u.__gl_acl_ch) + { + free (ai->buf); + ai->buf = ai->u.__gl_acl_ch; + } + if (ckd_add (&acl_alloc, acl_alloc, acl_alloc >> 1)) + acl_alloc = SSIZE_MAX; + if (acl_alloc < size) + acl_alloc = size; + if (SIZE_MAX < acl_alloc) + { + ai->u.err = ENOMEM; + break; + } + char *newbuf = malloc (acl_alloc); + if (!newbuf) + { + ai->u.err = errno; + break; + } + ai->buf = newbuf; + } + } + + if (0 < ai->size && flags & ACL_GET_SCONTEXT) + { + if (is_smack_enabled ()) + { + if (aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) + { + ssize_t r = smack_new_label_from_path (name, "security.SMACK64", + flags & ACL_SYMLINK_FOLLOW, + &ai->scontext); + scontext_err = r < 0 ? errno : 0; + } + } + else + { +# if USE_SELINUX_SELINUX_H + if (aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) + { + ssize_t r = + ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) + (name, &ai->scontext)); + scontext_err = r < 0 ? errno : 0; +# ifndef SE_SELINUX_INLINE + /* Gnulib's selinux-h module is not in use, so getfilecon and + lgetfilecon can misbehave, be it via an old version of + libselinux where these would return 0 and set the result + context to NULL, or via a modern kernel+lib operating on a + file from a disk whose attributes were set by a kernel from + around 2006. In that latter case, the functions return a + length of 10 for the "unlabeled" context. Map both failures + to a return value of -1, and set errno to ENOTSUP in the + first case, and ENODATA in the latter. */ + if (r == 0) + scontext_err = ENOTSUP; + if (r == 10 && memcmp (ai->scontext, "unlabeled", 10) == 0) + { + freecon (ai->scontext); + scontext_err = ENODATA; + } +# endif + } +# endif + } + } + ai->scontext_err = scontext_err; + if (scontext_err) + ai->scontext = (char *) UNKNOWN_SECURITY_CONTEXT; +} + +# ifndef aclinfo_scontext_free +/* Free the pointer that file_has_aclinfo put into scontext. + However, do nothing if the argument is a null pointer; + This lets the caller replace the scontext member with a null pointer if it + is willing to own the member and call this function later. */ +void +aclinfo_scontext_free (char *scontext) +{ + if (scontext != UNKNOWN_SECURITY_CONTEXT) + { + if (is_smack_enabled ()) + free (scontext); + else if (scontext) + freecon (scontext); + } +} +# endif + +/* Free AI's heap storage. */ +void +aclinfo_free (struct aclinfo *ai) +{ + if (ai->buf != ai->u.__gl_acl_ch) + free (ai->buf); + aclinfo_scontext_free (ai->scontext); +} + /* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial. -1 upon failure to determine it. Possibly change errno. Assume that the ACL is valid, except avoid undefined behavior even if invalid. @@ -150,196 +328,183 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes) 0 if ACLs are not supported, or if NAME has no or only a base ACL, and -1 (setting errno) on error. Note callers can determine if ACLs are not supported as errno is set in that case also. - SB must be set to the stat buffer of NAME, - obtained through stat() or lstat(). */ - + Set *AI to ACL info regardless of return value. + FLAGS should be a d_type value, optionally ORed with + - _GL_DT_NOTDIR if it is known that NAME is not a directory, + - ACL_GET_SCONTEXT to retrieve security context and return 1 if present, + - ACL_SYMLINK_FOLLOW to follow the link if NAME is a symbolic link; + otherwise do not follow them if possible. + If the d_type value is not known, use DT_UNKNOWN though this may be less + efficient. */ int -file_has_acl (char const *name, struct stat const *sb) +file_has_aclinfo (MAYBE_UNUSED char const *restrict name, + struct aclinfo *restrict ai, int flags) { -#if USE_ACL - if (! S_ISLNK (sb->st_mode)) + MAYBE_UNUSED unsigned char d_type = flags & UCHAR_MAX; + +#if USE_LINUX_XATTR + int initial_errno = errno; + get_aclinfo (name, ai, flags); + + if (ai->size <= 0) { + errno = ai->size < 0 ? ai->u.err : initial_errno; + return ai->size; + } -# if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR - int initial_errno = errno; - - /* The max length of a trivial NFSv4 ACL is 6 words for owner, - 6 for group, 7 for everyone, all times 2 because there are - both allow and deny ACEs. There are 6 words for owner - because of type, flag, mask, wholen, "OWNER@"+pad and - similarly for group; everyone is another word to hold - "EVERYONE@". */ - typedef uint32_t trivial_NFSv4_xattr_buf[2 * (6 + 6 + 7)]; - - /* A buffer large enough to hold any trivial NFSv4 ACL, - and also useful as a small array of char. */ - union { - trivial_NFSv4_xattr_buf xattr; - char ch[sizeof (trivial_NFSv4_xattr_buf)]; - } stackbuf; - - char *listbuf = stackbuf.ch; - ssize_t listbufsize = sizeof stackbuf.ch; - char *heapbuf = NULL; - ssize_t listsize; - - /* Use listxattr first, as this means just one syscall in the - typical case where the file lacks an ACL. Try stackbuf - first, falling back on malloc if stackbuf is too small. */ - while ((listsize = listxattr (name, listbuf, listbufsize)) < 0 - && errno == ERANGE) - { - free (heapbuf); - ssize_t newsize = listxattr (name, NULL, 0); - if (newsize <= 0) - return newsize; - - /* Grow LISTBUFSIZE to at least NEWSIZE. Grow it by a - nontrivial amount too, to defend against denial of - service by an adversary that fiddles with ACLs. */ - bool overflow = ckd_add (&listbufsize, listbufsize, listbufsize >> 1); - listbufsize = MAX (listbufsize, newsize); - if (overflow || SIZE_MAX < listbufsize) - { - errno = ENOMEM; - return -1; - } + /* In Fedora 39, a file can have both NFSv4 and POSIX ACLs, + but if it has an NFSv4 ACL that's the one that matters. + In earlier Fedora the two types of ACLs were mutually exclusive. + Attempt to work correctly on both kinds of systems. */ + + if (!aclinfo_has_xattr (ai, XATTR_NAME_NFSV4_ACL)) + return + (aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_ACCESS) + || ((d_type == DT_DIR || d_type == DT_UNKNOWN) + && aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_DEFAULT))); + + /* A buffer large enough to hold any trivial NFSv4 ACL. + The max length of a trivial NFSv4 ACL is 6 words for owner, + 6 for group, 7 for everyone, all times 2 because there are both + allow and deny ACEs. There are 6 words for owner because of + type, flag, mask, wholen, "OWNER@"+pad and similarly for group; + everyone is another word to hold "EVERYONE@". */ + uint32_t buf[2 * (6 + 6 + 7)]; + + int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) + (name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf)); + if (ret < 0) + switch (errno) + { + case ENODATA: return 0; + case ERANGE : return 1; /* ACL must be nontrivial. */ + default: return - acl_errno_valid (errno); + } - listbuf = heapbuf = malloc (listbufsize); - if (!listbuf) - return -1; - } + /* It looks like a trivial ACL, but investigate further. */ + ret = acl_nfs4_nontrivial (buf, ret); + errno = ret < 0 ? EINVAL : initial_errno; + return ret; + +#else /* !USE_LINUX_XATTR */ + + ai->buf = ai->u.__gl_acl_ch; + ai->size = -1; + ai->u.err = ENOTSUP; + ai->scontext = (char *) UNKNOWN_SECURITY_CONTEXT; + ai->scontext_err = ENOTSUP; + +# if USE_ACL +# if HAVE_ACL_GET_FILE + + { + /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ + /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ + int ret; + +# if HAVE_ACL_EXTENDED_FILE /* Linux */ + /* On Linux, acl_extended_file is an optimized function: It only + makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for + ACL_TYPE_DEFAULT. */ + ret = ((flags & ACL_SYMLINK_FOLLOW + ? acl_extended_file + : acl_extended_file_nofollow) + (name)); +# elif HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ + /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) + always return NULL / EINVAL. There is no point in making + these two useless calls. The real ACL is retrieved through + acl_get_file (name, ACL_TYPE_EXTENDED). */ + acl_t acl = ((flags & ACL_SYMLINK_FOLLOW + ? acl_get_file + : acl_get_link_np) + (name, ACL_TYPE_EXTENDED)); + if (acl) + { + ret = acl_extended_nontrivial (acl); + acl_free (acl); + } + else + ret = -1; +# else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */ + acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file; +# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */ + if (! (flags & ACL_SYMLINK_FOLLOW)) + acl_get_file_or_link = acl_get_link_np; +# endif - /* In Fedora 39, a file can have both NFSv4 and POSIX ACLs, - but if it has an NFSv4 ACL that's the one that matters. - In earlier Fedora the two types of ACLs were mutually exclusive. - Attempt to work correctly on both kinds of systems. */ - bool nfsv4_acl - = 0 < listsize && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize); - int ret - = (listsize <= 0 ? listsize - : (nfsv4_acl - || have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize) - || (S_ISDIR (sb->st_mode) - && have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, - listbuf, listsize)))); - free (heapbuf); - - /* If there is an NFSv4 ACL, follow up with a getxattr syscall - to see whether the NFSv4 ACL is nontrivial. */ - if (nfsv4_acl) - { - ret = getxattr (name, XATTR_NAME_NFSV4_ACL, - stackbuf.xattr, sizeof stackbuf.xattr); - if (ret < 0) - switch (errno) + acl_t acl = acl_get_file_or_link (name, ACL_TYPE_ACCESS); + if (acl) + { + ret = acl_access_nontrivial (acl); + int saved_errno = errno; + acl_free (acl); + errno = saved_errno; +# if HAVE_ACL_FREE_TEXT /* Tru64 */ + /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always + returns NULL with errno not set. There is no point in + making this call. */ +# else /* FreeBSD, NetBSD >= 10, IRIX, Cygwin >= 2.5 */ + /* On Linux, FreeBSD, NetBSD, IRIX, + acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory + either both succeed or both fail; it depends on the + file system. Therefore there is no point in making the second + call if the first one already failed. */ + if (ret == 0 + && (d_type == DT_DIR + || (d_type == DT_UNKNOWN && !(flags & _GL_DT_NOTDIR)))) + { + acl = acl_get_file_or_link (name, ACL_TYPE_DEFAULT); + if (acl) { - case ENODATA: return 0; - case ERANGE : return 1; /* ACL must be nontrivial. */ +# ifdef __CYGWIN__ /* Cygwin >= 2.5 */ + ret = acl_access_nontrivial (acl); + saved_errno = errno; + acl_free (acl); + errno = saved_errno; +# else + ret = (0 < acl_entries (acl)); + acl_free (acl); +# endif } - else - { - /* It looks like a trivial ACL, but investigate further. */ - ret = acl_nfs4_nontrivial (stackbuf.xattr, ret); - if (ret < 0) - { - errno = EINVAL; - return ret; - } - errno = initial_errno; - } - } - if (ret < 0) - return - acl_errno_valid (errno); - return ret; + else + { + ret = -1; +# ifdef __CYGWIN__ /* Cygwin >= 2.5 */ + if (d_type == DT_UNKNOWN) + ret = 0; +# endif + } + } +# endif + } + else + ret = -1; +# endif -# elif HAVE_ACL_GET_FILE + return ret < 0 ? - acl_errno_valid (errno) : ret; + } - /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ - /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ - int ret; +# else /* !HAVE_ACL_GET_FILE */ - if (HAVE_ACL_EXTENDED_FILE) /* Linux */ - { - /* On Linux, acl_extended_file is an optimized function: It only - makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for - ACL_TYPE_DEFAULT. */ - ret = acl_extended_file (name); - } - else /* FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ - { -# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ - /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) - and acl_get_file (name, ACL_TYPE_DEFAULT) - always return NULL / EINVAL. There is no point in making - these two useless calls. The real ACL is retrieved through - acl_get_file (name, ACL_TYPE_EXTENDED). */ - acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); - if (acl) - { - ret = acl_extended_nontrivial (acl); - acl_free (acl); - } - else - ret = -1; -# else /* FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */ - acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); - if (acl) - { - int saved_errno; - - ret = acl_access_nontrivial (acl); - saved_errno = errno; - acl_free (acl); - errno = saved_errno; -# if HAVE_ACL_FREE_TEXT /* Tru64 */ - /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always - returns NULL with errno not set. There is no point in - making this call. */ -# else /* FreeBSD, IRIX, Cygwin >= 2.5 */ - /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS) - and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory - either both succeed or both fail; it depends on the - file system. Therefore there is no point in making the second - call if the first one already failed. */ - if (ret == 0 && S_ISDIR (sb->st_mode)) - { - acl = acl_get_file (name, ACL_TYPE_DEFAULT); - if (acl) - { -# ifdef __CYGWIN__ /* Cygwin >= 2.5 */ - ret = acl_access_nontrivial (acl); - saved_errno = errno; - acl_free (acl); - errno = saved_errno; -# else - ret = (0 < acl_entries (acl)); - acl_free (acl); -# endif - } - else - ret = -1; - } -# endif - } - else - ret = -1; -# endif - } - if (ret < 0) - return - acl_errno_valid (errno); - return ret; + /* The remaining APIs always follow symlinks and operate on + platforms where symlinks do not have ACLs, so skip the APIs if + NAME is known to be a symlink. */ + if (d_type != DT_LNK) + { -# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin < 2.5, not HP-UX */ +# if HAVE_FACL && defined GETACL /* Solaris, Cygwin < 2.5, not HP-UX */ -# if defined ACL_NO_TRIVIAL +# ifdef ACL_NO_TRIVIAL /* Solaris 10 (newer version), which has additional API declared in (acl_t) and implemented in libsec (acl_set, acl_trivial, acl_fromtext, ...). */ return acl_trivial (name); -# else /* Solaris, Cygwin, general case */ +# else /* Solaris, Cygwin, general case */ /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions of Unixware. The acl() call returns the access and default ACL both @@ -374,10 +539,7 @@ file_has_acl (char const *name, struct stat const *sb) entries = malloced = (aclent_t *) malloc (alloc * sizeof (aclent_t)); if (entries == NULL) - { - errno = ENOMEM; - return -1; - } + return -1; continue; } break; @@ -415,7 +577,7 @@ file_has_acl (char const *name, struct stat const *sb) free (malloced); } -# ifdef ACE_GETACL +# ifdef ACE_GETACL /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 file systems (whereas the other ones are used in UFS file systems). */ { @@ -447,10 +609,7 @@ file_has_acl (char const *name, struct stat const *sb) alloc = 2 * alloc; /* <= alloc_max */ entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t)); if (entries == NULL) - { - errno = ENOMEM; - return -1; - } + return -1; continue; } break; @@ -491,12 +650,12 @@ file_has_acl (char const *name, struct stat const *sb) } free (malloced); } -# endif +# endif return 0; -# endif +# endif -# elif HAVE_GETACL /* HP-UX */ +# elif HAVE_GETACL /* HP-UX */ { struct acl_entry entries[NACLENTRIES]; @@ -539,7 +698,7 @@ file_has_acl (char const *name, struct stat const *sb) } } -# if HAVE_ACLV_H /* HP-UX >= 11.11 */ +# if HAVE_ACLV_H /* HP-UX >= 11.11 */ { struct acl entries[NACLVENTRIES]; @@ -574,9 +733,9 @@ file_has_acl (char const *name, struct stat const *sb) } } -# endif +# endif -# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ +# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ acl_type_t type; char aclbuf[1024]; @@ -604,10 +763,7 @@ file_has_acl (char const *name, struct stat const *sb) free (acl); acl = malloc (aclsize); if (acl == NULL) - { - errno = ENOMEM; - return -1; - } + return -1; } if (type.u64 == ACL_AIXC) @@ -634,7 +790,7 @@ file_has_acl (char const *name, struct stat const *sb) return -1; } -# elif HAVE_STATACL /* older AIX */ +# elif HAVE_STATACL /* older AIX */ union { struct acl a; char room[4096]; } u; @@ -643,7 +799,7 @@ file_has_acl (char const *name, struct stat const *sb) return acl_nontrivial (&u.a); -# elif HAVE_ACLSORT /* NonStop Kernel */ +# elif HAVE_ACLSORT /* NonStop Kernel */ { struct acl entries[NACLENTRIES]; @@ -675,10 +831,29 @@ file_has_acl (char const *name, struct stat const *sb) return acl_nontrivial (count, entries); } } - -# endif +# endif } +# endif +# endif #endif return 0; } + +/* Return 1 if NAME has a nontrivial access control list, + 0 if ACLs are not supported, or if NAME has no or only a base ACL, + and -1 (setting errno) on error. Note callers can determine + if ACLs are not supported as errno is set in that case also. + SB must be set to the stat buffer of NAME, + obtained through stat() or lstat(). */ +int +file_has_acl (char const *name, struct stat const *sb) +{ + int flags = IFTODT (sb->st_mode); + if (!S_ISDIR (sb->st_mode)) + flags |= _GL_DT_NOTDIR; + struct aclinfo ai; + int r = file_has_aclinfo (name, &ai, flags); + aclinfo_free (&ai); + return r; +} diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h index a1d304d49e8..9d704a9f6e5 100644 --- a/lib/getopt-cdefs.in.h +++ b/lib/getopt-cdefs.in.h @@ -46,10 +46,14 @@ # endif #endif +#if defined __clang__ + /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */ +# undef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2)) +#endif #ifndef __GNUC_PREREQ -# if defined __GNUC__ && defined __GNUC_VERSION__ -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) # else # define __GNUC_PREREQ(maj, min) 0 # endif diff --git a/lib/getopt-pfx-core.h b/lib/getopt-pfx-core.h index 78b7816aa42..df2cb183a52 100644 --- a/lib/getopt-pfx-core.h +++ b/lib/getopt-pfx-core.h @@ -31,6 +31,13 @@ functions and variables. Renaming avoids problems with some compilers and linkers. */ #ifdef __GETOPT_PREFIX + +/* Include platform-dependent header files that may declare getopt() and + friends. */ +# if defined _AIX || defined __hpux || defined __sun || defined __QNX__ +# include +# endif + # ifndef __GETOPT_ID # define __GETOPT_CONCAT(x, y) x ## y # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) diff --git a/lib/getopt.c b/lib/getopt.c index ea2d1a529c4..47800c1b35b 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -42,7 +42,7 @@ # define funlockfile(fp) _IO_funlockfile (fp) #else # include "gettext.h" -# define _(msgid) gettext (msgid) +# define _(msgid) dgettext ("gnulib", msgid) /* When used standalone, flockfile and funlockfile might not be available. */ # if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \ @@ -732,7 +732,7 @@ _getopt_internal (int argc, char **argv, const char *optstring, NAME (int argc, char *const *argv, const char *optstring) \ { \ return _getopt_internal (argc, (char **)argv, optstring, \ - 0, 0, 0, POSIXLY_CORRECT); \ + NULL, NULL, 0, POSIXLY_CORRECT); \ } #ifdef _LIBC diff --git a/lib/gettext.h b/lib/gettext.h index 39d5ae4daa5..bf0aa41e230 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -1,6 +1,5 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2024 Free Software - Foundation, Inc. + Copyright (C) 1995-2024 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -18,6 +17,7 @@ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 + /* NLS can be disabled through the configure --disable-nls option or through "#define ENABLE NLS 0" before including this file. */ #if defined ENABLE_NLS && ENABLE_NLS @@ -45,19 +45,19 @@ as well because people using "gettext.h" will not include , and also including would fail on SunOS 4, whereas is OK. */ -#if defined(__sun) -# include -#endif +# if defined(__sun) +# include +# endif /* Many header files from the libstdc++ coming with g++ 3.3 or newer include , which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. */ -#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) -# include -# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H -# include +# if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) +# include +# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H +# include +# endif # endif -#endif /* Disabled NLS. The casts to 'const char *' serve the purpose of producing warnings @@ -93,12 +93,14 @@ #endif + /* Prefer gnulib's setlocale override over libintl's setlocale override. */ #ifdef GNULIB_defined_setlocale # undef setlocale # define setlocale rpl_setlocale #endif + /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time translation is done at a different place in the code. @@ -108,6 +110,7 @@ initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String + /* The separator between msgctxt and msgid in a .mo file. */ #define GETTEXT_CONTEXT_GLUE "\004" @@ -115,6 +118,9 @@ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be short and rarely need to change. The letter 'p' stands for 'particular' or 'special'. */ + +#include /* for LC_MESSAGES */ + #ifdef DEFAULT_TEXT_DOMAIN # define pgettext(Msgctxt, Msgid) \ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) @@ -178,11 +184,12 @@ npgettext_aux (const char *domain, return translation; } + /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID can be arbitrary expressions. But for string literals these macros are less efficient than those above. */ -#include +#include /* for memcpy */ /* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. This relates to the -Wvla and -Wvla-larger-than warnings, enabled in @@ -199,7 +206,7 @@ npgettext_aux (const char *domain, #endif #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS -#include +# include /* for malloc, free */ #endif #define pgettext_expr(Msgctxt, Msgid) \ @@ -297,4 +304,5 @@ dcnpgettext_expr (const char *domain, return (n == 1 ? msgid : msgid_plural); } + #endif /* _LIBGETTEXT_H */ diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 5e541d9af1f..53275a4e62f 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -42,6 +42,7 @@ # --avoid=dup \ # --avoid=fchdir \ # --avoid=fstat \ +# --avoid=gnulib-i18n \ # --avoid=iswblank \ # --avoid=iswctype \ # --avoid=iswdigit \ @@ -80,6 +81,7 @@ # alloca-opt \ # binary-io \ # boot-time \ +# builtin-expect \ # byteswap \ # c-ctype \ # c-strcase \ @@ -261,7 +263,6 @@ DYNLIB_OBJ = @DYNLIB_OBJ@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ -EGREP = @EGREP@ EMACSRES = @EMACSRES@ EMACS_MANIFEST = @EMACS_MANIFEST@ EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@ @@ -336,6 +337,7 @@ GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@ GL_COND_OBJ_RAWMEMCHR_CONDITION = @GL_COND_OBJ_RAWMEMCHR_CONDITION@ GL_COND_OBJ_READLINKAT_CONDITION = @GL_COND_OBJ_READLINKAT_CONDITION@ GL_COND_OBJ_READLINK_CONDITION = @GL_COND_OBJ_READLINK_CONDITION@ +GL_COND_OBJ_REALLOC_POSIX_CONDITION = @GL_COND_OBJ_REALLOC_POSIX_CONDITION@ GL_COND_OBJ_REGEX_CONDITION = @GL_COND_OBJ_REGEX_CONDITION@ GL_COND_OBJ_SIG2STR_CONDITION = @GL_COND_OBJ_SIG2STR_CONDITION@ GL_COND_OBJ_SIGDESCR_NP_CONDITION = @GL_COND_OBJ_SIGDESCR_NP_CONDITION@ @@ -584,7 +586,6 @@ GL_GNULIB_READDIR = @GL_GNULIB_READDIR@ GL_GNULIB_READLINK = @GL_GNULIB_READLINK@ GL_GNULIB_READLINKAT = @GL_GNULIB_READLINKAT@ GL_GNULIB_REALLOCARRAY = @GL_GNULIB_REALLOCARRAY@ -GL_GNULIB_REALLOC_GNU = @GL_GNULIB_REALLOC_GNU@ GL_GNULIB_REALLOC_POSIX = @GL_GNULIB_REALLOC_POSIX@ GL_GNULIB_REALPATH = @GL_GNULIB_REALPATH@ GL_GNULIB_REMOVE = @GL_GNULIB_REMOVE@ @@ -707,7 +708,6 @@ GNUSTEP_CFLAGS = @GNUSTEP_CFLAGS@ GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_LIBS = @GOBJECT_LIBS@ -GREP = @GREP@ GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@ GSETTINGS_LIBS = @GSETTINGS_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ @@ -1031,6 +1031,7 @@ LIB_MATH = @LIB_MATH@ LIB_NANOSLEEP = @LIB_NANOSLEEP@ LIB_PTHREAD = @LIB_PTHREAD@ LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ +LIB_SELINUX = @LIB_SELINUX@ LIB_TIMER_TIME = @LIB_TIMER_TIME@ LIB_WSOCK32 = @LIB_WSOCK32@ LIB_XATTR = @LIB_XATTR@ @@ -1277,7 +1278,6 @@ REPLACE_READDIR = @REPLACE_READDIR@ REPLACE_READLINK = @REPLACE_READLINK@ REPLACE_READLINKAT = @REPLACE_READLINKAT@ REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@ -REPLACE_REALLOC_FOR_REALLOC_GNU = @REPLACE_REALLOC_FOR_REALLOC_GNU@ REPLACE_REALLOC_FOR_REALLOC_POSIX = @REPLACE_REALLOC_FOR_REALLOC_POSIX@ REPLACE_REALPATH = @REPLACE_REALPATH@ REPLACE_REMOVE = @REPLACE_REMOVE@ @@ -1384,6 +1384,7 @@ UNISTD_H_HAVE_SYS_RANDOM_H = @UNISTD_H_HAVE_SYS_RANDOM_H@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ +USE_SELINUX_SELINUX_H = @USE_SELINUX_SELINUX_H@ USE_STARTUP_NOTIFICATION = @USE_STARTUP_NOTIFICATION@ VMLIMIT_OBJ = @VMLIMIT_OBJ@ W32_LIBS = @W32_LIBS@ @@ -1470,16 +1471,13 @@ gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_CONDITION = @gl_GNULIB_ENABLE gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION@ gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION@ gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION = @gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION@ -gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION@ gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION = @gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION@ gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION = @gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION@ gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION@ gl_GNULIB_ENABLED_cloexec_CONDITION = @gl_GNULIB_ENABLED_cloexec_CONDITION@ -gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION = @gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION@ gl_GNULIB_ENABLED_dirfd_CONDITION = @gl_GNULIB_ENABLED_dirfd_CONDITION@ gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_CONDITION = @gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_CONDITION@ -gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION = @gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION@ gl_GNULIB_ENABLED_endian_CONDITION = @gl_GNULIB_ENABLED_endian_CONDITION@ gl_GNULIB_ENABLED_euidaccess_CONDITION = @gl_GNULIB_ENABLED_euidaccess_CONDITION@ gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION = @gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION@ @@ -2694,9 +2692,7 @@ endif ## begin gnulib module malloc-posix ifeq (,$(OMIT_GNULIB_MODULE_malloc-posix)) -ifneq (,$(gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION)) -endif EXTRA_DIST += malloc.c EXTRA_libgnu_a_SOURCES += malloc.c @@ -2925,29 +2921,15 @@ EXTRA_libgnu_a_SOURCES += at-func.c endif ## end gnulib module readlinkat -## begin gnulib module realloc-gnu -ifeq (,$(OMIT_GNULIB_MODULE_realloc-gnu)) - -ifneq (,$(gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION)) - -endif -EXTRA_DIST += realloc.c - -EXTRA_libgnu_a_SOURCES += realloc.c - -endif -## end gnulib module realloc-gnu - ## begin gnulib module realloc-posix ifeq (,$(OMIT_GNULIB_MODULE_realloc-posix)) ifneq (,$(gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION)) - +ifneq (,$(GL_COND_OBJ_REALLOC_POSIX_CONDITION)) +libgnu_a_SOURCES += realloc.c endif -EXTRA_DIST += realloc.c - -EXTRA_libgnu_a_SOURCES += realloc.c +endif endif ## end gnulib module realloc-posix @@ -3459,9 +3441,8 @@ endif ifeq (,$(OMIT_GNULIB_MODULE_stdlib)) BUILT_SOURCES += stdlib.h +libgnu_a_SOURCES += stdlib.c -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(gl_V_at)$(SED_HEADER_STDOUT) \ @@ -3500,7 +3481,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \ -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \ - -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \ -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \ -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \ @@ -3602,7 +3582,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \ -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ - -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \ -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \ -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ @@ -4446,17 +4425,6 @@ EXTRA_DIST += vla.h endif ## end gnulib module vla -## begin gnulib module xalloc-oversized -ifeq (,$(OMIT_GNULIB_MODULE_xalloc-oversized)) - -ifneq (,$(gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION)) - -endif -EXTRA_DIST += xalloc-oversized.h - -endif -## end gnulib module xalloc-oversized - mostlyclean-local: mostlyclean-generic @for dir in '' $(MOSTLYCLEANDIRS); do \ diff --git a/lib/malloc.c b/lib/malloc.c index 2a7867a1d1f..045ff82c1a7 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -17,28 +17,33 @@ /* written by Jim Meyering and Bruno Haible */ +/* Ensure that we call the system's malloc() below. */ #define _GL_USE_STDLIB_ALLOC 1 #include #include #include - -#include "xalloc-oversized.h" +#include /* Allocate an N-byte block of memory from the heap, even if N is 0. */ void * rpl_malloc (size_t n) { +#if !HAVE_MALLOC_0_NONNULL if (n == 0) n = 1; +#endif - if (xalloc_oversized (n, 1)) +#if !HAVE_MALLOC_PTRDIFF + ptrdiff_t signed_n; + if (ckd_add (&signed_n, n, 0)) { errno = ENOMEM; return NULL; } +#endif void *result = malloc (n); diff --git a/lib/md5-stream.c b/lib/md5-stream.c index fdd2bd8b4bf..2cbdda6b0fa 100644 --- a/lib/md5-stream.c +++ b/lib/md5-stream.c @@ -22,9 +22,6 @@ #include /* Specification. */ -#if HAVE_OPENSSL_MD5 -# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE -#endif #include "md5.h" #include diff --git a/lib/md5.h b/lib/md5.h index 2f470703f5c..94cc6994cc1 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -52,10 +52,14 @@ #define MD5_DIGEST_SIZE 16 #define MD5_BLOCK_SIZE 64 +#if defined __clang__ + /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */ +# undef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2)) +#endif #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) # else # define __GNUC_PREREQ(maj, min) 0 # endif diff --git a/lib/memset_explicit.c b/lib/memset_explicit.c index 33c09873482..a5d2b00b7ea 100644 --- a/lib/memset_explicit.c +++ b/lib/memset_explicit.c @@ -27,7 +27,10 @@ memset_explicit (void *s, int c, size_t len) #if HAVE_EXPLICIT_MEMSET return explicit_memset (s, c, len); #elif HAVE_MEMSET_S - (void) memset_s (s, len, c, len); +# if !HAVE_MEMSET_S_SUPPORTS_ZERO + if (len > 0) +# endif + (void) memset_s (s, len, c, len); return s; #elif defined __GNUC__ && !defined __clang__ memset (s, c, len); diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c index c580a8fc025..c97dc7e6cfa 100644 --- a/lib/mini-gmp.c +++ b/lib/mini-gmp.c @@ -2706,6 +2706,66 @@ mpn_gcd_11 (mp_limb_t u, mp_limb_t v) return u << shift; } +mp_size_t +mpn_gcd (mp_ptr rp, mp_ptr up, mp_size_t un, mp_ptr vp, mp_size_t vn) +{ + assert (un >= vn); + assert (vn > 0); + assert (!GMP_MPN_OVERLAP_P (up, un, vp, vn)); + assert (vp[vn-1] > 0); + assert ((up[0] | vp[0]) & 1); + + if (un > vn) + mpn_div_qr (NULL, up, un, vp, vn); + + un = mpn_normalized_size (up, vn); + if (un == 0) + { + mpn_copyi (rp, vp, vn); + return vn; + } + + if (!(vp[0] & 1)) + MPN_PTR_SWAP (up, un, vp, vn); + + while (un > 1 || vn > 1) + { + int shift; + assert (vp[0] & 1); + + while (up[0] == 0) + { + up++; + un--; + } + gmp_ctz (shift, up[0]); + if (shift > 0) + { + gmp_assert_nocarry (mpn_rshift(up, up, un, shift)); + un -= (up[un-1] == 0); + } + + if (un < vn) + MPN_PTR_SWAP (up, un, vp, vn); + else if (un == vn) + { + int c = mpn_cmp (up, vp, un); + if (c == 0) + { + mpn_copyi (rp, up, un); + return un; + } + else if (c < 0) + MP_PTR_SWAP (up, vp); + } + + gmp_assert_nocarry (mpn_sub (up, up, un, vp, vn)); + un = mpn_normalized_size (up, un); + } + rp[0] = mpn_gcd_11 (up[0], vp[0]); + return 1; +} + unsigned long mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v) { @@ -2765,42 +2825,11 @@ mpz_gcd (mpz_t g, const mpz_t u, const mpz_t v) if (tu->_mp_size < tv->_mp_size) mpz_swap (tu, tv); - mpz_tdiv_r (tu, tu, tv); - if (tu->_mp_size == 0) - { - mpz_swap (g, tv); - } - else - for (;;) - { - int c; - - mpz_make_odd (tu); - c = mpz_cmp (tu, tv); - if (c == 0) - { - mpz_swap (g, tu); - break; - } - if (c < 0) - mpz_swap (tu, tv); + tu->_mp_size = mpn_gcd (tu->_mp_d, tu->_mp_d, tu->_mp_size, tv->_mp_d, tv->_mp_size); + mpz_mul_2exp (g, tu, gz); - if (tv->_mp_size == 1) - { - mp_limb_t *gp; - - mpz_tdiv_r (tu, tu, tv); - gp = MPZ_REALLOC (g, 1); /* gp = mpz_limbs_modify (g, 1); */ - *gp = mpn_gcd_11 (tu->_mp_d[0], tv->_mp_d[0]); - - g->_mp_size = *gp != 0; /* mpz_limbs_finish (g, 1); */ - break; - } - mpz_sub (tu, tu, tv); - } mpz_clear (tu); mpz_clear (tv); - mpz_mul_2exp (g, g, gz); } void diff --git a/lib/mini-gmp.h b/lib/mini-gmp.h index 59c24cf5111..f28cb360ce1 100644 --- a/lib/mini-gmp.h +++ b/lib/mini-gmp.h @@ -105,6 +105,7 @@ void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); int mpn_perfect_square_p (mp_srcptr, mp_size_t); mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); +mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h index 0693aaf1402..3e2848c1210 100644 --- a/lib/mktime-internal.h +++ b/lib/mktime-internal.h @@ -71,9 +71,8 @@ typedef int mktime_offset_t; #endif /* Subroutine of mktime. Return the time_t representation of TP and - normalize TP, given that a struct tm * maps to a time_t as performed - by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ -extern __time64_t __mktime_internal (struct tm *tp, - struct tm *(*func) (__time64_t const *, - struct tm *), + normalize TP, given that a struct tm * maps to a time_t. If + LOCAL, the mapping is performed by localtime_r, otherwise by gmtime_r. + Record next guess for localtime-gmtime offset in *OFFSET. */ +extern __time64_t __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) attribute_hidden; diff --git a/lib/mktime.c b/lib/mktime.c index c704f415740..81d58fd01a3 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -51,7 +51,6 @@ #include #include -#include #ifndef NEED_MKTIME_INTERNAL # define NEED_MKTIME_INTERNAL 0 @@ -119,12 +118,12 @@ my_tzset (void) __time64_t values that mktime can generate even on platforms where __time64_t is wider than the int components of struct tm. */ -#if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 +# if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 typedef long int long_int; -#else +# else typedef long long int long_int; -#endif -verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60); +# endif +static_assert (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60); /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. B should be in the range 0 <= B @@ -155,9 +154,9 @@ static long_int const mktime_max = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t) ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t)); -#define EPOCH_YEAR 1970 -#define TM_YEAR_BASE 1900 -verify (TM_YEAR_BASE % 100 == 0); +# define EPOCH_YEAR 1970 +# define TM_YEAR_BASE 1900 +static_assert (TM_YEAR_BASE % 100 == 0); /* Is YEAR + TM_YEAR_BASE a leap year? */ static bool @@ -172,9 +171,9 @@ leapyear (long_int year) } /* How many days come before each month (0-12). */ -#ifndef _LIBC +# ifndef _LIBC static -#endif +# endif const unsigned short int __mon_yday[2][13] = { /* Normal years. */ @@ -206,7 +205,7 @@ static long_int ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, int year0, int yday0, int hour0, int min0, int sec0) { - verify (-1 / 2 == 0); + static_assert (-1 / 2 == 0); /* Compute intervening leap days correctly even if year is negative. Take care to avoid integer overflow here. */ @@ -251,29 +250,33 @@ tm_diff (long_int year, long_int yday, int hour, int min, int sec, tp->tm_hour, tp->tm_min, tp->tm_sec); } -/* Use CONVERT to convert T to a struct tm value in *TM. T must be in - range for __time64_t. Return TM if successful, NULL (setting errno) on - failure. */ +/* Convert T to a struct tm value in *TM. Use localtime64_r if LOCAL, + otherwise gmtime64_r. T must be in range for __time64_t. Return + TM if successful, NULL (setting errno) on failure. */ static struct tm * -convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), - long_int t, struct tm *tm) +convert_time (long_int t, bool local, struct tm *tm) { __time64_t x = t; - return convert (&x, tm); + if (local) + return __localtime64_r (&x, tm); + else + return __gmtime64_r (&x, tm); } - -/* Use CONVERT to convert *T to a broken down time in *TP. - If *T is out of range for conversion, adjust it so that - it is the nearest in-range value and then convert that. - A value is in range if it fits in both __time64_t and long_int. - Return TP on success, NULL (setting errno) on failure. */ +/* Call it __tzconvert to sync with other parts of glibc. */ +#define __tz_convert convert_time + +/* Convert *T to a broken down time in *TP (as if by localtime if + LOCAL, otherwise as if by gmtime). If *T is out of range for + conversion, adjust it so that it is the nearest in-range value and + then convert that. A value is in range if it fits in both + __time64_t and long_int. Return TP on success, NULL (setting + errno) on failure. */ static struct tm * -ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), - long_int *t, struct tm *tp) +ranged_convert (bool local, long_int *t, struct tm *tp) { long_int t1 = (*t < mktime_min ? mktime_min : *t <= mktime_max ? *t : mktime_max); - struct tm *r = convert_time (convert, t1, tp); + struct tm *r = __tz_convert (t1, local, tp); if (r) { *t = t1; @@ -294,7 +297,7 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), long_int mid = long_int_avg (ok, bad); if (mid == ok || mid == bad) break; - if (convert_time (convert, mid, tp)) + if (__tz_convert (mid, local, tp)) ok = mid, oktm = *tp; else if (errno != EOVERFLOW) return NULL; @@ -310,36 +313,45 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), } -/* Convert *TP to a __time64_t value, inverting - the monotonic and mostly-unit-linear conversion function CONVERT. - Use *OFFSET to keep track of a guess at the offset of the result, +/* Convert *TP to a __time64_t value. If LOCAL, the reverse mapping + is performed as if localtime, otherwise as if by gmtime. Use + *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. - If *OFFSET's guess is correct, only one CONVERT call is needed. - If successful, set *TP to the canonicalized struct tm; + If *OFFSET's guess is correct, only one reverse mapping call is + needed. If successful, set *TP to the canonicalized struct tm; otherwise leave *TP alone, return ((time_t) -1) and set errno. This function is external because it is used also by timegm.c. */ __time64_t -__mktime_internal (struct tm *tp, - struct tm *(*convert) (const __time64_t *, struct tm *), - mktime_offset_t *offset) +__mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) { struct tm tm; - /* The maximum number of probes (calls to CONVERT) should be enough - to handle any combinations of time zone rule changes, solar time, - leap seconds, and oscillations around a spring-forward gap. - POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ + /* The maximum number of probes should be enough to handle any + combinations of time zone rule changes, solar time, leap seconds, + and oscillations around a spring-forward gap. POSIX.1 prohibits + leap seconds, but some hosts have them anyway. */ int remaining_probes = 6; - /* Time requested. Copy it in case CONVERT modifies *TP; this can - occur if TP is localtime's returned value and CONVERT is localtime. */ +#ifndef _LIBC + /* Gnulib mktime doesn't lock the tz state, so it may need to probe + more often if some other thread changes local time while + __mktime_internal is probing. Double the number of probes; this + should suffice for practical cases that are at all likely. */ + remaining_probes *= 2; +#endif + + /* Time requested. Copy it in case gmtime/localtime modify *TP; + this can occur if TP is localtime's returned value and CONVERT is + localtime. */ int sec = tp->tm_sec; int min = tp->tm_min; int hour = tp->tm_hour; int mday = tp->tm_mday; int mon = tp->tm_mon; int year_requested = tp->tm_year; - int isdst = tp->tm_isdst; + + /* Ignore any tm_isdst request for timegm. */ + int isdst = local ? tp->tm_isdst : 0; /* 1 if the previous probe was DST. */ int dst2 = 0; @@ -390,7 +402,7 @@ __mktime_internal (struct tm *tp, while (true) { - if (! ranged_convert (convert, &t, &tm)) + if (! ranged_convert (local, &t, &tm)) return -1; long_int dt = tm_diff (year, yday, hour, min, sec, &tm); if (dt == 0) @@ -469,7 +481,7 @@ __mktime_internal (struct tm *tp, if (! ckd_add (&ot, t, delta * direction)) { struct tm otm; - if (! ranged_convert (convert, &ot, &otm)) + if (! ranged_convert (local, &ot, &otm)) return -1; if (! isdst_differ (isdst, otm.tm_isdst)) { @@ -479,7 +491,7 @@ __mktime_internal (struct tm *tp, &otm); if (mktime_min <= gt && gt <= mktime_max) { - if (convert_time (convert, gt, &tm)) + if (__tz_convert (gt, local, &tm)) { t = gt; goto offset_found; @@ -493,7 +505,7 @@ __mktime_internal (struct tm *tp, /* No unusual DST offset was found nearby. Assume one-hour DST. */ t += 60 * 60 * dst_difference; - if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm)) + if (mktime_min <= t && t <= mktime_max && __tz_convert (t, local, &tm)) goto offset_found; __set_errno (EOVERFLOW); @@ -520,7 +532,7 @@ __mktime_internal (struct tm *tp, __set_errno (EOVERFLOW); return -1; } - if (! convert_time (convert, t, &tm)) + if (! __tz_convert (t, local, &tm)) return -1; } @@ -536,14 +548,13 @@ __mktime_internal (struct tm *tp, __time64_t __mktime64 (struct tm *tp) { - /* POSIX.1 8.1.1 requires that whenever mktime() is called, the - time zone names contained in the external variable 'tzname' shall - be set as if the tzset() function had been called. */ + /* POSIX.1 requires mktime to set external variables like 'tzname' + as though tzset had been called. */ __tzset (); # if defined _LIBC || NEED_MKTIME_WORKING static mktime_offset_t localtime_offset; - return __mktime_internal (tp, __localtime64_r, &localtime_offset); + return __mktime_internal (tp, true, &localtime_offset); # else # undef mktime return mktime (tp); diff --git a/lib/nproc.c b/lib/nproc.c index 92a07e82890..0b5898d88ff 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -20,6 +20,7 @@ #include #include "nproc.h" +#include #include #include #include @@ -125,6 +126,46 @@ num_processors_via_affinity_mask (void) } } #elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */ + /* There are two ways to use the sched_getaffinity() function: + - With a statically-sized cpu_set_t. + - With a dynamically-sized cpu_set_t. + Documentation: + + + The second way has the advantage that it works on systems with more than + 1024 CPUs. The first way has the advantage that it works also when memory + is tight. */ +# if defined CPU_ALLOC_SIZE /* glibc >= 2.6 */ + { + unsigned int alloc_count = 1024; + for (;;) + { + cpu_set_t *set = CPU_ALLOC (alloc_count); + if (set == NULL) + /* Out of memory. */ + break; + unsigned int size = CPU_ALLOC_SIZE (alloc_count); + if (sched_getaffinity (0, size, set) == 0) + { + unsigned int count = CPU_COUNT_S (size, set); + CPU_FREE (set); + return count; + } + if (errno != EINVAL) + { + /* Some other error. */ + CPU_FREE (set); + return 0; + } + CPU_FREE (set); + /* Retry with some larger cpu_set_t. */ + alloc_count *= 2; + if (alloc_count == 0) + /* Integer overflow. Avoid an endless loop. */ + return 0; + } + } +# endif { cpu_set_t set; diff --git a/lib/pipe2.c b/lib/pipe2.c index 7b476df3457..e290f94a94a 100644 --- a/lib/pipe2.c +++ b/lib/pipe2.c @@ -40,7 +40,7 @@ pipe2 (int fd[2], int flags) { /* Mingw _pipe() corrupts fd on failure; also, if we succeed at creating the pipe but later fail at changing fcntl, we want - to leave fd unchanged: http://austingroupbugs.net/view.php?id=467 */ + to leave fd unchanged: https://austingroupbugs.net/view.php?id=467 */ int tmp[2]; tmp[0] = fd[0]; tmp[1] = fd[1]; diff --git a/lib/realloc.c b/lib/realloc.c index 0573139625e..58044745f45 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -18,17 +18,21 @@ /* written by Jim Meyering and Bruno Haible */ +/* Ensure that we call the system's realloc() below. */ +#define _GL_USE_STDLIB_ALLOC 1 #include +#define _GL_REALLOC_INLINE _GL_EXTERN_INLINE #include #include +#include -#include "xalloc-oversized.h" +#ifdef __CHERI_PURE_CAPABILITY__ +# include +#endif -/* Call the system's realloc below. This file does not define - _GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */ -#undef realloc +#ifndef _GL_INLINE_RPL_REALLOC /* Change the size of an allocated block of memory P to N bytes, with error checking. If P is NULL, use malloc. Otherwise if N is zero, @@ -37,27 +41,70 @@ void * rpl_realloc (void *p, size_t n) { - if (p == NULL) - return malloc (n); + size_t n1 = n; if (n == 0) { - free (p); - return NULL; +# if NEED_SANITIZED_REALLOC + /* When P is non-null, ISO C23 §7.24.3.7.(3) says realloc (P, 0) has + undefined behavior even though C17 and earlier partially defined + the behavior. Let the programmer know. + When the undefined-behaviour sanitizers report this case, i.e. when + and + + have been closed and new releases of GCC and clang have been made, + we can revisit this code. */ + if (p != NULL) + abort (); +# endif + + /* realloc (NULL, 0) acts like glibc malloc (0), i.e., like malloc (1) + except the caller cannot dereference any non-null return. + + realloc (P, 0) with non-null P is a messier situation. + As mentioned above, C23 says behavior is undefined. + POSIX.1-2024 extends C17 to say realloc (P, 0) + either fails by setting errno and returning a null pointer, + or succeeds by freeing P and then either: + (a) setting errno=EINVAL and returning a null pointer; or + (b) acting like a successful malloc (0). + glibc 1 through 2.1 realloc acted like (b), + which conforms to C17, to C23 and to POSIX.1-2024. + glibc 2.1.1+ realloc acts like (a) except it does not set errno; + this conforms to C17 and to C23 but not to POSIX.1-2024. + Quite possibly future versions of POSIX will change, + due either to C23 or to (a)'s semantics being messy. + Act like (b), as that's easy, matches GNU, BSD and V7 malloc, + matches BSD and V7 realloc, and requires no extra code at + caller sites. */ + +# if !HAVE_REALLOC_0_NONNULL + n1 = 1; +# endif } - if (xalloc_oversized (n, 1)) +# if !HAVE_MALLOC_PTRDIFF + ptrdiff_t signed_n; + if (ckd_add (&signed_n, n, 0)) { errno = ENOMEM; return NULL; } +# endif - void *result = realloc (p, n); + void *result = realloc (p, n1); -#if !HAVE_MALLOC_POSIX +# if !HAVE_MALLOC_POSIX if (result == NULL) errno = ENOMEM; -#endif +# endif + +# ifdef __CHERI_PURE_CAPABILITY__ + if (result != NULL) + result = cheri_bounds_set (result, n); +# endif return result; } + +#endif diff --git a/lib/regex.h b/lib/regex.h index ccf40cebc0e..004dc624050 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -647,10 +647,12 @@ extern int re_exec (const char *); || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ || __clang_major__ >= 3 # define _Restrict_ __restrict -# elif 199901L <= __STDC_VERSION__ || defined restrict -# define _Restrict_ restrict # else -# define _Restrict_ +# if 199901L <= __STDC_VERSION__ || defined restrict +# define _Restrict_ restrict +# else +# define _Restrict_ +# endif # endif #endif /* For the ISO C99 syntax @@ -661,13 +663,15 @@ extern int re_exec (const char *); #ifndef _Restrict_arr_ # ifdef __restrict_arr # define _Restrict_arr_ __restrict_arr -# elif ((199901L <= __STDC_VERSION__ \ +# else +# if ((199901L <= __STDC_VERSION__ \ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ || __clang_major__ >= 3) \ && !defined __cplusplus) -# define _Restrict_arr_ _Restrict_ -# else -# define _Restrict_arr_ +# define _Restrict_arr_ _Restrict_ +# else +# define _Restrict_arr_ +# endif # endif #endif diff --git a/lib/regex_internal.c b/lib/regex_internal.c index 8cd096ebcfb..6ccf701f266 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c @@ -937,8 +937,7 @@ re_node_set_alloc (re_node_set *set, Idx size) set->alloc = size; set->nelem = 0; set->elems = re_malloc (Idx, size); - if (__glibc_unlikely (set->elems == NULL) - && (MALLOC_0_IS_NONNULL || size != 0)) + if (__glibc_unlikely (set->elems == NULL)) return REG_ESPACE; return REG_NOERROR; } diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 6165cb17c70..02c2ca68960 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -100,10 +100,12 @@ /* This is for other GNU distributions with internationalized messages. */ #if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC # include +# undef gettext # ifdef _LIBC -# undef gettext # define gettext(msgid) \ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) +# else +# define gettext(msgid) dgettext ("gnulib", msgid) # endif #else # undef gettext @@ -436,12 +438,6 @@ typedef struct re_dfa_t re_dfa_t; #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) -#ifdef _LIBC -# define MALLOC_0_IS_NONNULL 1 -#elif !defined MALLOC_0_IS_NONNULL -# define MALLOC_0_IS_NONNULL 0 -#endif - #ifndef MAX # define MAX(a,b) ((a) < (b) ? (b) : (a)) #endif diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h index 63ebf7c64b7..dfb5166171a 100644 --- a/lib/stdio-impl.h +++ b/lib/stdio-impl.h @@ -110,7 +110,7 @@ # endif # if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ - /* See + /* See and and */ struct __sfileext diff --git a/lib/stdlib.c b/lib/stdlib.c new file mode 100644 index 00000000000..521d64627dc --- /dev/null +++ b/lib/stdlib.c @@ -0,0 +1,21 @@ +/* Inline functions for . + + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#define _GL_STDLIB_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 6667f426ad9..adbef69131b 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -54,7 +54,7 @@ /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, - GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ + _GL_INLINE_HEADER_BEGIN, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -130,6 +130,14 @@ struct random_data # include #endif +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_STDLIB_INLINE +# define _GL_STDLIB_INLINE _GL_INLINE +#endif +#ifndef _GL_REALLOC_INLINE +# define _GL_REALLOC_INLINE _GL_INLINE +#endif + /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers that can be freed by passing them as the Ith argument to the function F. */ @@ -283,8 +291,8 @@ _GL_CXXALIASWARN (free); #elif defined GNULIB_POSIXCHECK # undef free /* Assume free is always declared. */ -_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " - "use gnulib module free for portability"); +_GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - " + "use gnulib module free-posix for portability"); #endif @@ -367,9 +375,10 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " #endif #if @GNULIB_CALLOC_POSIX@ -# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \ +# if @REPLACE_CALLOC_FOR_CALLOC_POSIX@ \ || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) # undef calloc # define calloc rpl_calloc # endif @@ -681,7 +690,7 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - " by never specifying a zero size), so it does not need malloc or realloc to be redefined. */ #if @GNULIB_MALLOC_POSIX@ -# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \ +# if @REPLACE_MALLOC_FOR_MALLOC_POSIX@ \ || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@) # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) @@ -740,11 +749,12 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " /* Return maximum number of bytes of a multibyte character. */ #if @REPLACE_MB_CUR_MAX@ # if !GNULIB_defined_MB_CUR_MAX -static inline -int gl_MB_CUR_MAX (void) +_GL_STDLIB_INLINE int +gl_MB_CUR_MAX (void) { /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ - return MB_CUR_MAX + (MB_CUR_MAX == 3); + int gl_mb_cur_max = MB_CUR_MAX; + return gl_mb_cur_max == 3 ? 4 : gl_mb_cur_max; } # undef MB_CUR_MAX # define MB_CUR_MAX gl_MB_CUR_MAX () @@ -1454,16 +1464,25 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ -# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ - || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 +# define _GL_INLINE_RPL_REALLOC 1 +_GL_REALLOC_INLINE void * +rpl_realloc (void *ptr, size_t size) +{ + return realloc (ptr, size ? size : 1); +} +# endif # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) # undef realloc # define realloc rpl_realloc # endif +# if !defined _GL_INLINE_RPL_REALLOC _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size), _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD); +# endif _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else # if __GNUC__ >= 11 && !defined __clang__ @@ -1968,6 +1987,8 @@ _GL_CXXALIASWARN (wctomb); #endif +_GL_INLINE_HEADER_END + #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif diff --git a/lib/timegm.c b/lib/timegm.c index e5cf30c0198..ba28b3ecd96 100644 --- a/lib/timegm.c +++ b/lib/timegm.c @@ -30,8 +30,7 @@ __time64_t __timegm64 (struct tm *tmp) { static mktime_offset_t gmtime_offset; - tmp->tm_isdst = 0; - return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset); + return __mktime_internal (tmp, false, &gmtime_offset); } #if defined _LIBC && __TIMESIZE != 64 diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 20b1356fd38..ceb3cb48f15 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -181,6 +181,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_UNISTD_INLINE # define _GL_UNISTD_INLINE _GL_INLINE #endif +#ifndef _GL_GETPAGESIZE_INLINE +# define _GL_GETPAGESIZE_INLINE _GL_INLINE +#endif /* Hide some function declarations from . */ @@ -1478,7 +1481,7 @@ _GL_FUNCDECL_SYS (getpagesize, int, (void), ); # define getpagesize() _gl_getpagesize () # else # if !GNULIB_defined_getpagesize_function -_GL_UNISTD_INLINE int +_GL_GETPAGESIZE_INLINE int getpagesize () { return _gl_getpagesize (); diff --git a/lib/utimens.c b/lib/utimens.c index cd86a44ea76..3c81b5c3492 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -78,6 +78,21 @@ static int utimensat_works_really; static int lutimensat_works_really; #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ +static bool +is_valid_timespec (struct timespec const *timespec) +{ + return (timespec->tv_nsec == UTIME_NOW + || timespec->tv_nsec == UTIME_OMIT + || (0 <= timespec->tv_nsec && timespec->tv_nsec < TIMESPEC_HZ)); +} + +static bool +is_valid_timespecs (struct timespec const timespec[2]) +{ + return (is_valid_timespec (×pec[0]) + && is_valid_timespec (×pec[1])); +} + /* Validate the requested timestamps. Return 0 if the resulting timespec can be used for utimensat (after possibly modifying it to work around bugs in utimensat). Return a positive value if the @@ -90,14 +105,7 @@ validate_timespec (struct timespec timespec[2]) { int result = 0; int utime_omit_count = 0; - if ((timespec[0].tv_nsec != UTIME_NOW - && timespec[0].tv_nsec != UTIME_OMIT - && ! (0 <= timespec[0].tv_nsec - && timespec[0].tv_nsec < TIMESPEC_HZ)) - || (timespec[1].tv_nsec != UTIME_NOW - && timespec[1].tv_nsec != UTIME_OMIT - && ! (0 <= timespec[1].tv_nsec - && timespec[1].tv_nsec < TIMESPEC_HZ))) + if (!is_valid_timespecs (timespec)) { errno = EINVAL; return -1; @@ -516,24 +524,44 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) } } -#if !HAVE_UTIMENS /* Set the access and modification timestamps of FILE to be TIMESPEC[0] and TIMESPEC[1], respectively. */ int utimens (char const *file, struct timespec const timespec[2]) +#undef utimens { +#if HAVE_UTIMENS + /* NetBSD's native utimens() does not fulfil the Gnulib expectations: + At least in NetBSD 10.0, it does not validate the timespec argument. */ + if (timespec != NULL && !is_valid_timespecs (timespec)) + { + errno = EINVAL; + return -1; + } + return utimens (file, timespec); +#else return fdutimens (-1, file, timespec); -} #endif +} -#if !HAVE_LUTIMENS /* Set the access and modification timestamps of FILE to be TIMESPEC[0] and TIMESPEC[1], respectively, without dereferencing symlinks. Fail with ENOSYS if the platform does not support changing symlink timestamps, but FILE was a symlink. */ int lutimens (char const *file, struct timespec const timespec[2]) +#undef lutimens { +#if HAVE_LUTIMENS + /* NetBSD's native lutimens() does not fulfil the Gnulib expectations: + At least in NetBSD 10.0, it does not validate the timespec argument. */ + if (timespec != NULL && !is_valid_timespecs (timespec)) + { + errno = EINVAL; + return -1; + } + return lutimens (file, timespec); +#else struct timespec adjusted_timespec[2]; struct timespec *ts = timespec ? adjusted_timespec : NULL; int adjustment_needed = 0; @@ -553,11 +581,11 @@ lutimens (char const *file, struct timespec const timespec[2]) fdutimens' worry about buggy NFS clients. But we do have to worry about bogus return values. */ -#if HAVE_UTIMENSAT +# if HAVE_UTIMENSAT if (0 <= lutimensat_works_really) { int result; -# if defined __linux__ || defined __sun || defined __NetBSD__ +# if defined __linux__ || defined __sun || defined __NetBSD__ /* As recently as Linux kernel 2.6.32 (Dec 2009), several file systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT, but work if both times are either explicitly specified or @@ -582,9 +610,9 @@ lutimens (char const *file, struct timespec const timespec[2]) /* Note that st is good, in case utimensat gives ENOSYS. */ adjustment_needed++; } -# endif +# endif result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW); -# ifdef __linux__ +# ifdef __linux__ /* Work around a kernel bug: https://bugzilla.redhat.com/show_bug.cgi?id=442352 https://bugzilla.redhat.com/show_bug.cgi?id=449910 @@ -594,7 +622,7 @@ lutimens (char const *file, struct timespec const timespec[2]) are no longer in common use. */ if (0 < result) errno = ENOSYS; -# endif +# endif if (result == 0 || errno != ENOSYS) { utimensat_works_really = 1; @@ -603,7 +631,7 @@ lutimens (char const *file, struct timespec const timespec[2]) } } lutimensat_works_really = -1; -#endif /* HAVE_UTIMENSAT */ +# endif /* HAVE_UTIMENSAT */ /* The platform lacks an interface to set file timestamps with nanosecond resolution, so do the best we can, discarding any @@ -619,7 +647,7 @@ lutimens (char const *file, struct timespec const timespec[2]) /* On Linux, lutimes is a thin wrapper around utimensat, so there is no point trying lutimes if utimensat failed with ENOSYS. */ -#if HAVE_LUTIMES && !HAVE_UTIMENSAT +# if HAVE_LUTIMES && !HAVE_UTIMENSAT { struct timeval timeval[2]; struct timeval *t; @@ -639,7 +667,7 @@ lutimens (char const *file, struct timespec const timespec[2]) if (result == 0 || errno != ENOSYS) return result; } -#endif /* HAVE_LUTIMES && !HAVE_UTIMENSAT */ +# endif /* HAVE_LUTIMES && !HAVE_UTIMENSAT */ /* Out of luck for symlinks, but we still handle regular files. */ if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st)) @@ -648,5 +676,5 @@ lutimens (char const *file, struct timespec const timespec[2]) return fdutimens (-1, file, ts); errno = ENOSYS; return -1; -} #endif +} diff --git a/lib/utimens.h b/lib/utimens.h index e85477b8493..762c3f9a858 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -33,12 +33,16 @@ extern "C" { #endif int fdutimens (int, char const *, struct timespec const [2]); -#if !HAVE_UTIMENS + +#if HAVE_UTIMENS +# define utimens rpl_utimens +#endif int utimens (char const *, struct timespec const [2]); + +#if HAVE_LUTIMENS +# define lutimens rpl_lutimens #endif -#if !HAVE_LUTIMENS int lutimens (char const *, struct timespec const [2]); -#endif #ifdef __cplusplus } diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 index cd16771848c..aac283b3287 100644 --- a/m4/00gnulib.m4 +++ b/m4/00gnulib.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl This file must be named something that sorts before all other dnl gnulib-provided .m4 files. It is needed until the clang fix has diff --git a/m4/__inline.m4 b/m4/__inline.m4 index 20baf16437f..d4887e31102 100644 --- a/m4/__inline.m4 +++ b/m4/__inline.m4 @@ -4,6 +4,7 @@ dnl Copyright 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Test for __inline keyword diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 index 0abd6d9002c..5314bcc0e80 100644 --- a/m4/absolute-header.m4 +++ b/m4/absolute-header.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Derek Price. diff --git a/m4/acl.m4 b/m4/acl.m4 index be88f1b8313..68d7799b668 100644 --- a/m4/acl.m4 +++ b/m4/acl.m4 @@ -1,9 +1,10 @@ # acl.m4 -# serial 31 +# serial 34 dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for access control list (ACL) primitives @@ -15,9 +16,12 @@ AC_DEFUN([gl_FUNC_ACL_ARG], AC_ARG_ENABLE([acl], AS_HELP_STRING([[--disable-acl]], [do not support ACLs]), , [enable_acl=auto]) + AC_ARG_WITH([libsmack], + [AS_HELP_STRING([--without-libsmack], + [do not use libsmack, even on systems that have it])] + [], [with_libsmack=maybe]) ]) - AC_DEFUN_ONCE([gl_FUNC_ACL], [ AC_REQUIRE([gl_FUNC_ACL_ARG]) @@ -30,8 +34,8 @@ AC_DEFUN_ONCE([gl_FUNC_ACL], if test $ac_cv_header_sys_acl_h = yes; then gl_saved_LIBS=$LIBS - dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, Mac OS X, - dnl IRIX, Tru64, Cygwin >= 2.5). + dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, NetBSD >= 10, + dnl Mac OS X, IRIX, Tru64, Cygwin >= 2.5). dnl -lacl is needed on GNU/Linux, -lpacl on OSF/1. if test $use_acl = 0; then AC_SEARCH_LIBS([acl_get_file], [acl pacl], @@ -40,6 +44,7 @@ AC_DEFUN_ONCE([gl_FUNC_ACL], fi AC_CHECK_FUNCS( [acl_get_file acl_get_fd acl_set_file acl_set_fd \ + acl_get_link_np \ acl_free acl_from_mode acl_from_text \ acl_delete_def_file acl_extended_file \ acl_delete_fd_np acl_delete_file_np \ @@ -189,9 +194,35 @@ AC_DEFUN([gl_FILE_HAS_ACL], AC_CHECK_HEADERS_ONCE([linux/xattr.h]) AC_CHECK_FUNCS_ONCE([listxattr]) FILE_HAS_ACL_LIB= - AS_CASE([$enable_acl,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr], - [no,*,*], [], - [*,yes,yes], [], + + gl_file_has_acl_uses_smack=no + AS_CASE([$enable_acl,$with_libsmack,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr], + [no,* | *,no,*], [], + [*,*,yes,yes], + [AC_CHECK_HEADER([sys/smack.h], + [gl_saved_LIBS=$LIBS + AC_SEARCH_LIBS([smack_new_label_from_path], [smack], + [AC_DEFINE([HAVE_SMACK], [1], + [Define to 1 if libsmack is usable.]) + AS_CASE([$ac_cv_search_smack_new_label_from_path], + ["none required"], [], + [FILE_HAS_ACL_LIB=$ac_cv_search_new_label_from_path]) + gl_file_has_acl_uses_smack=yes], + [AS_CASE([$with_libsmack], + [yes], [AC_MSG_ERROR([libsmack not found or unusable])])]) + LIBS=$gl_saved_LIBS])]) + + gl_file_has_acl_uses_selinux=no + AS_CASE([$enable_acl,$with_selinux,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr], + [no,* | *,no,*], [], + [*,*,yes,yes], + [AC_REQUIRE([gl_CHECK_HEADER_SELINUX_SELINUX_H]) + AS_IF([test $USE_SELINUX_SELINUX_H = 1], + [FILE_HAS_ACL_LIB="$FILE_HAS_ACL_LIB $LIB_SELINUX" + gl_file_has_acl_uses_selinux=yes])]) + + AS_CASE([$enable_acl,$gl_file_has_acl_uses_selinux,$gl_file_has_acl_uses_smack], + [no,* | *,yes,* | *,yes], [], [*], [dnl Set gl_need_lib_has_acl to a nonempty value, so that any dnl later gl_FUNC_ACL call will set FILE_HAS_ACL_LIB=$LIB_ACL. diff --git a/m4/alloca.m4 b/m4/alloca.m4 index dc78dc19a87..d746131352e 100644 --- a/m4/alloca.m4 +++ b/m4/alloca.m4 @@ -5,6 +5,7 @@ dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_ALLOCA], [ diff --git a/m4/assert_h.m4 b/m4/assert_h.m4 index b90d0f19390..02f24db5350 100644 --- a/m4/assert_h.m4 +++ b/m4/assert_h.m4 @@ -1,9 +1,10 @@ # assert_h.m4 -# serial 1 +# serial 4 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Paul Eggert. @@ -12,30 +13,31 @@ AC_DEFUN([gl_ASSERT_H], AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], [gl_saved_CFLAGS=$CFLAGS for gl_working in "yes, a keyword" "yes, an macro"; do - AS_CASE([$gl_working], - [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"]) - - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#if defined __clang__ && __STDC_VERSION__ < 202311 - #pragma clang diagnostic error "-Wc2x-extensions" - #pragma clang diagnostic error "-Wc++1z-extensions" - #endif - #ifdef INCLUDE_ASSERT_H - #include - #endif - static_assert (2 + 2 == 4, "arithmetic does not work"); - static_assert (2 + 2 == 4); - ]], - [[ - static_assert (sizeof (char) == 1, "sizeof does not work"); - static_assert (sizeof (char) == 1); - ]])], - [gl_cv_static_assert=$gl_working], - [gl_cv_static_assert=no]) - CFLAGS=$gl_saved_CFLAGS - test "$gl_cv_static_assert" != no && break - done]) + AS_CASE([$gl_working], + [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if defined __clang__ && __STDC_VERSION__ < 202311 + #pragma clang diagnostic error "-Wc2x-extensions" + #pragma clang diagnostic error "-Wc++1z-extensions" + #endif + #ifdef INCLUDE_ASSERT_H + #include + #endif + static_assert (2 + 2 == 4, "arithmetic does not work"); + static_assert (2 + 2 == 4); + ]], + [[ + static_assert (sizeof (char) == 1, "sizeof does not work"); + static_assert (sizeof (char) == 1); + ]]) + ], + [gl_cv_static_assert=$gl_working], + [gl_cv_static_assert=no]) + CFLAGS=$gl_saved_CFLAGS + test "$gl_cv_static_assert" != no && break + done + ]) GL_GENERATE_ASSERT_H=false AS_CASE([$gl_cv_static_assert], @@ -48,6 +50,10 @@ AC_DEFUN([gl_ASSERT_H], dnl The "zz" puts this toward config.h's end, to avoid potential dnl collisions with other definitions. + dnl Hardcode the known configuration results for GCC and clang, so that + dnl a configuration made with the C compiler works also with the C++ compiler + dnl and vice versa. + dnl The seemingly redundant parentheses are necessary for MSVC 14. dnl #undef assert so that programs are not tempted to use it without dnl specifically including assert.h. dnl #undef __ASSERT_H__ so that on IRIX, when programs later include @@ -55,7 +61,16 @@ AC_DEFUN([gl_ASSERT_H], dnl Break the #undef_s apart with a comment so that 'configure' does dnl not comment them out. AH_VERBATIM([zzstatic_assert], -[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ +[#if (!(defined __clang__ \ + ? (defined __cplusplus \ + ? __cplusplus >= 201703L \ + : __STDC_VERSION__ >= 202000L && __clang_major__ >= 16) \ + : (defined __GNUC__ \ + ? (defined __cplusplus \ + ? __cplusplus >= 201103L && __GNUG__ >= 6 \ + : __STDC_VERSION__ >= 202000L && __GNUC__ >= 13) \ + : defined HAVE_C_STATIC_ASSERT)) \ + && !defined assert \ && (!defined __cplusplus \ || (__cpp_static_assert < 201411 \ && __GNUG__ < 6 && __clang_major__ < 6))) @@ -65,8 +80,9 @@ AC_DEFUN([gl_ASSERT_H], #undef/**/__ASSERT_H__ #endif /* Solaris 11.4 defines static_assert as a macro with 2 arguments. - We need it also to be invocable with a single argument. */ - #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus + We need it also to be invocable with a single argument. + Haiku 2022 does not define static_assert at all. */ + #if (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus #undef/**/static_assert #define static_assert _Static_assert #endif diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4 index 33f255e9f56..917a98d3261 100644 --- a/m4/builtin-expect.m4 +++ b/m4/builtin-expect.m4 @@ -4,6 +4,7 @@ dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Provide a GCC-compatible __builtin_expect macro in . diff --git a/m4/byteswap.m4 b/m4/byteswap.m4 index e91da97b958..825b5a08b71 100644 --- a/m4/byteswap.m4 +++ b/m4/byteswap.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Oskar Liljeblad. diff --git a/m4/c-bool.m4 b/m4/c-bool.m4 index 0fb0de3b59e..fa792b12a14 100644 --- a/m4/c-bool.m4 +++ b/m4/c-bool.m4 @@ -1,9 +1,10 @@ # c-bool.m4 -# serial 1 +# serial 3 dnl Copyright 2022-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for bool that conforms to C2023. @@ -29,12 +30,23 @@ AC_DEFUN([gl_C_BOOL], dnl The "zz" puts this toward config.h's end, to avoid potential dnl collisions with other definitions. dnl If 'bool', 'true' and 'false' do not work, arrange for them to work. - dnl In C, this means including if it is not already included. + dnl Hardcode the known configuration results for GCC and clang, so that + dnl a configuration made with the C compiler works also with the C++ compiler + dnl and vice versa. + dnl The seemingly redundant parentheses are necessary for MSVC 14. + dnl "Arrange for them to work", in C, means including if it is + dnl not already included. dnl However, if the preprocessor mistakenly treats 'true' as 0, dnl define it to a bool expression equal to 1; this is needed in dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older. AH_VERBATIM([zzbool], -[#ifndef HAVE_C_BOOL +[#if !(defined __cplusplus \ + ? 1 \ + : (defined __clang__ \ + ? __STDC_VERSION__ >= 202000L && __clang_major__ >= 15 \ + : (defined __GNUC__ \ + ? __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \ + : defined HAVE_C_BOOL))) # if !defined __cplusplus && !defined __bool_true_false_are_defined # if HAVE_STDBOOL_H # include diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index ec7aac47089..74a5f95df5d 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -6,6 +6,7 @@ dnl Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Provides canonicalize_file_name and canonicalize_filename_mode, but does # not provide or fix realpath. diff --git a/m4/clock_time.m4 b/m4/clock_time.m4 index 27f6fd153a3..330883f7b86 100644 --- a/m4/clock_time.m4 +++ b/m4/clock_time.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for clock_getres, clock_gettime and clock_settime, # and set CLOCK_TIME_LIB. diff --git a/m4/codeset.m4 b/m4/codeset.m4 index e69b7402fc2..69c7046f94d 100644 --- a/m4/codeset.m4 +++ b/m4/codeset.m4 @@ -5,6 +5,7 @@ dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Bruno Haible. diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4 index 4ef75f62d40..dc13ff422fe 100644 --- a/m4/copy-file-range.m4 +++ b/m4/copy-file-range.m4 @@ -4,6 +4,7 @@ dnl Copyright 2019-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_COPY_FILE_RANGE], [ diff --git a/m4/d-type.m4 b/m4/d-type.m4 index 0ef89b86b15..d6de386363d 100644 --- a/m4/d-type.m4 +++ b/m4/d-type.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1997, 1999-2004, 2006, 2009-2024 Free Software Foundation, Inc dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. dnl diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4 index 037ae369a2d..20fa69f78e8 100644 --- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Bruno Haible. diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 index 605cb706c0a..f7ff53a9283 100644 --- a/m4/dirfd.m4 +++ b/m4/dirfd.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Find out how to get the file descriptor associated with an open DIR*. diff --git a/m4/double-slash-root.m4 b/m4/double-slash-root.m4 index 3437c699ada..93572ac99a5 100644 --- a/m4/double-slash-root.m4 +++ b/m4/double-slash-root.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_DOUBLE_SLASH_ROOT], [ diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 786121fd8f3..ed08cc526ed 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2005, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_DUP2], [ diff --git a/m4/endian_h.m4 b/m4/endian_h.m4 index 3149b492270..c205a44464b 100644 --- a/m4/endian_h.m4 +++ b/m4/endian_h.m4 @@ -4,6 +4,7 @@ dnl Copyright 2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl A placeholder for , for platforms that have issues. diff --git a/m4/environ.m4 b/m4/environ.m4 index 107960b2e77..6823dd405ba 100644 --- a/m4/environ.m4 +++ b/m4/environ.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_ENVIRON], [ diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index 920ea6cc653..9f8e8341c86 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_PREREQ([2.61]) diff --git a/m4/euidaccess.m4 b/m4/euidaccess.m4 index 3ade282f4ec..9052b9fa60a 100644 --- a/m4/euidaccess.m4 +++ b/m4/euidaccess.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_NONREENTRANT_EUIDACCESS], [ diff --git a/m4/execinfo.m4 b/m4/execinfo.m4 index 9dc8d6d489d..dcec42f9d20 100644 --- a/m4/execinfo.m4 +++ b/m4/execinfo.m4 @@ -4,6 +4,7 @@ dnl Copyright 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for GNU-style execinfo.h. diff --git a/m4/extensions-aix.m4 b/m4/extensions-aix.m4 index 990a7ac3ef0..e2b85224a25 100644 --- a/m4/extensions-aix.m4 +++ b/m4/extensions-aix.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # On AIX, most extensions are already enabled through the _ALL_SOURCE macro, # defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally diff --git a/m4/extensions.m4 b/m4/extensions.m4 index 1fb68956b33..7c35419da2c 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Enable extensions on systems that normally disable them. diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index 547da82afa5..5e13812a97c 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -4,6 +4,7 @@ dnl Copyright 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl 'extern inline' a la ISO C99. diff --git a/m4/faccessat.m4 b/m4/faccessat.m4 index c5f40e52900..a47129353d0 100644 --- a/m4/faccessat.m4 +++ b/m4/faccessat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide faccessat replacement. diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4 index 99dcf58aa7a..51505ebec5b 100644 --- a/m4/fchmodat.m4 +++ b/m4/fchmodat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Written by Jim Meyering. diff --git a/m4/fcntl.m4 b/m4/fcntl.m4 index f6d0f377319..130403b6567 100644 --- a/m4/fcntl.m4 +++ b/m4/fcntl.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # For now, this module ensures that fcntl() # - supports F_DUPFD correctly diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4 index b69f7a0ca81..a9af001a95c 100644 --- a/m4/fcntl_h.m4 +++ b/m4/fcntl_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Configure fcntl.h. diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4 index e9268378d6e..c4c5628fee8 100644 --- a/m4/fdopendir.m4 +++ b/m4/fdopendir.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide fdopendir. diff --git a/m4/filemode.m4 b/m4/filemode.m4 index cb87a564cfd..66bb70d8eaf 100644 --- a/m4/filemode.m4 +++ b/m4/filemode.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FILEMODE], [ diff --git a/m4/flexmember.m4 b/m4/flexmember.m4 index 73fb6142faf..605c42cb8ee 100644 --- a/m4/flexmember.m4 +++ b/m4/flexmember.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for flexible array member support. diff --git a/m4/fpending.m4 b/m4/fpending.m4 index 9f2d83fb117..b8d544f7552 100644 --- a/m4/fpending.m4 +++ b/m4/fpending.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2001, 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering dnl Using code from emacs, based on suggestions from Paul Eggert diff --git a/m4/fpieee.m4 b/m4/fpieee.m4 index 086d51ddf5b..3f6a3aad1f7 100644 --- a/m4/fpieee.m4 +++ b/m4/fpieee.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl IEEE 754 standardized three items: dnl - The formats of single-float and double-float - nowadays commonly diff --git a/m4/free.m4 b/m4/free.m4 index a2b596d67f7..ed2f606c814 100644 --- a/m4/free.m4 +++ b/m4/free.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Written by Paul Eggert and Bruno Haible. diff --git a/m4/fstatat.m4 b/m4/fstatat.m4 index c5ef7dfb197..be635c5268c 100644 --- a/m4/fstatat.m4 +++ b/m4/fstatat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Written by Jim Meyering. diff --git a/m4/fsusage.m4 b/m4/fsusage.m4 index 1ce90660858..69d2a65494e 100644 --- a/m4/fsusage.m4 +++ b/m4/fsusage.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1997-1998, 2000-2001, 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Obtaining file system usage information. diff --git a/m4/fsync.m4 b/m4/fsync.m4 index 6f49321c2db..288d93fd713 100644 --- a/m4/fsync.m4 +++ b/m4/fsync.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_FSYNC], [ diff --git a/m4/futimens.m4 b/m4/futimens.m4 index b5f22605f49..d9910a61ce8 100644 --- a/m4/futimens.m4 +++ b/m4/futimens.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide futimens replacement. diff --git a/m4/getdelim.m4 b/m4/getdelim.m4 index 61139039554..7587db7f941 100644 --- a/m4/getdelim.m4 +++ b/m4/getdelim.m4 @@ -6,6 +6,7 @@ dnl dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_PREREQ([2.59]) diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index aaefe9b2983..b16e486c028 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_GETDTABLESIZE], [ diff --git a/m4/getgroups.m4 b/m4/getgroups.m4 index 5457275e9e1..e91916edb45 100644 --- a/m4/getgroups.m4 +++ b/m4/getgroups.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1996-1997, 1999-2004, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. dnl A wrapper around AC_FUNC_GETGROUPS. diff --git a/m4/getline.m4 b/m4/getline.m4 index 36513cd4171..a7d0a9308b0 100644 --- a/m4/getline.m4 +++ b/m4/getline.m4 @@ -7,6 +7,7 @@ dnl dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_PREREQ([2.59]) diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 index 0918bcd21ec..e1a4d9be659 100644 --- a/m4/getloadavg.m4 +++ b/m4/getloadavg.m4 @@ -5,6 +5,7 @@ dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for getloadavg. diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 53cab8bef93..a5451c7e7c3 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Request a POSIX compliant getopt function. AC_DEFUN([gl_FUNC_GETOPT_POSIX], @@ -77,7 +78,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], fi dnl POSIX 2008 does not specify leading '+' behavior, but see - dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on + dnl https://austingroupbugs.net/view.php?id=191 for a recommendation on dnl the next version of POSIX. For now, we only guarantee leading '+' dnl behavior with getopt-gnu. if test -z "$gl_replace_getopt"; then diff --git a/m4/getrandom.m4 b/m4/getrandom.m4 index 0051c9c4218..312d2c92e75 100644 --- a/m4/getrandom.m4 +++ b/m4/getrandom.m4 @@ -4,6 +4,7 @@ dnl Copyright 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Paul Eggert. diff --git a/m4/gettime.m4 b/m4/gettime.m4 index 299f3d1b788..1e964ab6d4a 100644 --- a/m4/gettime.m4 +++ b/m4/gettime.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2004-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_GETTIME], [ diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 8135f89e584..65963fbafa7 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2003, 2005, 2007, 2009-2024 Free Software Foundation, Inc dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index d985522893f..0a5cbd55ecf 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,9 +1,10 @@ # gnulib-common.m4 -# serial 103 +# serial 106 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_PREREQ([2.62]) @@ -842,6 +843,35 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_UNUSED_LABEL # endif #endif + +/* The following attributes enable detection of multithread-safety problems + and resource leaks at compile-time, by clang ≥ 15, when the warning option + -Wthread-safety is enabled. For usage, see + . */ +#ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \ + __attribute__ ((__capability__ (concept))) +# else +# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) +# endif +#endif +#ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \ + __attribute__ ((__acquire_capability__ (resource))) +# else +# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) +# endif +#endif +#ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \ + __attribute__ ((__release_capability__ (resource))) +# else +# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) +# endif +#endif ]) AH_VERBATIM([c_linkage], [/* In C++, there is the concept of "language linkage", that encompasses @@ -1351,6 +1381,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], dnl -Wno-type-limits >= 4.3 >= 3.9 dnl -Wno-undef >= 3 >= 3.9 dnl -Wno-unsuffixed-float-constants >= 4.5 + dnl -Wno-unused-const-variable >= 4.4 >= 3.9 dnl -Wno-unused-function >= 3 >= 3.9 dnl -Wno-unused-parameter >= 3 >= 3.9 dnl @@ -1380,6 +1411,9 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS], -Wno-sign-conversion -Wno-type-limits #endif + #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3) + -Wno-unused-const-variable + #endif #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) -Wno-unsuffixed-float-constants #endif diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 31784600d44..5c28ea8b3b2 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -162,7 +162,6 @@ AC_DEFUN([gl_EARLY], # Code from module rawmemchr: # Code from module readlink: # Code from module readlinkat: - # Code from module realloc-gnu: # Code from module realloc-posix: # Code from module regex: # Code from module root-uid: @@ -221,7 +220,6 @@ AC_DEFUN([gl_EARLY], # Code from module verify: # Code from module vla: # Code from module warnings: - # Code from module xalloc-oversized: # Code from module year2038: AC_REQUIRE([AC_SYS_YEAR2038]) ]) @@ -424,6 +422,11 @@ AC_DEFUN([gl_INIT], ]) gl_SYS_STAT_MODULE_INDICATOR([lstat]) gl_MODULE_INDICATOR([lstat]) + AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + AC_LIBOBJ([malloc]) + fi + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) gl_FUNC_MEMMEM_SIMPLE if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then AC_LIBOBJ([memmem]) @@ -681,18 +684,15 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false gl_gnulib_enabled_lchmod=false gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=false - gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=false gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_open=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false gl_gnulib_enabled_rawmemchr=false - gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=false gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false gl_gnulib_enabled_strtoll=false gl_gnulib_enabled_utimens=false gl_gnulib_enabled_verify=false - gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () { if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then :; else @@ -788,9 +788,6 @@ AC_DEFUN([gl_INIT], [test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1]) gl_UNISTD_MODULE_INDICATOR([getgroups]) gl_gnulib_enabled_getgroups=true - if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then - func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 - fi fi } func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 () @@ -813,7 +810,6 @@ AC_DEFUN([gl_INIT], if $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then :; else AC_PROG_MKDIR_P gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9=true - func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 fi } @@ -831,7 +827,7 @@ AC_DEFUN([gl_INIT], func_gl_gnulib_m4code_getgroups fi if test $HAVE_GROUP_MEMBER = 0; then - func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b + func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b fi fi } @@ -856,24 +852,6 @@ AC_DEFUN([gl_INIT], fi gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=true - func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 - if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec - fi - fi - } - func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 () - { - if $gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866; then :; else - AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) - if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then - AC_LIBOBJ([malloc]) - fi - gl_STDLIB_MODULE_INDICATOR([malloc-posix]) - gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=true - if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec - fi fi } func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () @@ -920,39 +898,15 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_rawmemchr=true fi } - func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b () - { - if $gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b; then :; else - gl_FUNC_REALLOC_GNU - if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then - AC_LIBOBJ([realloc]) - fi - gl_STDLIB_MODULE_INDICATOR([realloc-gnu]) - gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=true - if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then - func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b - fi - func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 - if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec - fi - fi - } func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 () { if $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then :; else gl_FUNC_REALLOC_POSIX - if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then - AC_LIBOBJ([realloc]) - fi + gl_FUNC_REALLOC_0_NONNULL + gl_CONDITIONAL([GL_COND_OBJ_REALLOC_POSIX], + [test $REPLACE_REALLOC_FOR_REALLOC_POSIX != 0]) gl_STDLIB_MODULE_INDICATOR([realloc-posix]) gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=true - if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then - func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 - fi - if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec - fi fi } func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c () @@ -987,12 +941,6 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_verify=true fi } - func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () - { - if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then :; else - gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=true - fi - } if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c fi @@ -1053,9 +1001,6 @@ AC_DEFUN([gl_INIT], if $GL_GENERATE_IEEE754_H; then func_gl_gnulib_m4code_endian fi - if test $REPLACE_MKTIME = 1; then - func_gl_gnulib_m4code_verify - fi if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -1065,6 +1010,9 @@ AC_DEFUN([gl_INIT], if test $ac_use_included_regex = yes; then func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c fi + if test $ac_use_included_regex = yes; then + func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b + fi if test $ac_use_included_regex = yes; then func_gl_gnulib_m4code_verify fi @@ -1099,18 +1047,15 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod]) AM_CONDITIONAL([gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b], [$gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866], [$gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866]) AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b], [$gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b]) AM_CONDITIONAL([gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4], [$gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) # End of code from modules m4_ifval(gl_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || @@ -1468,6 +1413,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdio-read.c lib/stdio-write.c lib/stdio.in.h + lib/stdlib.c lib/stdlib.in.h lib/stpcpy.c lib/str-two-way.h @@ -1506,7 +1452,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/verify.h lib/vla.h lib/warn-on-use.h - lib/xalloc-oversized.h m4/00gnulib.m4 m4/__inline.m4 m4/absolute-header.m4 @@ -1525,7 +1470,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/dirfd.m4 m4/double-slash-root.m4 m4/dup2.m4 - m4/eealloc.m4 m4/endian_h.m4 m4/environ.m4 m4/errno_h.m4 @@ -1605,6 +1549,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/readutmp.m4 m4/realloc.m4 m4/regex.m4 + m4/selinux-selinux-h.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 diff --git a/m4/group-member.m4 b/m4/group-member.m4 index f8ceb1d8186..7e0230dcecb 100644 --- a/m4/group-member.m4 +++ b/m4/group-member.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1999-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Jim Meyering diff --git a/m4/ieee754-h.m4 b/m4/ieee754-h.m4 index fa41db5c945..227a90dbdf4 100644 --- a/m4/ieee754-h.m4 +++ b/m4/ieee754-h.m4 @@ -4,6 +4,7 @@ dnl Copyright 2018-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Configure ieee754-h module diff --git a/m4/include_next.m4 b/m4/include_next.m4 index 03e852518e4..0043d560af9 100644 --- a/m4/include_next.m4 +++ b/m4/include_next.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Paul Eggert and Derek Price. diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index c43cd16207b..2173995ea6f 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Derek Price, Bruno Haible. dnl Test whether is supported or must be substituted. diff --git a/m4/largefile.m4 b/m4/largefile.m4 index 28813483594..2d30b8471b7 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -4,6 +4,7 @@ dnl Copyright 1992-1996, 1998-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Enable large files on systems where this is not the default. # Enable support for files on Linux file systems with 64-bit inode numbers. @@ -294,7 +295,7 @@ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])]) # By default, many hosts won't let programs access large files; # one must use special compiler options to get large-file access to work. # For more details about this brain damage please see: -# http://www.unix.org/version2/whatsnew/lfs20mar.html +# https://www.unix.org/version2/whatsnew/lfs20mar.html # Additionally, on Linux file systems with 64-bit inodes a file that happens # to have a 64-bit inode number cannot be accessed by 32-bit applications on # Linux x86/x86_64. This can occur with file systems such as XFS and NFS. diff --git a/m4/lchmod.m4 b/m4/lchmod.m4 index 797cb446938..29f06a22847 100644 --- a/m4/lchmod.m4 +++ b/m4/lchmod.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Paul Eggert. dnl Provide a replacement for lchmod on hosts that lack a working version. diff --git a/m4/libgmp.m4 b/m4/libgmp.m4 index a82a6fa1b71..e6dad10051f 100644 --- a/m4/libgmp.m4 +++ b/m4/libgmp.m4 @@ -5,6 +5,7 @@ dnl Copyright 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl gl_LIBGMP dnl Search for an installed libgmp. diff --git a/m4/limits-h.m4 b/m4/limits-h.m4 index 1b619e1eb2e..55dea94c9bf 100644 --- a/m4/limits-h.m4 +++ b/m4/limits-h.m4 @@ -4,6 +4,7 @@ dnl Copyright 2016-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Check whether limits.h has needed features. diff --git a/m4/locale-en.m4 b/m4/locale-en.m4 index 39d08a23b0b..a194894a43d 100644 --- a/m4/locale-en.m4 +++ b/m4/locale-en.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Bruno Haible. diff --git a/m4/lstat.m4 b/m4/lstat.m4 index f838e2cc1e8..530d99b3a15 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1997-2001, 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. diff --git a/m4/malloc.m4 b/m4/malloc.m4 index ee6df5c3fb6..a854ade93b3 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,12 +1,24 @@ # malloc.m4 -# serial 34 +# serial 43 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. - -# This is adapted with modifications from upstream Autoconf here: -# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 +dnl This file is offered as-is, without any warranty. + +m4_version_prereq([2.73], [], [ +# Modules that use this macro directly or indirectly should depend +# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined +# before this macro gets invoked. This helps on AIX 7.2 and earlier +# if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. +# +# This is copied from upstream Autoconf here: +# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=1f38316f6af7bf63e5e7dd187ff6456e07ad743e#n971 +# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME]) +# ------------------------------------------------------ +# If 'malloc (0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT. +# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME, +# which should end in "yes" or in something else (the latter is the default). AC_DEFUN([_AC_FUNC_MALLOC_IF], [ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles @@ -15,61 +27,81 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[#include - ]], - [[void *p = malloc (0); - void * volatile vp = p; - int result = !vp; + /* Use pmalloc to test; 'volatile' prevents the compiler + from optimizing the malloc call away. */ + void *(*volatile pmalloc) (size_t) = malloc;]], + [[void *p = pmalloc (0); + int result = !p; free (p); - return result;]]) - ], + return result;]])], [ac_cv_func_malloc_0_nonnull=yes], [ac_cv_func_malloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midipix* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) - ac_cv_func_malloc_0_nonnull="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; - esac - ]) - ]) + [AS_CASE([$host_os], + [# Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ + | gnu* | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin* | mingw* | windows* | msys*], + [ac_cv_func_malloc_0_nonnull="guessing yes"], + [# Guess as follows if we don't know. + ac_cv_func_malloc_0_nonnull=m4_default([$3], ["guessing no"])])])]) AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) ])# _AC_FUNC_MALLOC_IF +]) + +# gl_FUNC_MALLOC_0_NONNULL +# ------------------------ +# If 'malloc (0)' returns nonnull define HAVE_MALLOC_0_NONNULL. +# Also, set ac_cv_func_malloc_0_nonnull to a string that ends in +# "yes", otherwise set it to something else. If unknown whether +# malloc (0) works, guess as normal for cross-builds. +AC_DEFUN([gl_FUNC_MALLOC_0_NONNULL], +[ + _AC_FUNC_MALLOC_IF( + [AC_DEFINE([HAVE_MALLOC_0_NONNULL], [1], + [Define to 1 if malloc (0) returns nonnull.])], + [], + ["$gl_cross_guess_normal"]) +]) # gl_FUNC_MALLOC_GNU # ------------------ -# Replace malloc if it is not compatible with GNU libc. +# Test whether malloc (0) is compatible with GNU libc. +# Replace malloc if not. +# Define HAVE_MALLOC_0_NONNULL if malloc (0) returns nonnull (except upon +# out-of-memory). +# Define HAVE_MALLOC_PTRDIFF if malloc (N) reliably fails when N exceeds +# PTRDIFF_MAX. AC_DEFUN([gl_FUNC_MALLOC_GNU], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) + AC_REQUIRE([gl_FUNC_MALLOC_0_NONNULL]) - dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT - dnl gets defined already before this macro gets invoked. This helps - dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. - - REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" - if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then - _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) - fi + AS_CASE([$ac_cv_func_malloc_0_nonnull], + [*yes], + [REPLACE_MALLOC_FOR_MALLOC_GNU=$REPLACE_MALLOC_FOR_MALLOC_POSIX], + [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) ]) # gl_FUNC_MALLOC_PTRDIFF # ---------------------- -# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX, -# and replace malloc otherwise. +# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX. +# Define HAVE_MALLOC_PTRDIFF if yes. +# Replace malloc if not. AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) - test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1 + AS_IF([test "$gl_cv_malloc_ptrdiff" = yes], + [AC_DEFINE([HAVE_MALLOC_PTRDIFF], 1, + [Define to 1 if malloc-like functions do not allocate objects + larger than PTRDIFF_MAX bytes.])], + [REPLACE_MALLOC_FOR_MALLOC_POSIX=1]) ]) # Test whether malloc, realloc, calloc refuse to create objects # larger than what can be expressed in ptrdiff_t. -# Set gl_cv_func_malloc_gnu to yes or no accordingly. +# Set gl_cv_func_malloc_gnu. AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF], [ AC_CACHE_CHECK([whether malloc is ptrdiff_t safe], @@ -113,16 +145,19 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX], AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF]) AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) - if test "$gl_cv_func_malloc_posix" = yes; then - AC_DEFINE([HAVE_MALLOC_POSIX], [1], - [Define if malloc, realloc, and calloc set errno on allocation failure.]) - else - REPLACE_MALLOC_FOR_MALLOC_POSIX=1 - fi + case "$gl_cv_func_malloc_posix" in + *yes) + AC_DEFINE([HAVE_MALLOC_POSIX], [1], + [Define if malloc, realloc, and calloc set errno on allocation failure.]) + ;; + *) + REPLACE_MALLOC_FOR_MALLOC_POSIX=1 + ;; + esac ]) # Test whether malloc, realloc, calloc set errno to ENOMEM on failure. -# Set gl_cv_func_malloc_posix to yes or no accordingly. +# Set gl_cv_func_malloc_posix to *yes or *no accordingly. AC_DEFUN([gl_CHECK_MALLOC_POSIX], [ AC_REQUIRE([AC_CANONICAL_HOST]) @@ -133,10 +168,24 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX], dnl some systems go to their knees when you do that. So assume that dnl all Unix implementations of the function set errno on failure, dnl except on those platforms where we have seen 'test-malloc-gnu', - dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. + dnl 'test-realloc-posix', 'test-calloc-gnu' fail. case "$host_os" in mingw* | windows*) - gl_cv_func_malloc_posix=no ;; + dnl Old MSVCRT from 2001 did not set errno=ENOMEM when malloc failed. + dnl More recent MSVCRT from 2019 does so. + dnl UCRT is the successor of MSVCRT. Assume that UCRT does so as well. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #ifndef _UCRT + msvcrt yuck + #endif + ]], + [[]]) + ], + [gl_cv_func_malloc_posix="guessing yes"], + [gl_cv_func_malloc_posix="guessing no"]) + ;; irix* | solaris*) dnl On IRIX 6.5, the three functions return NULL with errno unset dnl when the argument is larger than PTRDIFF_MAX. diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 5b0baee2057..912f6aafd11 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,9 +1,10 @@ # manywarnings.m4 -# serial 27 +# serial 28 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Simon Josefsson @@ -185,6 +186,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], esac fi + # These options are not supported by gcc, but are useful with clang. + AS_VAR_APPEND([$1], [' -Wthread-safety']) + # Disable specific options as needed. if test "$gl_cv_cc_nomfi_needed" = yes; then AS_VAR_APPEND([$1], [' -Wno-missing-field-initializers']) diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4 index 66d65cd7c11..ae11afa9821 100644 --- a/m4/mbstate_t.m4 +++ b/m4/mbstate_t.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2002, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # From Paul Eggert. diff --git a/m4/md5.m4 b/m4/md5.m4 index a7b33d771ff..e081a6b42c6 100644 --- a/m4/md5.m4 +++ b/m4/md5.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_MD5], [ diff --git a/m4/memmem.m4 b/m4/memmem.m4 index e6b1d91cbb1..fba98ab759b 100644 --- a/m4/memmem.m4 +++ b/m4/memmem.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Check that memmem is present and functional. AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 index 377fda3caca..d73b40fa2b3 100644 --- a/m4/mempcpy.m4 +++ b/m4/mempcpy.m4 @@ -5,6 +5,7 @@ dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_MEMPCPY], [ diff --git a/m4/memrchr.m4 b/m4/memrchr.m4 index d8c931e90cc..a0c8a996640 100644 --- a/m4/memrchr.m4 +++ b/m4/memrchr.m4 @@ -5,6 +5,7 @@ dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_MEMRCHR], [ diff --git a/m4/memset_explicit.m4 b/m4/memset_explicit.m4 index 499a95968ab..abdabffcfa9 100644 --- a/m4/memset_explicit.m4 +++ b/m4/memset_explicit.m4 @@ -1,9 +1,10 @@ # memset_explicit.m4 -# serial 3 +# serial 4 dnl Copyright 2022-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_MEMSET_EXPLICIT], [ @@ -22,6 +23,36 @@ AC_DEFUN([gl_FUNC_MEMSET_EXPLICIT], AC_DEFUN([gl_PREREQ_MEMSET_EXPLICIT], [ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CHECK_FUNCS([explicit_memset]) AC_CHECK_FUNCS_ONCE([memset_s]) + if test $ac_cv_func_memset_s = yes; then + AC_CACHE_CHECK([for working memset_s], + [gl_cv_func_memset_s_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], [[ + (void) memset_s (NULL, 0, '?', 0); + ]]) + ], + [gl_cv_func_memset_s_works=yes], + [gl_cv_func_memset_s_works=no], + [case "$host_os" in + # Guess no on Solaris. + solaris*) + gl_cv_func_memset_s_works="guessing no" ;; + *) + gl_cv_func_memset_s_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_memset_s_works" in + *yes) + AC_DEFINE([HAVE_MEMSET_S_SUPPORTS_ZERO], [1], + [Define to 1 if memset_s support zero-length operations.]) + ;; + esac + fi ]) diff --git a/m4/minmax.m4 b/m4/minmax.m4 index bc7d0c345fa..2ce09e07774 100644 --- a/m4/minmax.m4 +++ b/m4/minmax.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_PREREQ([2.53]) diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4 index 57a033b859e..4656612b0ba 100644 --- a/m4/mkostemp.m4 +++ b/m4/mkostemp.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_MKOSTEMP], [ diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 85c52454aa5..cc4998804ed 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,9 +1,10 @@ # mktime.m4 -# serial 39 +# serial 42 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. diff --git a/m4/mode_t.m4 b/m4/mode_t.m4 index 0d5c2808289..159ef755d0d 100644 --- a/m4/mode_t.m4 +++ b/m4/mode_t.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # For using mode_t, it's sufficient to use AC_TYPE_MODE_T and # include . diff --git a/m4/multiarch.m4 b/m4/multiarch.m4 index 3af29d39a0b..bddff28e7c4 100644 --- a/m4/multiarch.m4 +++ b/m4/multiarch.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Determine whether the compiler is or may be producing universal binaries. # diff --git a/m4/musl.m4 b/m4/musl.m4 index 0d4de8926a2..6dccf1049f9 100644 --- a/m4/musl.m4 +++ b/m4/musl.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2019-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Test for musl libc, despite the musl libc authors don't like it # diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4 index a7281b8ac5f..569da93c01a 100644 --- a/m4/nanosleep.m4 +++ b/m4/nanosleep.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1999-2001, 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. dnl Check for the nanosleep function. diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index cbe8fe82d5d..dee7d74c727 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. diff --git a/m4/nproc.m4 b/m4/nproc.m4 index 317741d9b8d..9226560f6b2 100644 --- a/m4/nproc.m4 +++ b/m4/nproc.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_NPROC], [ diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4 index 534507d300b..f6b614a3d04 100644 --- a/m4/nstrftime.m4 +++ b/m4/nstrftime.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1996-1997, 1999-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Written by Jim Meyering and Paul Eggert. diff --git a/m4/off_t.m4 b/m4/off_t.m4 index db6035dbeb3..42cd98fbfb8 100644 --- a/m4/off_t.m4 +++ b/m4/off_t.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2012-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Check whether to override the 'off_t' type. dnl Set WINDOWS_64_BIT_OFF_T. diff --git a/m4/open-cloexec.m4 b/m4/open-cloexec.m4 index 6defdfb4005..91aa6efbea6 100644 --- a/m4/open-cloexec.m4 +++ b/m4/open-cloexec.m4 @@ -4,6 +4,7 @@ dnl Copyright 2017-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Test whether O_CLOEXEC is defined. diff --git a/m4/open-slash.m4 b/m4/open-slash.m4 index 03460e422d9..9d5c21ce1fb 100644 --- a/m4/open-slash.m4 +++ b/m4/open-slash.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Tests whether open() and creat() recognize a trailing slash. dnl Sets gl_cv_func_open_slash. diff --git a/m4/open.m4 b/m4/open.m4 index 62a11a110c5..600c2ec80dd 100644 --- a/m4/open.m4 +++ b/m4/open.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_OPEN], [ diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 index 4280837f1e1..958089e2d3a 100644 --- a/m4/pathmax.m4 +++ b/m4/pathmax.m4 @@ -5,6 +5,7 @@ dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_PATHMAX], [ diff --git a/m4/pid_t.m4 b/m4/pid_t.m4 index 8bedcc6bcd3..e014c0bd8f5 100644 --- a/m4/pid_t.m4 +++ b/m4/pid_t.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # The following implementation works around a problem in autoconf <= 2.69. m4_version_prereq([2.70], [], [ diff --git a/m4/pipe2.m4 b/m4/pipe2.m4 index e8ace7f077e..2bee623c005 100644 --- a/m4/pipe2.m4 +++ b/m4/pipe2.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_PIPE2], [ diff --git a/m4/pselect.m4 b/m4/pselect.m4 index 23d1fadd637..546235ec6a5 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_PSELECT], [ diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index 437869f6dbe..2de8ebebf16 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], [ diff --git a/m4/rawmemchr.m4 b/m4/rawmemchr.m4 index 6e0fa0a55e8..ffef17e982f 100644 --- a/m4/rawmemchr.m4 +++ b/m4/rawmemchr.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_RAWMEMCHR], [ diff --git a/m4/readlink.m4 b/m4/readlink.m4 index 7ebdb6ca14f..a7eb43504ab 100644 --- a/m4/readlink.m4 +++ b/m4/readlink.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_READLINK], [ diff --git a/m4/readlinkat.m4 b/m4/readlinkat.m4 index 4c4e3588e0a..81e389a1117 100644 --- a/m4/readlinkat.m4 +++ b/m4/readlinkat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide readlinkat replacement. diff --git a/m4/readutmp.m4 b/m4/readutmp.m4 index 1d9071fe65a..c11c2970609 100644 --- a/m4/readutmp.m4 +++ b/m4/readutmp.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_READUTMP], [ diff --git a/m4/realloc.m4 b/m4/realloc.m4 index cc91102836f..6401f22847c 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,59 +1,22 @@ # realloc.m4 -# serial 32 +# serial 39 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. -# This is adapted with modifications from upstream Autoconf here: -# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455 -AC_DEFUN([_AC_FUNC_REALLOC_IF], +# An an experimental option, the user can request a sanitized realloc() +# implementation, i.e. one that aborts upon undefined behaviour, +# by setting +# gl_cv_func_realloc_sanitize=yes +# at configure time. +AC_DEFUN([gl_FUNC_REALLOC_SANITIZED], [ - AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles - AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull], - [ac_cv_func_realloc_0_nonnull], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[#include - ]], - [[void *p = realloc (0, 0); - void * volatile vp = p; - int result = !vp; - free (p); - return result;]]) - ], - [ac_cv_func_realloc_0_nonnull=yes], - [ac_cv_func_realloc_0_nonnull=no], - [case "$host_os" in - # Guess yes on platforms where we know the result. - *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ - | gnu* | *-musl* | midipix* | midnightbsd* \ - | hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) - ac_cv_func_realloc_0_nonnull="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;; - esac - ]) - ]) - AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2]) -])# AC_FUNC_REALLOC - -# gl_FUNC_REALLOC_GNU -# ------------------- -# Replace realloc if it is not compatible with GNU libc. -AC_DEFUN([gl_FUNC_REALLOC_GNU], -[ - AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) - - dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT - dnl gets defined already before this macro gets invoked. This helps - dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. - - if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then - _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1]) - fi -])# gl_FUNC_REALLOC_GNU + AC_CACHE_CHECK([whether realloc should abort upon undefined behaviour], + [gl_cv_func_realloc_sanitize], + [test -n "$gl_cv_func_realloc_sanitize" || gl_cv_func_realloc_sanitize=no]) +]) # gl_FUNC_REALLOC_POSIX # --------------------- @@ -64,7 +27,59 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) - if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then + AC_REQUIRE([gl_FUNC_REALLOC_SANITIZED]) + if test "$gl_cv_func_realloc_sanitize" != no; then REPLACE_REALLOC_FOR_REALLOC_POSIX=1 + AC_DEFINE([NEED_SANITIZED_REALLOC], [1], + [Define to 1 if realloc should abort upon undefined behaviour.]) + else + REPLACE_REALLOC_FOR_REALLOC_POSIX=$REPLACE_MALLOC_FOR_MALLOC_POSIX fi ]) + +# gl_FUNC_REALLOC_0_NONNULL +# ------------------------- +# Replace realloc if realloc (..., 0) returns null. +# Modules that use this macro directly or indirectly should depend +# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined +# before this macro gets invoked. This helps if !(__VEC__ || __AIXVEC), +# and doesn't hurt otherwise. +AC_DEFUN([gl_FUNC_REALLOC_0_NONNULL], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_REQUIRE([gl_FUNC_REALLOC_POSIX]) + AC_CACHE_CHECK([whether realloc (..., 0) returns nonnull], + [gl_cv_func_realloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + /* Use prealloc to test; "volatile" prevents the compiler + from optimizing the realloc call away. */ + void *(*volatile prealloc) (void *, size_t) = realloc;]], + [[void *p = prealloc (0, 0); + int result = !p; + p = prealloc (p, 0); + result |= !p; + free (p); + return result;]])], + [gl_cv_func_realloc_0_nonnull=yes], + [gl_cv_func_realloc_0_nonnull=no], + [AS_CASE([$host_os], + [# Guess yes on platforms where we know the result. + freebsd* | netbsd* | openbsd* | darwin* | bitrig* \ + | *-musl* | midipix* | midnightbsd* \ + | hpux* | solaris* | cygwin*], + [gl_cv_func_realloc_0_nonnull="guessing yes"], + [# Guess as follows if we don't know. + gl_cv_func_realloc_0_nonnull=$gl_cross_guess_normal])])]) + AS_CASE([$gl_cv_func_realloc_0_nonnull], + [*yes], + [AC_DEFINE([HAVE_REALLOC_0_NONNULL], [1], + [Define to 1 if realloc (..., 0) returns nonnull.])], + [AS_CASE([$gl_cv_func_realloc_sanitize,$gl_cv_malloc_ptrdiff,$gl_cv_func_malloc_posix,$host], + [yes,*,*,* | *,no,*,* | *,*,*no,* | *,*,*,aarch64c-*-freebsd*], + [REPLACE_REALLOC_FOR_REALLOC_POSIX=1], + [# Optimize for common case of glibc 2.1.1+ and compatibles. + REPLACE_REALLOC_FOR_REALLOC_POSIX=2])]) +]) diff --git a/m4/regex.m4 b/m4/regex.m4 index f0101fe67c6..1060a8e8987 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,9 +1,10 @@ # regex.m4 -# serial 75 +# serial 78 dnl Copyright (C) 1996-2001, 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Initially derived from code in GNU grep. dnl Mostly written by Jim Meyering. @@ -39,16 +40,16 @@ AC_DEFUN([gl_REGEX], #include #include - #if defined M_CHECK_ACTION || HAVE_DECL_ALARM - # include - # include + #if HAVE_MALLOC_H + # include /* defines M_CHECK_ACTION on glibc */ #endif - #if HAVE_MALLOC_H - # include + #if defined __HAIKU__ || defined M_CHECK_ACTION || HAVE_DECL_ALARM + # include + # include #endif - #ifdef M_CHECK_ACTION + #if defined __HAIKU__ || defined M_CHECK_ACTION /* Exit with distinguishable exit code. */ static void sigabrt_no_core (int sig) { raise (SIGTERM); } #endif @@ -67,6 +68,9 @@ AC_DEFUN([gl_REGEX], signal (SIGALRM, SIG_DFL); alarm (2); #endif +#ifdef __HAIKU__ + signal (SIGABRT, sigabrt_no_core); +#endif #ifdef M_CHECK_ACTION signal (SIGABRT, sigabrt_no_core); mallopt (M_CHECK_ACTION, 2); @@ -388,7 +392,6 @@ AC_DEFUN([gl_PREREQ_REGEX], AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) - AC_REQUIRE([gl_EEMALLOC]) AC_CHECK_HEADERS([libintl.h]) AC_CHECK_FUNCS_ONCE([isblank iswctype]) AC_CHECK_DECLS([isblank], [], [], [[#include ]]) diff --git a/m4/selinux-selinux-h.m4 b/m4/selinux-selinux-h.m4 new file mode 100644 index 00000000000..c06a59415a3 --- /dev/null +++ b/m4/selinux-selinux-h.m4 @@ -0,0 +1,97 @@ +# selinux-selinux-h.m4 +# serial 10 -*- Autoconf -*- +dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. + +# From Jim Meyering +# Provide , if necessary. +# If it is already present, provide wrapper functions to guard against +# misbehavior from getfilecon, lgetfilecon, and fgetfilecon. + +AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H], +[ + AC_REQUIRE([gl_CHECK_HEADER_SELINUX_SELINUX_H]) + if test "$with_selinux" != no; then + if test "$ac_cv_header_selinux_selinux_h" = yes; then + # We do have , so do compile getfilecon.c + # and arrange to use its wrappers. + gl_CHECK_NEXT_HEADERS([selinux/selinux.h]) + AC_DEFINE([getfilecon], [rpl_getfilecon], + [Always use our getfilecon wrapper.]) + AC_DEFINE([getfilecon_raw], [rpl_getfilecon_raw], + [Always use our getfilecon_raw wrapper.]) + AC_DEFINE([lgetfilecon], [rpl_lgetfilecon], + [Always use our lgetfilecon wrapper.]) + AC_DEFINE([lgetfilecon_raw], [rpl_lgetfilecon_raw], + [Always use our lgetfilecon_raw wrapper.]) + AC_DEFINE([fgetfilecon], [rpl_fgetfilecon], + [Always use our fgetfilecon wrapper.]) + AC_DEFINE([fgetfilecon_raw], [rpl_fgetfilecon_raw], + [Always use our fgetfilecon_raw wrapper.]) + fi + fi +]) + +# Check for , if necessary. + +AC_DEFUN([gl_CHECK_HEADER_SELINUX_SELINUX_H], +[ + AC_REQUIRE([gl_LIBSELINUX]) + if test "$with_selinux" != no; then + AC_CHECK_HEADERS_ONCE([selinux/selinux.h]) + + if test $ac_cv_header_selinux_selinux_h = yes; then + USE_SELINUX_SELINUX_H=1 + else + USE_SELINUX_SELINUX_H=0 + fi + + case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in + no:*) # already warned + ;; + *:no) + AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.]) + AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.]) + ;; + esac + else + # Do as if does not exist, even if + # AC_CHECK_HEADERS_ONCE has already determined that it exists. + USE_SELINUX_SELINUX_H=0 + fi + AC_SUBST([USE_SELINUX_SELINUX_H]) + AC_DEFINE_UNQUOTED([USE_SELINUX_SELINUX_H], [$USE_SELINUX_SELINUX_H], + [Define to 1 if should be used, to 0 otherwise.]) +]) + +AC_DEFUN([gl_LIBSELINUX], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + + AC_ARG_WITH([selinux], + AS_HELP_STRING([[--without-selinux]], [do not use SELinux, even on systems with SELinux]), + [], [with_selinux=maybe]) + + LIB_SELINUX= + if test "$with_selinux" != no; then + gl_saved_LIBS=$LIBS + AC_SEARCH_LIBS([setfilecon], [selinux], + [test "$ac_cv_search_setfilecon" = "none required" || + LIB_SELINUX=$ac_cv_search_setfilecon]) + LIBS=$gl_saved_LIBS + fi + AC_SUBST([LIB_SELINUX]) + + # Warn if SELinux is found but libselinux is absent; + if test "$ac_cv_search_setfilecon" = no; then + if test "$host" = "$build" && test -d /selinux; then + AC_MSG_WARN([This system supports SELinux but libselinux is missing.]) + AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.]) + fi + with_selinux=no + fi +]) diff --git a/m4/sha1.m4 b/m4/sha1.m4 index 51f2afe8d0d..61189d260c4 100644 --- a/m4/sha1.m4 +++ b/m4/sha1.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_SHA1], [ diff --git a/m4/sha256.m4 b/m4/sha256.m4 index ad5596a488f..95070a15516 100644 --- a/m4/sha256.m4 +++ b/m4/sha256.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_SHA256], [ diff --git a/m4/sha512.m4 b/m4/sha512.m4 index 86e5518beec..d882973801b 100644 --- a/m4/sha512.m4 +++ b/m4/sha512.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_SHA512], [ diff --git a/m4/sig2str.m4 b/m4/sig2str.m4 index acef58a6a40..5e95f491b59 100644 --- a/m4/sig2str.m4 +++ b/m4/sig2str.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_SIG2STR], [ diff --git a/m4/sigdescr_np.m4 b/m4/sigdescr_np.m4 index 72da5e957ca..4f8f8cd58cf 100644 --- a/m4/sigdescr_np.m4 +++ b/m4/sigdescr_np.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_SIGDESCR_NP], [ diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 7a7d2b3c526..ef6c5df949c 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_SIGNAL_H], [ diff --git a/m4/socklen.m4 b/m4/socklen.m4 index 9ece0abb6d0..a2aca10e715 100644 --- a/m4/socklen.m4 +++ b/m4/socklen.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Albert Chin, Windows fixes from Simon Josefsson. diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4 index c15f948adb7..437f066c92c 100644 --- a/m4/ssize_t.m4 +++ b/m4/ssize_t.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2003, 2006, 2010-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Bruno Haible. dnl Define ssize_t if it does not already exist. diff --git a/m4/stat-time.m4 b/m4/stat-time.m4 index e8ee7d5125e..c192addd439 100644 --- a/m4/stat-time.m4 +++ b/m4/stat-time.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2024 Free Software Foun dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Checks for stat-related time functions. diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index 1c29d1e4fb9..fd6112b2d38 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -4,6 +4,7 @@ dnl Copyright 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for alignas and alignof that conform to C23. @@ -81,10 +82,10 @@ AC_DEFUN([gl_ALIGNASOF], References: ISO C23 (latest free draft - ) + ) sections 6.5.3.4, 6.7.5, 7.15. C++11 (latest free draft - ) + ) section 18.10. */ /* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 6af813f39dc..0aa9a634610 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -4,6 +4,7 @@ dnl Copyright 2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl A placeholder for , for platforms that have issues. diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index c7f75b37fa0..e80b56eef69 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl A placeholder for , for platforms that have issues. diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 2dea846914b..0a078e64d58 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Paul Eggert and Bruno Haible. dnl Test whether is supported or must be substituted. diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index ec52ae92ff4..14fb0d34c65 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_STDIO_H_EARLY], [ diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 5d9b3017c44..87b63ff54e3 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,9 +1,10 @@ # stdlib_h.m4 -# serial 81 +# serial 82 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_STDLIB_H], [ @@ -140,7 +141,6 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) - gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH]) @@ -247,7 +247,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_RAND=0; AC_SUBST([REPLACE_RAND]) REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) - REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU]) REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX]) REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4 index c4d71dd9fa5..0d7dca3dc6f 100644 --- a/m4/stpcpy.m4 +++ b/m4/stpcpy.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_STPCPY], [ diff --git a/m4/string_h.m4 b/m4/string_h.m4 index f31264ae85b..68464f0d083 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Configure a GNU-like replacement for . diff --git a/m4/strnlen.m4 b/m4/strnlen.m4 index 83a75c0c327..ecd25598196 100644 --- a/m4/strnlen.m4 +++ b/m4/strnlen.m4 @@ -5,6 +5,7 @@ dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. m4_version_prereq([2.73], [], [ # Replace AC_FUNC_STRNLEN from Autoconf 2.72 and earlier, diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4 index 2a0b50b3428..f4c6eb7e709 100644 --- a/m4/strtoimax.m4 +++ b/m4/strtoimax.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2004, 2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_STRTOIMAX], [ diff --git a/m4/strtoll.m4 b/m4/strtoll.m4 index 03a50dec2f1..e7f7654d91d 100644 --- a/m4/strtoll.m4 +++ b/m4/strtoll.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2004, 2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_STRTOLL], [ diff --git a/m4/symlink.m4 b/m4/symlink.m4 index 47968a1d33f..e56c96e6e0a 100644 --- a/m4/symlink.m4 +++ b/m4/symlink.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide symlink replacement. diff --git a/m4/sys_cdefs_h.m4 b/m4/sys_cdefs_h.m4 index 22fa6c3849e..95c9c722160 100644 --- a/m4/sys_cdefs_h.m4 +++ b/m4/sys_cdefs_h.m4 @@ -4,6 +4,7 @@ dnl Copyright 2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Paul Eggert. diff --git a/m4/sys_random_h.m4 b/m4/sys_random_h.m4 index 62fd519e365..6d40452462a 100644 --- a/m4/sys_random_h.m4 +++ b/m4/sys_random_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_SYS_RANDOM_H], [ diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4 index 550e066e171..9828237f622 100644 --- a/m4/sys_select_h.m4 +++ b/m4/sys_select_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_SYS_SELECT_H], [ diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 3bf3cb47778..2f1edcef1ad 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2005-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Simon Josefsson. diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 3cc50ce6776..2971bc526f3 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Eric Blake. dnl Provide a GNU-like . diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index d3203088934..6954319e4b4 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Configure a replacement for . diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 index 7c7f2655272..a7b289c206a 100644 --- a/m4/sys_types_h.m4 +++ b/m4/sys_types_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN_ONCE([gl_SYS_TYPES_H], [ diff --git a/m4/tempname.m4 b/m4/tempname.m4 index 795a9803fd0..2179cbe14bf 100644 --- a/m4/tempname.m4 +++ b/m4/tempname.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose # it as a public API, and provide it on systems that are lacking. diff --git a/m4/time_h.m4 b/m4/time_h.m4 index 88c76c03c02..28d698a1f0b 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Configure a more-standard replacement for . diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 3675390e871..05eaba31d90 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Reentrant time functions: localtime_r, gmtime_r. diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index 1a3dd3befb1..2e2ecab4867 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2015-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Time zone functions: tzalloc, localtime_rz, etc. diff --git a/m4/timegm.m4 b/m4/timegm.m4 index c1ff26777b8..9b12f1e4fda 100644 --- a/m4/timegm.m4 +++ b/m4/timegm.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_FUNC_TIMEGM], [ diff --git a/m4/timer_time.m4 b/m4/timer_time.m4 index 59a4cade539..8eb9f8e1a64 100644 --- a/m4/timer_time.m4 +++ b/m4/timer_time.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for timer_settime, and set TIMER_TIME_LIB. diff --git a/m4/timespec.m4 b/m4/timespec.m4 index 5333920ef5e..39255320c7f 100644 --- a/m4/timespec.m4 +++ b/m4/timespec.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4 index 3d97edb7a7f..341127746a4 100644 --- a/m4/tm_gmtoff.m4 +++ b/m4/tm_gmtoff.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Check for tm_gmtoff and tm_zone in struct tm, and #define dnl HAVE_STRUCT_TM_TM_GMTOFF and HAVE_STRUCT_TM_TM_ZONE accordingly. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 04fa79c9ca6..6fcbc242e47 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl Written by Simon Josefsson, Bruno Haible. diff --git a/m4/unlocked-io.m4 b/m4/unlocked-io.m4 index e96cf5f8736..1e515a0f4d7 100644 --- a/m4/unlocked-io.m4 +++ b/m4/unlocked-io.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 1998-2006, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Jim Meyering. dnl diff --git a/m4/utimens.m4 b/m4/utimens.m4 index b8200deaa25..5730b55feb5 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. AC_DEFUN([gl_UTIMENS], [ diff --git a/m4/utimensat.m4 b/m4/utimensat.m4 index a583f376687..8ed658d223b 100644 --- a/m4/utimensat.m4 +++ b/m4/utimensat.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to provide utimensat replacement. diff --git a/m4/utimes.m4 b/m4/utimes.m4 index 05b23cbb736..807b4600f09 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -5,6 +5,7 @@ dnl Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # See if we need to work around bugs in glibc's implementation of # utimes from 2003-07-12 to 2003-09-17. diff --git a/m4/vararrays.m4 b/m4/vararrays.m4 index 9211f69d4d8..6681ce9d699 100644 --- a/m4/vararrays.m4 +++ b/m4/vararrays.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2001, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for variable-length arrays. diff --git a/m4/warnings.m4 b/m4/warnings.m4 index fe7af01fc50..7350a400f1e 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl From Simon Josefsson diff --git a/m4/xattr.m4 b/m4/xattr.m4 index d8c08486834..9b2dd8d2453 100644 --- a/m4/xattr.m4 +++ b/m4/xattr.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. # Check for Extended Attributes (Linux) diff --git a/m4/zzgnulib.m4 b/m4/zzgnulib.m4 index 710fba4e297..c23127a97fb 100644 --- a/m4/zzgnulib.m4 +++ b/m4/zzgnulib.m4 @@ -4,6 +4,7 @@ dnl Copyright (C) 2020-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. +dnl This file is offered as-is, without any warranty. dnl This file must be named something that sorts after all other dnl package- or gnulib-provided .m4 files - at least for those packages commit 22806c65f4f8d68547d33997d017039763b4bf6a Author: Stefan Monnier Date: Tue Dec 17 17:07:45 2024 -0500 * lisp/mail/sendmail.el (mail-citation-prefix-regexp): Fix bug#24081 diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index a720df51d14..acb6a38436e 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -258,7 +258,9 @@ regardless of what part of it (if any) is included in the cited text.") ;;;###autoload (defcustom mail-citation-prefix-regexp - (purecopy "\\([ \t]*\\(\\w\\|[_.]\\)+>+\\|[ \t]*[>|]\\)+") + ;; Use [[:word:]] rather than \w so we don't get tripped up if one + ;; of those chars has a weird `syntax-table' text property. + (purecopy "\\([ \t]*\\([[:word:]]\\|[_.]\\)+>+\\|[ \t]*[>|]\\)+") "Regular expression to match a citation prefix plus whitespace. It should match whatever sort of citation prefixes you want to handle, with whitespace before and after; it should also match just whitespace. commit 78736420746e78445d4ff1889b56c85b66ca794e Author: Vincenzo Pupillo Date: Tue Dec 17 12:14:29 2024 +0100 Fix treesit-font-lock-level in python-ts-mode Now that 'treesit-font-lock-level' can be a number or a list, it should be handled using 'treesit--compute-font-lock-level'. * lisp/progmodes/python.el (python--treesit-fontify-string): Apply 'treesit--compute-font-lock-level' to 'treesit-font-lock-level'. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index dca0936c826..de1c6f551c4 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1108,7 +1108,8 @@ fontified." (ignore-interpolation (not (seq-some (lambda (feats) (memq 'string-interpolation feats)) - (seq-take treesit-font-lock-feature-list treesit-font-lock-level)))) + (seq-take treesit-font-lock-feature-list + (treesit--compute-font-lock-level treesit-font-lock-level))))) ;; If interpolation is enabled, highlight only ;; string_start/string_content/string_end children. Do not ;; touch interpolation node that can occur inside of the commit 69facd33a80bee3f49b0518e75e8ec570978334c Author: Juri Linkov Date: Tue Dec 17 20:58:09 2024 +0200 Rename the property 'repeat-continue-only' to 'repeat-continue' * doc/lispref/keymaps.texi (Creating Keymaps): * lisp/keymap.el (defvar-keymap): * lisp/repeat.el (repeat-get-map, describe-repeat-maps): * test/lisp/repeat-tests.el (repeat-tests-another-repeat-map) (repeat-tests-repeat-map): Replace 'repeat-continue-only' with 'repeat-continue' (bug#74140). diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index 87723720b1e..4b900e3a30d 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -481,7 +481,7 @@ This means all the commands in the keymap are repeatable, and is the most common usage. @item (:enter (commands ...) :exit (commands ...) -@itemx :continue-only (commands ...) :hints ((command . "hint") ...)) +@itemx :continue (commands ...) :hints ((command . "hint") ...)) This specifies that the commands in the @code{:enter} list enter @code{repeat-mode}, and the commands in the @code{:exit} list exit repeat mode. @@ -496,7 +496,7 @@ If the @code{:exit} list is empty then no commands in the map exit useful if the keymap being defined contains a command that should not have the @code{repeat-map} property. -The @code{:continue-only'} list specifies the commands that should not +The @code{:continue} list specifies the commands that should not enter @code{repeat-mode}. These command should only continue the already activated repeating sequence. diff --git a/etc/NEWS b/etc/NEWS index 4f046c59d65..d686bd78667 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1010,11 +1010,11 @@ widths can be determined. Columns widths can be set explicitly, or they will be calculated based on the window width. +++ -** New symbol property 'repeat-continue-only' for 'repeat-mode'. +** New symbol property 'repeat-continue' for 'repeat-mode'. A command with this symbol property whose value is a list of repeat maps will not activate the repeat map in 'repeat-mode'. It will only continue the already activated repeating sequence. Also 'defvar-keymap' -supports a new keyword ':continue-only' with a list of commands that +supports a new keyword ':continue' with a list of commands that only continue the active repeating sequence. ** New function 'completion-table-with-metadata'. diff --git a/lisp/keymap.el b/lisp/keymap.el index 43c8d918ba7..a6edead0ccf 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -687,7 +687,7 @@ value can also be a property list with properties `:enter', `:exit' and `:hints', for example: :repeat (:enter (commands ...) :exit (commands ...) - :continue-only (commands ...) + :continue (commands ...) :hints ((command . \"hint\") ...)) `:enter' specifies the list of additional commands that only @@ -703,7 +703,7 @@ Specifying a list of commands is useful when those commands exist in this specific map, but should not have the `repeat-map' symbol property. -`:continue-only' specifies the list of commands that should not +`:continue' specifies the list of commands that should not enter `repeat-mode'. These command should only continue the already activated repeating sequence. @@ -745,9 +745,9 @@ in the echo area. def) (dolist (def (plist-get repeat :enter)) (push `(put ',def 'repeat-map ',variable-name) props)) - (dolist (def (plist-get repeat :continue-only)) - (push `(put ',def 'repeat-continue-only - (cons ',variable-name (get ',def 'repeat-continue-only))) + (dolist (def (plist-get repeat :continue)) + (push `(put ',def 'repeat-continue + (cons ',variable-name (get ',def 'repeat-continue))) props)) (while defs (pop defs) diff --git a/lisp/repeat.el b/lisp/repeat.el index a114dc2c88b..901feae5cc8 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -457,11 +457,11 @@ See `describe-repeat-maps' for a list of all repeatable commands." "Return a transient map for keys repeatable after the current command." (when repeat-mode (let ((rep-map (or rep-map repeat-map (repeat--command-property 'repeat-map))) - (continue-only (repeat--command-property 'repeat-continue-only))) - (when continue-only + (continue (repeat--command-property 'repeat-continue))) + (when continue (if repeat-in-progress - (when (and (consp continue-only) - (memq repeat-in-progress continue-only)) + (when (and (consp continue) + (memq repeat-in-progress continue)) (setq rep-map repeat-in-progress)) (setq rep-map nil))) (when rep-map @@ -661,7 +661,7 @@ Click on a keymap to see the commands repeatable by the keymap.\n") (setq map-commands (seq-uniq map-commands)) (setq commands-continue (seq-filter (lambda (s) (memq (car keymap) - (get s 'repeat-continue-only))) + (get s 'repeat-continue))) map-commands)) (setq commands-enter (seq-difference repeat-commands map-commands)) diff --git a/test/lisp/repeat-tests.el b/test/lisp/repeat-tests.el index 4039a84c4d3..4f45378c520 100644 --- a/test/lisp/repeat-tests.el +++ b/test/lisp/repeat-tests.el @@ -77,9 +77,9 @@ (defvar-keymap repeat-tests-another-repeat-map :doc "Keymap for repeating other sequences." - :repeat ( :enter (repeat-tests-call-s) - :continue-only (repeat-tests-call-o - repeat-tests-call-u)) + :repeat ( :enter (repeat-tests-call-s) + :continue (repeat-tests-call-o + repeat-tests-call-u)) "s" 'ignore ;; for non-nil repeat-check-key only "t" 'repeat-tests-call-t "C-M-o" 'repeat-tests-call-o @@ -87,9 +87,9 @@ (defvar-keymap repeat-tests-repeat-map :doc "Keymap for repeating sequences." - :repeat ( :enter (repeat-tests-call-a) - :continue-only (repeat-tests-call-o) - :exit (repeat-tests-call-q)) + :repeat ( :enter (repeat-tests-call-a) + :continue (repeat-tests-call-o) + :exit (repeat-tests-call-q)) "a" 'ignore ;; for non-nil repeat-check-key only "c" 'repeat-tests-call-c "d" 'repeat-tests-call-d @@ -202,11 +202,11 @@ ;; TODO: :tags '(:expensive-test) for repeat-exit-timeout -(ert-deftest repeat-tests-continue-only () +(ert-deftest repeat-tests-continue () (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore) (repeat-check-key nil)) - ;; 'C-M-o' used as continue-only + ;; 'C-M-o' used as continue (repeat-tests--check "C-M-a c C-M-o c z" '((1 a) (1 c) (1 o) (1 c)) "z") @@ -223,7 +223,7 @@ (repeat-tests--check "C-M-s t t z" '((1 s) (1 t) (1 t)) "z") - ;; 'C-M-u' used as continue-only + ;; 'C-M-u' used as continue (repeat-tests--check "C-M-s t C-M-u t z" '((1 s) (1 t) (1 u) (1 t)) "z") @@ -268,7 +268,7 @@ :repeat-map repeat-tests-bind-keys-repeat-map :continue ("c" . repeat-tests-bind-call-c) - ;; :continue-only + ;; :continue ("C-M-o" . repeat-tests-bind-call-o) :exit ("q" . repeat-tests-bind-call-q)) @@ -279,7 +279,7 @@ (with-repeat-mode repeat-tests-bind-keys-map (let ((repeat-echo-function 'ignore) (repeat-check-key nil)) - ;; 'C-M-o' used as continue-only + ;; 'C-M-o' used as continue (repeat-tests--check "C-M-a c C-M-o c z" '((1 a) (1 c) (1 o) (1 c)) "z") commit f025c9df48f8ad5f1cb13c9adac2fc1fbeb81b79 Author: Juri Linkov Date: Tue Dec 17 20:51:03 2024 +0200 Display commands with repeat-continue-only in describe-repeat-maps * lisp/repeat.el (describe-repeat-maps): Display commands with the property 'repeat-continue-only' used to continue the currently active repeat-map (bug#74140). Also use 'cl--map-keymap-recursively' instead of 'map-keymap' to find more deep keybindings. diff --git a/lisp/repeat.el b/lisp/repeat.el index 2328c05a652..a114dc2c88b 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -653,15 +653,23 @@ Click on a keymap to see the commands repeatable by the keymap.\n") (symbol-value (car keymap)) (car keymap))) (repeat-commands (cdr keymap)) - map-commands commands-enter commands-exit) - (map-keymap (lambda (_key cmd) - (when (symbolp cmd) (push cmd map-commands))) - map) + map-commands commands-enter commands-exit commands-continue) + (cl--map-keymap-recursively + (lambda (_key cmd) + (when (symbolp cmd) (push cmd map-commands))) + map) (setq map-commands (seq-uniq map-commands)) - (setq commands-enter (seq-difference repeat-commands map-commands)) - (setq commands-exit (seq-difference map-commands repeat-commands)) - - (when (or commands-enter commands-exit) + (setq commands-continue + (seq-filter (lambda (s) (memq (car keymap) + (get s 'repeat-continue-only))) + map-commands)) + (setq commands-enter + (seq-difference repeat-commands map-commands)) + (setq commands-exit + (seq-difference (seq-difference map-commands repeat-commands) + commands-continue)) + + (when (or commands-enter commands-exit commands-continue) (when commands-enter (insert "\n** Entered with:\n\n") (fill-region-as-paragraph @@ -673,6 +681,17 @@ Click on a keymap to see the commands repeatable by the keymap.\n") ", ")) (point))) (insert "\n")) + (when commands-continue + (insert "\n** Continued only with:\n\n") + (fill-region-as-paragraph + (point) + (progn + (insert (mapconcat (lambda (cmd) + (format-message "`%s'" cmd)) + (sort commands-continue #'string<) + ", ")) + (point))) + (insert "\n")) (when commands-exit (insert "\n** Exited with:\n\n") (fill-region-as-paragraph @@ -688,7 +707,7 @@ Click on a keymap to see the commands repeatable by the keymap.\n") ;; Hide ^Ls. (goto-char (point-min)) (while (search-forward "\n\f\n" nil t) - (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) + (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) 'invisible t))))))) (provide 'repeat) commit 9232c985ef3d874755b0cbf4399fcc7077c308b5 Author: Juri Linkov Date: Tue Dec 17 20:45:42 2024 +0200 Improve support of property repeat-continue-only in repeat-mode (bug#74140) * lisp/repeat.el (repeat-get-map): Add optional arg 'rep-map'. Move the check for 'repeat-continue-only' from 'repeat-pre-hook'. Improve its logic to check if the current map 'repeat-in-progress' exists in the list from the 'repeat-continue-only' property. (repeat-post-hook): Set 'repeat-in-progress' to the symbol from the property 'repeat-map'. * test/lisp/repeat-tests.el (repeat-tests-another-repeat-map): Add new keymap to test multiple parallel repeat-maps. (repeat-tests-continue-another): New test that uses commands from 'repeat-tests-another-repeat-map' shared with 'repeat-tests-repeat-map'. diff --git a/lisp/repeat.el b/lisp/repeat.el index 45888d9db08..2328c05a652 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -453,10 +453,17 @@ See `describe-repeat-maps' for a list of all repeatable commands." (and (symbolp real-this-command) (get real-this-command property)))) -(defun repeat-get-map () +(defun repeat-get-map (&optional rep-map) "Return a transient map for keys repeatable after the current command." (when repeat-mode - (let ((rep-map (or repeat-map (repeat--command-property 'repeat-map)))) + (let ((rep-map (or rep-map repeat-map (repeat--command-property 'repeat-map))) + (continue-only (repeat--command-property 'repeat-continue-only))) + (when continue-only + (if repeat-in-progress + (when (and (consp continue-only) + (memq repeat-in-progress continue-only)) + (setq rep-map repeat-in-progress)) + (setq rep-map nil))) (when rep-map (when (and (symbolp rep-map) (boundp rep-map)) (setq rep-map (symbol-value rep-map))) @@ -501,37 +508,32 @@ See `describe-repeat-maps' for a list of all repeatable commands." (defun repeat-post-hook () "Function run after commands to set transient keymap for repeatable keys." - (let ((was-in-progress repeat-in-progress)) + (let* ((was-in-progress repeat-in-progress) + (map-sym (or repeat-map (repeat--command-property 'repeat-map))) + (map (repeat-get-map map-sym))) (setq repeat-in-progress nil) - (let ((map (repeat-get-map))) - (when (and (repeat-check-map map) - (let ((continue-only (repeat--command-property 'repeat-continue-only))) - (or (null continue-only) - (and (or (not (consp continue-only)) - (memq (repeat--command-property 'repeat-map) - continue-only)) - was-in-progress)))) - ;; Messaging - (funcall repeat-echo-function map) - - ;; Adding an exit key - (when repeat-exit-key - (setq map (copy-keymap map)) - (define-key map (if (key-valid-p repeat-exit-key) - (kbd repeat-exit-key) - repeat-exit-key) - 'ignore)) - - (setq repeat-in-progress t) - (repeat--clear-prev) - (let ((exitfun (set-transient-map map))) - (setq repeat--transient-exitfun exitfun) - - (let* ((prop (repeat--command-property 'repeat-exit-timeout)) - (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout)))) - (when timeout - (setq repeat-exit-timer - (run-with-idle-timer timeout nil #'repeat-exit))))))) + (when (repeat-check-map map) + ;; Messaging + (funcall repeat-echo-function map) + + ;; Adding an exit key + (when repeat-exit-key + (setq map (copy-keymap map)) + (define-key map (if (key-valid-p repeat-exit-key) + (kbd repeat-exit-key) + repeat-exit-key) + 'ignore)) + + (setq repeat-in-progress map-sym) + (repeat--clear-prev) + (let ((exitfun (set-transient-map map))) + (setq repeat--transient-exitfun exitfun) + + (let* ((prop (repeat--command-property 'repeat-exit-timeout)) + (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout)))) + (when timeout + (setq repeat-exit-timer + (run-with-idle-timer timeout nil #'repeat-exit)))))) (setq repeat-map nil) (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command)) diff --git a/test/lisp/repeat-tests.el b/test/lisp/repeat-tests.el index d69d431146a..4039a84c4d3 100644 --- a/test/lisp/repeat-tests.el +++ b/test/lisp/repeat-tests.el @@ -24,8 +24,8 @@ (require 'ert) (require 'repeat) -;; Key mnemonics: a - Activate (enter, also b), c - Continue (also d), -;; o - continue-Only (not activate), q - Quit (exit) +;; Key mnemonics: a - Activate (enter, also b, s), c - Continue (also d, t), +;; o - continue-Only (not activate, also u), q - Quit (exit) (defvar repeat-tests-calls nil) @@ -53,13 +53,37 @@ (interactive "p") (push `(,arg q) repeat-tests-calls)) +(defun repeat-tests-call-s (&optional arg) + (interactive "p") + (push `(,arg s) repeat-tests-calls)) + +(defun repeat-tests-call-t (&optional arg) + (interactive "p") + (push `(,arg t) repeat-tests-calls)) + +(defun repeat-tests-call-u (&optional arg) + (interactive "p") + (push `(,arg u) repeat-tests-calls)) + ;; Global keybindings -(defvar-keymap repeat-tests-map +(defvar-keymap repeat-tests-global-map :doc "Keymap for keys that initiate repeating sequences." "C-x w a" 'repeat-tests-call-a "C-M-a" 'repeat-tests-call-a "C-M-b" 'repeat-tests-call-b - "C-M-o" 'repeat-tests-call-o) + "C-M-o" 'repeat-tests-call-o + "C-M-s" 'repeat-tests-call-s + "C-M-u" 'repeat-tests-call-u) + +(defvar-keymap repeat-tests-another-repeat-map + :doc "Keymap for repeating other sequences." + :repeat ( :enter (repeat-tests-call-s) + :continue-only (repeat-tests-call-o + repeat-tests-call-u)) + "s" 'ignore ;; for non-nil repeat-check-key only + "t" 'repeat-tests-call-t + "C-M-o" 'repeat-tests-call-o + "C-M-u" 'repeat-tests-call-u) (defvar-keymap repeat-tests-repeat-map :doc "Keymap for repeating sequences." @@ -99,7 +123,7 @@ (should (equal (buffer-string) inserted))) (ert-deftest repeat-tests-check-key () - (with-repeat-mode repeat-tests-map + (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore)) (let ((repeat-check-key t)) (repeat-tests--check @@ -131,7 +155,7 @@ (put 'repeat-tests-call-b 'repeat-check-key nil)))))) (ert-deftest repeat-tests-exit-command () - (with-repeat-mode repeat-tests-map + (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore)) ;; 'c' doesn't continue since 'q' exited (repeat-tests--check @@ -139,7 +163,7 @@ '((1 a) (1 c) (1 d) (1 q)) "c")))) (ert-deftest repeat-tests-exit-key () - (with-repeat-mode repeat-tests-map + (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore)) (let ((repeat-exit-key nil)) (repeat-tests--check @@ -151,7 +175,7 @@ '((1 a) (1 c) (1 d) (1 c)) "z"))))) (ert-deftest repeat-tests-keep-prefix () - (with-repeat-mode repeat-tests-map + (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore)) (repeat-tests--check "C-x w a c d c z" @@ -179,7 +203,7 @@ ;; TODO: :tags '(:expensive-test) for repeat-exit-timeout (ert-deftest repeat-tests-continue-only () - (with-repeat-mode repeat-tests-map + (with-repeat-mode repeat-tests-global-map (let ((repeat-echo-function 'ignore) (repeat-check-key nil)) ;; 'C-M-o' used as continue-only @@ -191,6 +215,27 @@ "C-M-o c z" '((1 o)) "cz")))) +(ert-deftest repeat-tests-continue-another () + (with-repeat-mode repeat-tests-global-map + (let ((repeat-echo-function 'ignore) + (repeat-check-key nil)) + ;; First test without 'C-M-O' + (repeat-tests--check + "C-M-s t t z" + '((1 s) (1 t) (1 t)) "z") + ;; 'C-M-u' used as continue-only + (repeat-tests--check + "C-M-s t C-M-u t z" + '((1 s) (1 t) (1 u) (1 t)) "z") + ;; 'C-M-u' should not activate + (repeat-tests--check + "C-M-u t z" + '((1 u)) "tz") + ;; 'C-M-o' shared with another map should continue current map + (repeat-tests--check + "C-M-s t C-M-o t C-M-o t z" + '((1 s) (1 t) (1 o) (1 t) (1 o) (1 t)) "z")))) + (require 'use-package) commit 39a438d693daeb2e770f8a30c7a02e4039bf0036 Author: Eli Zaretskii Date: Tue Dec 17 13:59:08 2024 +0200 ; * lisp/frame.el (clone-frame): Doc fix (bug#74750). diff --git a/lisp/frame.el b/lisp/frame.el index 02f3f9f9dae..62bcd3c56b0 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -862,10 +862,11 @@ When called from Lisp, returns the new frame." (defun clone-frame (&optional frame no-windows) "Make a new frame with the same parameters and windows as FRAME. -With a prefix arg NO-WINDOWS, don't clone the window configuration. -When the user option `frame-resize-pixelwise' is non-nil, and FRAME is -not text-only, clone the originating frame's pixel size. Otherwise, use -the number of FRAME's columns and lines for the clone. +If NO-WINDOWS is non-nil (interactively, the prefix argument), don't +clone the configuration of FRAME's windows. +If FRAME is a graphical frame and `frame-resize-pixelwise' is non-nil, +clone FRAME's pixel size. Otherwise, use the number of FRAME's columns +and lines for the clone. FRAME defaults to the selected frame. The frame is created on the same terminal as FRAME. If the terminal is a text-only terminal then commit b8a7e2ef71b25a851437d41e16621a07da824758 Author: Pip Cet Date: Tue Dec 17 09:11:49 2024 +0000 ; * etc/NEWS: Fix typo. diff --git a/etc/NEWS b/etc/NEWS index d20c733c0c3..4f046c59d65 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1021,7 +1021,7 @@ only continue the active repeating sequence. It offers a more concise way to create a completion table with metadata. +++ -** 'all-completions' and 'obarray' no longer support their old calling conventions. +** 'all-completions' and 'unintern' no longer support their old calling conventions. * Changes in Emacs 31.1 on Non-Free Operating Systems