| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! /bin/sh | | 1 | #! /bin/sh |
2 | # $NetBSD: msg_xlat.sh,v 1.4 2021/07/11 10:51:46 cjep Exp $ | | 2 | # $NetBSD: msg_xlat.sh,v 1.5 2021/07/12 19:03:20 kre Exp $ |
3 | | | 3 | |
4 | #- | | 4 | #- |
5 | # Copyright (c) 2003 The NetBSD Foundation, Inc. | | 5 | # Copyright (c) 2003 The NetBSD Foundation, Inc. |
6 | # All rights reserved. | | 6 | # All rights reserved. |
7 | # | | 7 | # |
8 | # This code is derived from software contributed to The NetBSD Foundation | | 8 | # This code is derived from software contributed to The NetBSD Foundation |
9 | # by David Laight. | | 9 | # by David Laight. |
10 | # | | 10 | # |
11 | # Redistribution and use in source and binary forms, with or without | | 11 | # Redistribution and use in source and binary forms, with or without |
12 | # modification, are permitted provided that the following conditions | | 12 | # modification, are permitted provided that the following conditions |
13 | # are met: | | 13 | # are met: |
14 | # 1. Redistributions of source code must retain the above copyright | | 14 | # 1. Redistributions of source code must retain the above copyright |
15 | # notice, this list of conditions and the following disclaimer. | | 15 | # notice, this list of conditions and the following disclaimer. |
| @@ -164,27 +164,27 @@ do | | | @@ -164,27 +164,27 @@ do |
164 | # For our purposes, empty messages are the same as words without % | | 164 | # For our purposes, empty messages are the same as words without % |
165 | if [ $# -eq 0 ]; then set -- x; fi | | 165 | if [ $# -eq 0 ]; then set -- x; fi |
166 | | | 166 | |
167 | if $count_fmtargs; then | | 167 | if $count_fmtargs; then |
168 | echo $number $# | | 168 | echo $number $# |
169 | continue | | 169 | continue |
170 | fi | | 170 | fi |
171 | eval count=\${count_$number:-unknown} | | 171 | eval count=\${count_$number:-unknown} |
172 | if [ "$count" -ne $# ]; then | | 172 | if [ "$count" -ne $# ]; then |
173 | error "Wrong number of format specifiers in \"$sv_name\", got $#, expected $count" | | 173 | error "Wrong number of format specifiers in \"$sv_name\", got $#, expected $count" |
174 | $IGNORE_MISSING_TRANSLATIONS || rval=1 | | 174 | $IGNORE_MISSING_TRANSLATIONS || rval=1 |
175 | fi | | 175 | fi |
176 | done | | 176 | done |
177 | IFS=% | | 177 | unset IFS |
178 | | | 178 | |
179 | if $count_fmtargs; then exit $rval; fi | | 179 | if $count_fmtargs; then exit $rval; fi |
180 | | | 180 | |
181 | # Output the total number of messages and the offset of each in the file. | | 181 | # Output the total number of messages and the offset of each in the file. |
182 | # Use ascii numbers because generating target-ordered binary numbers | | 182 | # Use ascii numbers because generating target-ordered binary numbers |
183 | # is just a smidgen tricky in the shell. | | 183 | # is just a smidgen tricky in the shell. |
184 | | | 184 | |
185 | offset=$(( 8 + $last_msg_number * 8 + 8 )) | | 185 | offset=$(( 8 + $last_msg_number * 8 + 8 )) |
186 | printf 'MSGTXTS\0%-7d\0' $last_msg_number | | 186 | printf 'MSGTXTS\0%-7d\0' $last_msg_number |
187 | | | 187 | |
188 | msgnum=0 | | 188 | msgnum=0 |
189 | while | | 189 | while |
190 | msgnum=$(( $msgnum + 1 )) | | 190 | msgnum=$(( $msgnum + 1 )) |
| @@ -200,17 +200,17 @@ do | | | @@ -200,17 +200,17 @@ do |
200 | printf '%-7d\0' $offset | | 200 | printf '%-7d\0' $offset |
201 | offset=$(( $offset + ${#msg} + 1 )) | | 201 | offset=$(( $offset + ${#msg} + 1 )) |
202 | done | | 202 | done |
203 | | | 203 | |
204 | # Finally output and null terminate the messages. | | 204 | # Finally output and null terminate the messages. |
205 | | | 205 | |
206 | msgnum=0 | | 206 | msgnum=0 |
207 | while | | 207 | while |
208 | msgnum=$(( $msgnum + 1 )) | | 208 | msgnum=$(( $msgnum + 1 )) |
209 | [ "$msgnum" -le "$last_msg_number" ] | | 209 | [ "$msgnum" -le "$last_msg_number" ] |
210 | do | | 210 | do |
211 | eval msg=\${MSGTEXT_$msgnum} | | 211 | eval msg=\${MSGTEXT_$msgnum} |
212 | if [ -z "$msg" ]; then continue; fi | | 212 | if [ -z "$msg" ]; then continue; fi |
213 | printf '%s\0' $msg | | 213 | printf '%s\0' "$msg" |
214 | done | | 214 | done |
215 | | | 215 | |
216 | exit $rval | | 216 | exit $rval |