git: 4c45ab6ac8c8 - stable/13 - sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 15 Dec 2023 00:41:41 UTC
The branch stable/13 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c45ab6ac8c875fc227a40e4c5304d604b6c2a96

commit 4c45ab6ac8c875fc227a40e4c5304d604b6c2a96
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-12-07 20:27:07 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2023-12-15 00:41:05 +0000

    sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined
    
    On MacOS, we bootstrap sort. Since ALTMON_* are not defined there, the
    build blows up. Since we don't need this feature for the FreeBSD build
    process, and since we won't use it unless we actually install the NL
    files that have this data in it, just #ifdef it out for now. In the
    extremely unlikely event that the FreeBSD bootstrap/build process grows
    this dependency, we can evaluate the best solution then (which most
    likely is going to be not depend on the local's month names).
    
    Fixes:                  3d44dce90a69 (MacOS builds and github CI)
    Sponsored by:           Netflix
    Reviewed by:            jrtc27, jlduran@gmail.com, markj
    Differential Revision:  https://reviews.freebsd.org/D42868
    
    (cherry picked from commit bd234c0d4c8256db7e5a1fdda9ef311c9e0080e4)
---
 usr.bin/sort/bwstring.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c
index b0c14e996b23..10679fe631ba 100644
--- a/usr.bin/sort/bwstring.c
+++ b/usr.bin/sort/bwstring.c
@@ -113,9 +113,11 @@ initialise_months(void)
 	const nl_item ab_item[12] = { ABMON_1, ABMON_2, ABMON_3, ABMON_4,
 	    ABMON_5, ABMON_6, ABMON_7, ABMON_8, ABMON_9, ABMON_10,
 	    ABMON_11, ABMON_12 };
+#ifdef ALTMON_1
 	const nl_item alt_item[12] = { ALTMON_1, ALTMON_2, ALTMON_3, ALTMON_4,
 	    ALTMON_5, ALTMON_6, ALTMON_7, ALTMON_8, ALTMON_9, ALTMON_10,
 	    ALTMON_11, ALTMON_12 };
+#endif
 	int i;
 
 	/*
@@ -132,9 +134,13 @@ initialise_months(void)
 				if (!populate_cmonth(&cmonths[i].ab,
 				    ab_item[i], i))
 					continue;
+#ifdef ALTMON_1
 				if (!populate_cmonth(&cmonths[i].alt,
 				    alt_item[i], i))
 					continue;
+#else
+				cmonths[i].alt = NULL;
+#endif
 			}
 		}
 
@@ -148,9 +154,13 @@ initialise_months(void)
 				if (!populate_wmonth(&wmonths[i].ab,
 				    ab_item[i], i))
 					continue;
+#ifdef ALTMON_1
 				if (!populate_wmonth(&wmonths[i].alt,
 				    alt_item[i], i))
 					continue;
+#else
+				wmonths[i].alt = NULL;
+#endif
 			}
 		}
 	}