git: bd234c0d4c82 - main - sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 07 Dec 2023 20:43:30 UTC
The branch main has been updated by imp:

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

commit bd234c0d4c8256db7e5a1fdda9ef311c9e0080e4
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-12-07 20:27:07 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-12-07 20:42:52 +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
---
 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
 			}
 		}
 	}