@@ -1019,10 +1019,23 @@ static int form_file_list(char **files, int file_cnt)
1019
1019
sp = files [i ];
1020
1020
}
1021
1021
}
1022
+
1023
+ /* BSD-style '-o' offensive file suffix */
1024
+ bool offensive = false;
1025
+ const size_t sp_len = strlen (sp );
1026
+ if (sp_len >= 3 && sp [sp_len - 2 ] == '-' && sp [sp_len - 1 ] == 'o' )
1027
+ {
1028
+ sp [sp_len - 2 ] = '\0' ;
1029
+ offensive = true;
1030
+ }
1031
+
1032
+ const char * fulldir = offensive ? OFFDIR : FORTDIR ;
1033
+ const char * locdir = offensive ? LOCOFFDIR : LOCFORTDIR ;
1034
+
1022
1035
if (strcmp (sp , "all" ) == 0 )
1023
1036
{
1024
- snprintf (fullpathname , sizeof (fullpathname ), "%s" , FORTDIR );
1025
- snprintf (locpathname , sizeof (locpathname ), "%s" , LOCFORTDIR );
1037
+ snprintf (fullpathname , sizeof (fullpathname ), "%s" , fulldir );
1038
+ snprintf (locpathname , sizeof (locpathname ), "%s" , locdir );
1026
1039
}
1027
1040
/* if it isn't an absolute path or relative to . or ..
1028
1041
make it an absolute path relative to FORTDIR */
@@ -1032,9 +1045,9 @@ static int form_file_list(char **files, int file_cnt)
1032
1045
strncmp (sp , "../" , 3 ) != 0 )
1033
1046
{
1034
1047
snprintf (
1035
- fullpathname , sizeof (fullpathname ), "%s/%s" , FORTDIR , sp );
1048
+ fullpathname , sizeof (fullpathname ), "%s/%s" , fulldir , sp );
1036
1049
snprintf (
1037
- locpathname , sizeof (locpathname ), "%s/%s" , LOCFORTDIR , sp );
1050
+ locpathname , sizeof (locpathname ), "%s/%s" , locdir , sp );
1038
1051
}
1039
1052
else
1040
1053
{
@@ -1063,7 +1076,7 @@ static int form_file_list(char **files, int file_cnt)
1063
1076
1064
1077
/* first try full locale */
1065
1078
snprintf (
1066
- langdir , sizeof (langdir ), "%s/%s/%s" , FORTDIR , lang , sp );
1079
+ langdir , sizeof (langdir ), "%s/%s/%s" , fulldir , lang , sp );
1067
1080
ret = add_file (
1068
1081
percent , langdir , NULL , & File_list , & File_tail , NULL );
1069
1082
@@ -1075,7 +1088,7 @@ static int form_file_list(char **files, int file_cnt)
1075
1088
strncpy (ll , lang , 2 );
1076
1089
ll [2 ] = '\0' ;
1077
1090
snprintf (
1078
- langdir , sizeof (langdir ), "%s/%s/%s" , FORTDIR , ll , sp );
1091
+ langdir , sizeof (langdir ), "%s/%s/%s" , fulldir , ll , sp );
1079
1092
ret = add_file (
1080
1093
percent , langdir , NULL , & File_list , & File_tail , NULL );
1081
1094
}
@@ -1094,8 +1107,19 @@ static int form_file_list(char **files, int file_cnt)
1094
1107
ret = add_file (
1095
1108
percent , locpathname , NULL , & File_list , & File_tail , NULL );
1096
1109
}
1110
+ if (strncmp (fullpathname , locpathname , sizeof (fullpathname )) &&
1111
+ strcmp (sp , "all" ) == 0 )
1112
+ {
1113
+ add_file (
1114
+ percent , locpathname , NULL , & File_list , & File_tail , NULL );
1115
+ }
1097
1116
if (!ret )
1098
1117
{
1118
+ if (offensive )
1119
+ {
1120
+ // restore -o suffix
1121
+ sp [sp_len - 2 ] = '-' ;
1122
+ }
1099
1123
snprintf (locpathname , sizeof (locpathname ), "%s/%s" ,
1100
1124
getenv ("PWD" ), sp );
1101
1125
@@ -1106,12 +1130,6 @@ static int form_file_list(char **files, int file_cnt)
1106
1130
{
1107
1131
return false;
1108
1132
}
1109
- if (strncmp (fullpathname , locpathname , sizeof (fullpathname )) &&
1110
- strcmp (sp , "all" ) == 0 )
1111
- {
1112
- add_file (
1113
- percent , locpathname , NULL , & File_list , & File_tail , NULL );
1114
- }
1115
1133
}
1116
1134
else if (!add_file (
1117
1135
percent , fullpathname , NULL , & File_list , & File_tail , NULL ))
0 commit comments