libgpg-error-1.36-gawk.patch 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. diff --git a/lang/cl/mkerrcodes.awk b/lang/cl/mkerrcodes.awk
  2. index ae29043..9a1fc18 100644
  3. --- a/lang/cl/mkerrcodes.awk
  4. +++ b/lang/cl/mkerrcodes.awk
  5. @@ -1,154 +1,154 @@
  6. # mkerrcodes.awk
  7. # Copyright (C) 2004, 2005, 2006 g10 Code GmbH
  8. #
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License as
  11. # published by the Free Software Foundation; either version 2 of
  12. # the License, or (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. #
  23. # As a special exception, g10 Code GmbH gives unlimited permission to
  24. # copy, distribute and modify the lisp source files that are the output
  25. # of mkerrcodes.awk. You need not follow the terms of the GNU General
  26. # Public License when using or distributing such scripts, even though
  27. # portions of the text of mkerrcodes.awk appear in them. The GNU
  28. # General Public License (GPL) does govern all other use of the material
  29. # that constitutes the mkerrcodes.awk program.
  30. #
  31. # Certain portions of the mkerrcodes.awk source text are designed to be
  32. # copied (in certain cases, depending on the input) into the output of
  33. # mkerrcodes.awk. We call these the "data" portions. The rest of the
  34. # mkerrcodes.awk source text consists of comments plus executable code
  35. # that decides which of the data portions to output in any given case.
  36. # We call these comments and executable code the "non-data" portions.
  37. # mkerrcodes.awk never copies any of the non-data portions into its output.
  38. #
  39. # This special exception to the GPL applies to versions of mkerrcodes.awk
  40. # released by g10 Code GmbH. When you make and distribute a modified version
  41. # of mkerrcodes.awk, you may extend this special exception to the GPL to
  42. # apply to your modified version as well, *unless* your modified version
  43. # has the potential to copy into its output some of the text that was the
  44. # non-data portion of the version that you started with. (In other words,
  45. # unless your change moves or copies text from the non-data portions to the
  46. # data portions.) If your modification has such potential, you must delete
  47. # any notice of this special exception to the GPL from your modified version.
  48. # The input file is in the following format:
  49. # [CODE SYMBOL...]
  50. # @errnos@
  51. # [CODE SYMBOL...]
  52. #
  53. # The difference between the sections is how symbol is transformed.
  54. # The second section gets GPG_ERR_ prepended before processing.
  55. #
  56. # Comments (starting with # and ending at the end of the line) are removed,
  57. # as is trailing whitespace.
  58. BEGIN {
  59. FS="[ \t]+";
  60. print ";;;; Output of mkerrcodes.awk. DO NOT EDIT.";
  61. print "";
  62. print ";;; Copyright (C) 2006 g10 Code GmbH";
  63. print ";;;";
  64. print ";;; This file is part of libgpg-error.";
  65. print ";;;";
  66. print ";;; libgpg-error is free software; you can redistribute it and/or";
  67. print ";;; modify it under the terms of the GNU Lesser General Public License";
  68. print ";;; as published by the Free Software Foundation; either version 2.1 of";
  69. print ";;; the License, or (at your option) any later version.";
  70. print ";;;";
  71. print ";;; libgpg-error is distributed in the hope that it will be useful, but";
  72. print ";;; WITHOUT ANY WARRANTY; without even the implied warranty of";
  73. print ";;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU";
  74. print ";;; Lesser General Public License for more details.";
  75. print ";;;";
  76. print ";;; You should have received a copy of the GNU Lesser General Public";
  77. print ";;; License along with libgpg-error; if not, write to the Free";
  78. print ";;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA";
  79. print ";;; 02111-1307, USA.";
  80. print "";
  81. header = 1;
  82. errnos = 0;
  83. }
  84. /^#/ { next; }
  85. header {
  86. if (errnos)
  87. {
  88. if ($1 ~ /^[0123456789]+$/)
  89. {
  90. header = 0;
  91. print "";
  92. print " ;; The following error codes map system errors.";
  93. }
  94. }
  95. else
  96. {
  97. if ($1 ~ /^[0123456789]+$/)
  98. {
  99. header = 0;
  100. print "(in-package :gpg-error)";
  101. print "";
  102. print ";;; The error code type gpg-err-code-t.";
  103. print "";
  104. print ";;; This is used for system error codes.";
  105. print "(defconstant +gpg-err-system-error+ (ash 1 15))";
  106. print "";
  107. print ";;; This is one more than the largest allowed entry.";
  108. print "(defconstant +gpg-err-code-dim+ 65536)";
  109. print "";
  110. print ";;; A helper macro to have the keyword values evaluated.";
  111. print "(defmacro defcenum-eval (type doc &rest vals)";
  112. print " `(defcenum ,type ,doc";
  113. print " ,@(loop for v in vals";
  114. print " collect `(,(first v) ,(eval (second v))))))";
  115. print "";
  116. print "(defcenum-eval gpg-err-code-t";
  117. print " \"The GPG error code type.\"";
  118. }
  119. }
  120. }
  121. !header {
  122. - sub (/\#.+/, "");
  123. + sub (/#.+/, "");
  124. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  125. if (/^$/)
  126. next;
  127. # The following can happen for GPG_ERR_CODE_DIM.
  128. if ($1 == "")
  129. next;
  130. if (/^@errnos@$/)
  131. {
  132. header = 1;
  133. errnos = 1;
  134. next;
  135. }
  136. $2 = tolower($2);
  137. gsub ("_", "-", $2);
  138. if (errnos)
  139. print " (:gpg-err-" $2 " (logior +gpg-err-system-error+ " $1 "))";
  140. else
  141. print " (:" $2 " " $1 ")";
  142. }
  143. END {
  144. # I am very sorry to break lisp coding style here.
  145. print ")";
  146. }
  147. diff --git a/src/Makefile.am b/src/Makefile.am
  148. index ce1b882..f2590cb 100644
  149. --- a/src/Makefile.am
  150. +++ b/src/Makefile.am
  151. @@ -1,356 +1,356 @@
  152. # Makefile.am for libgpg-error.
  153. # Copyright (C) 2003, 2004, 2014 g10 Code GmbH
  154. #
  155. # This file is part of libgpg-error.
  156. #
  157. # libgpg-error is free software; you can redistribute it and/or modify
  158. # it under the terms of the GNU Lesser General Public License as
  159. # published by the Free Software Foundation; either version 2.1 of the
  160. # License, or (at your option) any later version.
  161. #
  162. # libgpg-error is distributed in the hope that it will be useful,
  163. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  164. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  165. # GNU Lesser General Public License for more details.
  166. #
  167. # You should have received a copy of the GNU Lesser General Public
  168. # License along with this program; if not, see <https://www.gnu.org/licenses/>.
  169. # SPDX-License-Identifier: LGPL-2.1+
  170. #
  171. # We distribute the generated sources err-sources.h and err-codes.h,
  172. # because they are needed to build the po directory, and they don't
  173. # depend on the configuration anyway.
  174. #
  175. if HAVE_W32CE_SYSTEM
  176. gpg_extra_headers = gpg-extra/errno.h
  177. extra_cppflags = -idirafter gpg-extra
  178. else
  179. gpg_extra_headers =
  180. extra_cppflags =
  181. endif
  182. localedir = $(datadir)/locale
  183. bin_PROGRAMS = gpg-error
  184. if HAVE_W32_SYSTEM
  185. noinst_PROGRAMS = gen-w32-lock-obj
  186. else
  187. noinst_PROGRAMS = gen-posix-lock-obj
  188. endif
  189. # Distributed lock object definitions for cross compilation.
  190. lock_obj_pub = \
  191. syscfg/lock-obj-pub.aarch64-unknown-linux-gnu.h \
  192. syscfg/lock-obj-pub.aarch64-unknown-linux-gnu_ilp32.h \
  193. syscfg/lock-obj-pub.aarch64-apple-darwin.h \
  194. syscfg/lock-obj-pub.alpha-unknown-linux-gnu.h \
  195. syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h \
  196. syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h \
  197. syscfg/lock-obj-pub.arm-apple-darwin.h \
  198. syscfg/lock-obj-pub.hppa-unknown-linux-gnu.h \
  199. syscfg/lock-obj-pub.i386-apple-darwin.h \
  200. syscfg/lock-obj-pub.i686-unknown-gnu.h \
  201. syscfg/lock-obj-pub.i686-unknown-kfreebsd-gnu.h \
  202. syscfg/lock-obj-pub.i686-unknown-linux-gnu.h \
  203. syscfg/lock-obj-pub.m68k-unknown-linux-gnu.h \
  204. syscfg/lock-obj-pub.mips-unknown-linux-gnu.h \
  205. syscfg/lock-obj-pub.mips64el-unknown-linux-gnuabi64.h \
  206. syscfg/lock-obj-pub.mipsel-unknown-linux-gnu.h \
  207. syscfg/lock-obj-pub.nios2-unknown-linux-gnu.h \
  208. syscfg/lock-obj-pub.or1k-unknown-linux-gnu.h \
  209. syscfg/lock-obj-pub.powerpc-unknown-linux-gnu.h \
  210. syscfg/lock-obj-pub.powerpc64-unknown-linux-gnu.h \
  211. syscfg/lock-obj-pub.powerpc64le-unknown-linux-gnu.h \
  212. syscfg/lock-obj-pub.powerpc-unknown-linux-gnuspe.h \
  213. syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h \
  214. syscfg/lock-obj-pub.riscv32-unknown-linux-gnu.h \
  215. syscfg/lock-obj-pub.s390x-unknown-linux-gnu.h \
  216. syscfg/lock-obj-pub.sh3-unknown-linux-gnu.h \
  217. syscfg/lock-obj-pub.sh4-unknown-linux-gnu.h \
  218. syscfg/lock-obj-pub.sparc-unknown-linux-gnu.h \
  219. syscfg/lock-obj-pub.sparc64-unknown-linux-gnu.h \
  220. syscfg/lock-obj-pub.x86_64-apple-darwin.h \
  221. syscfg/lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h \
  222. syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h \
  223. syscfg/lock-obj-pub.x86_64-unknown-linux-gnux32.h \
  224. syscfg/lock-obj-pub.x86_64-unknown-linux-musl.h \
  225. syscfg/lock-obj-pub.tilegx-unknown-linux-gnu.h \
  226. syscfg/lock-obj-pub.ia64-unknown-linux-gnu.h \
  227. syscfg/lock-obj-pub.mingw32.h
  228. lib_LTLIBRARIES = libgpg-error.la
  229. nodist_include_HEADERS = gpg-error.h gpgrt.h
  230. dist_bin_SCRIPTS = gpgrt-config
  231. bin_SCRIPTS = gpg-error-config
  232. m4datadir = $(datadir)/aclocal
  233. m4data_DATA = gpg-error.m4 gpgrt.m4
  234. pkgconfigdir = $(libdir)/pkgconfig
  235. pkgconfig_DATA = gpg-error.pc
  236. EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
  237. mkerrnos.awk errnos.in README \
  238. mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
  239. mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
  240. err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 gpgrt.m4 \
  241. gpg-error.vers gpg-error.def.in \
  242. versioninfo.rc.in gpg-error.w32-manifest.in \
  243. gpg-error-config-test.sh gpg-error.pc.in \
  244. $(lock_obj_pub)
  245. BUILT_SOURCES = $(srcdir)/err-sources.h $(srcdir)/err-codes.h \
  246. code-to-errno.h code-from-errno.h \
  247. err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h gpgrt.h \
  248. gpg-error.def mkw32errmap.map.c
  249. tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
  250. CLEANFILES = code-to-errno.h code-from-errno.h \
  251. gpg-error.h gpgrt.h \
  252. mkerrcodes$(EXEEXT_FOR_BUILD) mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
  253. mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
  254. gpg-extra/errno.h mkheader$(EXEEXT_FOR_BUILD) \
  255. gpg-error-config gpg-error-config-test.log \
  256. $(tmp_files) lock-obj-pub.native.h
  257. MAINTAINERCLEANFILES = $(srcdir)/err-sources.h $(srcdir)/err-codes.h
  258. TESTS = gpg-error-config-test.sh
  259. #
  260. # {{{ Begin Windows part
  261. #
  262. if HAVE_W32_SYSTEM
  263. arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c \
  264. w32-iconv.c w32-estream.c w32-reg.c spawn-w32.c
  265. RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
  266. -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS)
  267. LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
  268. SUFFIXES = .rc .lo
  269. .rc.lo:
  270. $(LTRCCOMPILE) -i "$<" -o "$@"
  271. gpg_error_res = versioninfo.lo
  272. no_undefined = -no-undefined
  273. export_symbols = -export-symbols gpg-error.def
  274. # i686-w64-mingw32.gcc version 4.9.1 takes the long long helper
  275. # functions from libgcc_s_sjlj-1.dll and not from a static libgcc. As
  276. # a plain C program we do not use exception handler and thus there is
  277. # no need to use this DLL. Thus we force gcc to link that statically.
  278. extra_ltoptions = -XCClinker -static-libgcc
  279. versioninfo.lo : gpg-error.w32-manifest
  280. install-def-file: gpg-error.def
  281. -$(INSTALL) -d $(DESTDIR)$(libdir)
  282. $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
  283. uninstall-def-file:
  284. -rm $(DESTDIR)$(libdir)/gpg-error.def
  285. libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
  286. intllibs =
  287. socklibs = -lws2_32
  288. #
  289. # }}} End Windows part
  290. #
  291. else
  292. #
  293. # {{{ Begin Unix part
  294. #
  295. arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c spawn-posix.c
  296. gpg_error_res =
  297. no_undefined =
  298. export_symbols =
  299. extra_ltoptions =
  300. install-def-file:
  301. uninstall-def-file:
  302. intllibs = @LTLIBINTL@
  303. socklibs =
  304. endif
  305. #
  306. # }}} End Unix part
  307. #
  308. if HAVE_LD_VERSION_SCRIPT
  309. libgpg_error_vers_opt = -Wl,--version-script=$(srcdir)/gpg-error.vers
  310. else
  311. libgpg_error_vers_opt =
  312. endif
  313. libgpg_error_la_LDFLAGS = \
  314. $(no_undefined) $(export_symbols) $(libgpg_error_vers_opt) \
  315. $(extra_ltoptions) -version-info \
  316. @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@
  317. libgpg_error_la_SOURCES = gettext.h $(arch_sources) \
  318. gpgrt-int.h init.c init.h version.c lock.h thread.h \
  319. estream.c estream-printf.c estream-printf.h \
  320. strsource.c strerror.c code-to-errno.c code-from-errno.c \
  321. visibility.c visibility.h \
  322. sysutils.c \
  323. syscall-clamp.c \
  324. logging.c \
  325. b64dec.c b64enc.c \
  326. argparse.c
  327. nodist_libgpg_error_la_SOURCES = gpg-error.h
  328. # libgpg_error_la_DEPENDENCIES = \
  329. # $(srcdir)/gpg-error.vers
  330. # Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
  331. # without the extra_cppflags because they may include am -idirafter
  332. # which is not supported by the RC compiler.
  333. libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
  334. libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBTHREAD)
  335. gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
  336. gpg_error_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \
  337. -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
  338. gpg_error_LDADD = libgpg-error.la $(LTLIBINTL)
  339. # We build err-sources.h and err-codes.h in the source directory.
  340. # This is needed because gettext does only look into the source
  341. # directory to find the files listed in po/POTFILE.in. To make these
  342. # rules work we also need to depend on Makefile.am and not on the
  343. # generated files Makefile.in or Makefile.
  344. $(srcdir)/err-sources.h: Makefile.am mkstrtable.awk err-sources.h.in
  345. $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
  346. $(srcdir)/err-sources.h.in >$@
  347. err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
  348. $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
  349. $(srcdir)/err-sources.h.in >$@
  350. $(srcdir)/err-codes.h: Makefile.am mkstrtable.awk err-codes.h.in
  351. $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
  352. $(srcdir)/err-codes.h.in >$@
  353. err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
  354. $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
  355. $(srcdir)/err-codes.h.in >$@
  356. code-to-errno.h: Makefile mkerrnos.awk errnos.in
  357. $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
  358. # It is correct to use $(CPP). We want the host's idea of the error codes.
  359. mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers)
  360. $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
  361. $(CPP) $(CPPFLAGS) $(extra_cppflags) -P _$@ | grep GPG_ERR_ | \
  362. $(AWK) -f $(srcdir)/mkerrcodes.awk >$@
  363. -rm _$@
  364. if HAVE_W32CE_SYSTEM
  365. # It is correct to use $(CPP). We want the host's idea of the error codes.
  366. mkw32errmap.tab.h: Makefile mkw32errmap.c
  367. $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \
  368. grep '{&mkw32errmap_marker' >$@
  369. mkw32errmap.map.c: mkw32errmap$(EXEEXT_FOR_BUILD)
  370. ./mkw32errmap$(EXEEXT_FOR_BUILD) --map > $@
  371. gpg-extra/errno.h: mkw32errmap$(EXEEXT_FOR_BUILD)
  372. -$(MKDIR_P) gpg-extra
  373. ./mkw32errmap$(EXEEXT_FOR_BUILD) > $@
  374. else
  375. mkw32errmap.map.c:
  376. echo "/*dummy*/" > $@
  377. endif
  378. # We use CC proper for preprocessing thus we have to convince it that
  379. # the data is really to be preprocessed.
  380. gpg-error.def: Makefile gpg-error.def.in
  381. cat $(srcdir)/gpg-error.def.in >_$@.h
  382. $(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \
  383. grep -v '^#' >$@
  384. -rm _$@.h
  385. # It is correct to use $(CC_FOR_BUILD) here. We want to run the
  386. # program at build time.
  387. mkerrcodes$(EXEEXT_FOR_BUILD): mkerrcodes.c mkerrcodes.h Makefile
  388. $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
  389. if HAVE_W32CE_SYSTEM
  390. # It is correct to use $(CC_FOR_BUILD) here. We want to run the
  391. # program at build time.
  392. mkw32errmap$(EXEEXT_FOR_BUILD): mkw32errmap.c mkw32errmap.tab.h Makefile
  393. $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c
  394. endif
  395. code-from-errno.h: mkerrcodes$(EXEEXT_FOR_BUILD) Makefile
  396. ./mkerrcodes$(EXEEXT_FOR_BUILD) | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
  397. errnos-sym.h: Makefile mkstrtable.awk errnos.in
  398. $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
  399. - -v prefix=GPG_ERR_ -v namespace=errnos_ \
  400. + -v prefix=GPG_ERR_ -v pkg_namespace=errnos_ \
  401. $(srcdir)/errnos.in >$@
  402. mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile
  403. $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
  404. parts_of_gpg_error_h = \
  405. gpg-error.h.in \
  406. err-sources.h.in \
  407. err-codes.h.in \
  408. errnos.in \
  409. w32-add.h \
  410. w32ce-add.h \
  411. $(lock_obj_pub)
  412. # If we are cross-compiling or building on Windows we better make sure
  413. # that no stale native lock include file will be found by mkheader.
  414. if FORCE_USE_SYSCFG
  415. pre_mkheader_cmds = if test -f lock-obj-pub.native.h; \
  416. then rm lock-obj-pub.native.h; fi
  417. mkheader_opts = --cross
  418. else
  419. pre_mkheader_cmds = :
  420. mkheader_opts =
  421. parts_of_gpg_error_h += ./lock-obj-pub.native.h
  422. ./lock-obj-pub.native.h: Makefile gen-posix-lock-obj$(EXEEXT) posix-lock-obj.h
  423. ./gen-posix-lock-obj >$@
  424. endif
  425. # We also depend on versioninfo.rc because that is build by
  426. # config.status and thus has up-to-date version numbers.
  427. gpg-error.h: Makefile mkheader$(EXEEXT_FOR_BUILD) $(parts_of_gpg_error_h) \
  428. versioninfo.rc ../config.h
  429. $(pre_mkheader_cmds)
  430. ./mkheader$(EXEEXT_FOR_BUILD) $(mkheader_opts) \
  431. $(host_triplet) $(srcdir)/gpg-error.h.in \
  432. ../config.h $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
  433. gpgrt.h: gpg-error.h
  434. cp gpg-error.h gpgrt.h
  435. gpg-error-config: gpgrt-config gpg-error-config-old
  436. @echo $(ECHO_N) "Confirm gpg-error-config works... $(ECHO_C)"
  437. @if $(srcdir)/gpg-error-config-test.sh --old-new; then \
  438. echo "good"; \
  439. else \
  440. echo "no"; \
  441. echo "*** Please report to <https://bugs.gnupg.org> with gpg-error-config-test.log"; \
  442. fi
  443. cp gpg-error-config-old $@
  444. install-data-local:
  445. if HAVE_W32CE_SYSTEM
  446. -$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
  447. $(INSTALL_DATA) gpg-extra/errno.h \
  448. "$(DESTDIR)$(includedir)/gpg-extra/errno.h"
  449. else
  450. :
  451. endif
  452. diff --git a/src/mkerrcodes.awk b/src/mkerrcodes.awk
  453. index 46d436c..e9c857c 100644
  454. --- a/src/mkerrcodes.awk
  455. +++ b/src/mkerrcodes.awk
  456. @@ -1,99 +1,99 @@
  457. # mkerrcodes.awk
  458. # Copyright (C) 2004, 2005 g10 Code GmbH
  459. #
  460. # This program is free software; you can redistribute it and/or
  461. # modify it under the terms of the GNU General Public License as
  462. # published by the Free Software Foundation; either version 2 of
  463. # the License, or (at your option) any later version.
  464. #
  465. # This program is distributed in the hope that it will be useful,
  466. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  467. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  468. # General Public License for more details.
  469. #
  470. # You should have received a copy of the GNU General Public License
  471. # along with this program; if not, write to the Free Software
  472. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  473. #
  474. # As a special exception, g10 Code GmbH gives unlimited permission to
  475. # copy, distribute and modify the C source files that are the output
  476. # of mkerrcodes.awk. You need not follow the terms of the GNU General
  477. # Public License when using or distributing such scripts, even though
  478. # portions of the text of mkerrcodes.awk appear in them. The GNU
  479. # General Public License (GPL) does govern all other use of the material
  480. # that constitutes the mkerrcodes.awk program.
  481. #
  482. # Certain portions of the mkerrcodes.awk source text are designed to be
  483. # copied (in certain cases, depending on the input) into the output of
  484. # mkerrcodes.awk. We call these the "data" portions. The rest of the
  485. # mkerrcodes.awk source text consists of comments plus executable code
  486. # that decides which of the data portions to output in any given case.
  487. # We call these comments and executable code the "non-data" portions.
  488. # mkerrcodes.h never copies any of the non-data portions into its output.
  489. #
  490. # This special exception to the GPL applies to versions of mkerrcodes.awk
  491. # released by g10 Code GmbH. When you make and distribute a modified version
  492. # of mkerrcodes.awk, you may extend this special exception to the GPL to
  493. # apply to your modified version as well, *unless* your modified version
  494. # has the potential to copy into its output some of the text that was the
  495. # non-data portion of the version that you started with. (In other words,
  496. # unless your change moves or copies text from the non-data portions to the
  497. # data portions.) If your modification has such potential, you must delete
  498. # any notice of this special exception to the GPL from your modified version.
  499. # This script outputs an intermediate file that contains the following output:
  500. # static struct
  501. # {
  502. # int err;
  503. # const char *err_sym;
  504. # } err_table[] =
  505. # {
  506. # { 7, "GPG_ERR_E2BIG" },
  507. # [...]
  508. # };
  509. #
  510. # The input file is a list of possible system errors, followed by a GPG_ERR_* name:
  511. #
  512. # 7 GPG_ERR_E2BIG
  513. #
  514. # Comments (starting with # and ending at the end of the line) are removed,
  515. # as is trailing whitespace.
  516. BEGIN {
  517. FS="[ \t]+GPG_ERR_";
  518. print "/* Output of mkerrcodes.awk. DO NOT EDIT. */";
  519. print "";
  520. header = 1;
  521. }
  522. /^#/ { next; }
  523. header {
  524. if (! /^[ \t]*$/)
  525. {
  526. header = 0;
  527. print "static struct";
  528. print " {";
  529. print " int err;";
  530. print " const char *err_sym;";
  531. print " } err_table[] = ";
  532. print "{";
  533. }
  534. else
  535. print;
  536. }
  537. !header {
  538. - sub (/\#.+/, "");
  539. + sub (/#.+/, "");
  540. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  541. if (/^$/)
  542. next;
  543. print " { " $1 ", \"GPG_ERR_" $2 "\" },";
  544. }
  545. END {
  546. print "};";
  547. }
  548. diff --git a/src/mkerrcodes1.awk b/src/mkerrcodes1.awk
  549. index a771a73..4578e29 100644
  550. --- a/src/mkerrcodes1.awk
  551. +++ b/src/mkerrcodes1.awk
  552. @@ -1,96 +1,96 @@
  553. # mkerrcodes.awk
  554. # Copyright (C) 2003, 2004 g10 Code GmbH
  555. #
  556. # This program is free software; you can redistribute it and/or
  557. # modify it under the terms of the GNU General Public License as
  558. # published by the Free Software Foundation; either version 2 of
  559. # the License, or (at your option) any later version.
  560. #
  561. # This program is distributed in the hope that it will be useful,
  562. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  563. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  564. # General Public License for more details.
  565. #
  566. # You should have received a copy of the GNU General Public License
  567. # along with this program; if not, write to the Free Software
  568. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  569. #
  570. # As a special exception, g10 Code GmbH gives unlimited permission to
  571. # copy, distribute and modify the C source files that are the output
  572. # of mkerrcodes.awk. You need not follow the terms of the GNU General
  573. # Public License when using or distributing such scripts, even though
  574. # portions of the text of mkerrcodes.awk appear in them. The GNU
  575. # General Public License (GPL) does govern all other use of the material
  576. # that constitutes the mkerrcodes.awk program.
  577. #
  578. # Certain portions of the mkerrcodes.awk source text are designed to be
  579. # copied (in certain cases, depending on the input) into the output of
  580. # mkerrcodes.awk. We call these the "data" portions. The rest of the
  581. # mkerrcodes.awk source text consists of comments plus executable code
  582. # that decides which of the data portions to output in any given case.
  583. # We call these comments and executable code the "non-data" portions.
  584. # mkerrcodes.h never copies any of the non-data portions into its output.
  585. #
  586. # This special exception to the GPL applies to versions of mkerrcodes.awk
  587. # released by g10 Code GmbH. When you make and distribute a modified version
  588. # of mkerrcodes.awk, you may extend this special exception to the GPL to
  589. # apply to your modified version as well, *unless* your modified version
  590. # has the potential to copy into its output some of the text that was the
  591. # non-data portion of the version that you started with. (In other words,
  592. # unless your change moves or copies text from the non-data portions to the
  593. # data portions.) If your modification has such potential, you must delete
  594. # any notice of this special exception to the GPL from your modified version.
  595. # This script outputs an intermediate file that contains the following block
  596. # for each error value symbol in the input file (example for EINVAL):
  597. #
  598. # #ifdef EINVAL
  599. # EINVAL GPG_ERR_EINVAL
  600. # #endif
  601. #
  602. # The input file is a list of possible system errors in the column errnoidx
  603. # (defaults to 2).
  604. #
  605. # Comments (starting with # and ending at the end of the line) are removed,
  606. # as is trailing whitespace.
  607. BEGIN {
  608. FS="[\t]+";
  609. header = 1;
  610. if (errnoidx == 0)
  611. errnoidx = 2;
  612. print "/* Output of mkerrcodes.awk. DO NOT EDIT. */";
  613. print "";
  614. }
  615. /^#/ { next; }
  616. header {
  617. if ($1 ~ /^[0-9]/)
  618. {
  619. print "#include <errno.h>";
  620. print "#ifdef _WIN32";
  621. print "#include <winsock2.h>";
  622. print "#endif";
  623. print "";
  624. header = 0;
  625. }
  626. else
  627. print;
  628. }
  629. !header {
  630. - sub (/\#.+/, "");
  631. + sub (/#.+/, "");
  632. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  633. if (/^$/)
  634. next;
  635. print "#ifdef " $errnoidx;
  636. print $errnoidx "\tGPG_ERR_" $errnoidx;
  637. print "#endif";
  638. print "#ifdef WSA" $errnoidx;
  639. print "WSA" $errnoidx "\tGPG_ERR_" $errnoidx;
  640. print "#endif";
  641. }
  642. diff --git a/src/mkerrcodes2.awk b/src/mkerrcodes2.awk
  643. index ea58503..188f7a4 100644
  644. --- a/src/mkerrcodes2.awk
  645. +++ b/src/mkerrcodes2.awk
  646. @@ -1,134 +1,134 @@
  647. # mkstrtable.awk
  648. # Copyright (C) 2003 g10 Code GmbH
  649. #
  650. # This program is free software; you can redistribute it and/or
  651. # modify it under the terms of the GNU General Public License as
  652. # published by the Free Software Foundation; either version 2 of
  653. # the License, or (at your option) any later version.
  654. #
  655. # This program is distributed in the hope that it will be useful,
  656. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  657. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  658. # General Public License for more details.
  659. #
  660. # You should have received a copy of the GNU General Public License
  661. # along with this program; if not, write to the Free Software
  662. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  663. #
  664. # As a special exception, g10 Code GmbH gives unlimited permission to
  665. # copy, distribute and modify the C source files that are the output
  666. # of mkerrcodes2.awk. You need not follow the terms of the GNU General
  667. # Public License when using or distributing such scripts, even though
  668. # portions of the text of mkerrcodes2.awk appear in them. The GNU
  669. # General Public License (GPL) does govern all other use of the material
  670. # that constitutes the mkerrcodes2.awk program.
  671. #
  672. # Certain portions of the mkerrcodes2.awk source text are designed to be
  673. # copied (in certain cases, depending on the input) into the output of
  674. # mkerrcodes2.awk. We call these the "data" portions. The rest of the
  675. # mkerrcodes2.awk source text consists of comments plus executable code
  676. # that decides which of the data portions to output in any given case.
  677. # We call these comments and executable code the "non-data" portions.
  678. # mkstrtable.h never copies any of the non-data portions into its output.
  679. #
  680. # This special exception to the GPL applies to versions of mkerrcodes2.awk
  681. # released by g10 Code GmbH. When you make and distribute a modified version
  682. # of mkerrcodes2.awk, you may extend this special exception to the GPL to
  683. # apply to your modified version as well, *unless* your modified version
  684. # has the potential to copy into its output some of the text that was the
  685. # non-data portion of the version that you started with. (In other words,
  686. # unless your change moves or copies text from the non-data portions to the
  687. # data portions.) If your modification has such potential, you must delete
  688. # any notice of this special exception to the GPL from your modified version.
  689. # This script outputs a source file that does define the following
  690. # symbols:
  691. #
  692. # static const char msgstr[];
  693. # A string containing all messages in the list.
  694. #
  695. # static const int msgidx[];
  696. # A list of index numbers, one for each message, that points to the
  697. # beginning of the string in msgstr.
  698. #
  699. # msgidxof (code);
  700. # A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE
  701. # is provided (see below), its index will be returned for unknown codes.
  702. # Otherwise -1 is returned for codes that do not appear in the list.
  703. # You can lookup the message with code CODE with:
  704. # msgstr + msgidx[msgidxof (code)].
  705. #
  706. # The input file has the following format:
  707. # CODE1 MESSAGE1 (Code number, <tab>, message string)
  708. # CODE2 MESSAGE2 (Code number, <tab>, message string)
  709. # ...
  710. # CODEn MESSAGEn (Code number, <tab>, message string)
  711. # DEFAULT MESSAGE (<tab>, fall-back message string)
  712. #
  713. # Comments (starting with # and ending at the end of the line) are removed,
  714. # as is trailing whitespace. The last line is optional; if no DEFAULT
  715. # MESSAGE is given, msgidxof will return the number -1 for unknown
  716. # index numbers.
  717. BEGIN {
  718. # msg holds the number of messages.
  719. msg = 0;
  720. print "/* Output of mkerrcodes2.awk. DO NOT EDIT. */";
  721. print "";
  722. header = 1;
  723. }
  724. /^#/ { next; }
  725. header {
  726. if ($1 ~ /^[0123456789]+$/)
  727. {
  728. print "static const int err_code_from_index[] = {";
  729. header = 0;
  730. }
  731. else
  732. print;
  733. }
  734. !header {
  735. - sub (/\#.+/, "");
  736. + sub (/#.+/, "");
  737. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  738. if (/^$/)
  739. next;
  740. # Print the string msgstr line by line. We delay output by one line to be able
  741. # to treat the last line differently (see END).
  742. print " " $2 ",";
  743. # Remember the error value and index of each error code.
  744. code[msg] = $1;
  745. pos[msg] = $2;
  746. msg++;
  747. }
  748. END {
  749. print "};";
  750. print "";
  751. print "#define errno_to_idx(code) (0 ? -1 \\";
  752. # Gather the ranges.
  753. skip = code[0];
  754. start = code[0];
  755. stop = code[0];
  756. for (i = 1; i < msg; i++)
  757. {
  758. if (code[i] == stop + 1)
  759. stop++;
  760. else
  761. {
  762. print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
  763. skip ") \\";
  764. skip += code[i] - stop - 1;
  765. start = code[i];
  766. stop = code[i];
  767. }
  768. }
  769. print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
  770. skip ") \\";
  771. print " : -1)";
  772. }
  773. diff --git a/src/mkerrnos.awk b/src/mkerrnos.awk
  774. index f79df66..15b1aad 100644
  775. --- a/src/mkerrnos.awk
  776. +++ b/src/mkerrnos.awk
  777. @@ -1,104 +1,104 @@
  778. # mkerrnos.awk
  779. # Copyright (C) 2003, 2004 g10 Code GmbH
  780. #
  781. # This program is free software; you can redistribute it and/or
  782. # modify it under the terms of the GNU General Public License as
  783. # published by the Free Software Foundation; either version 2 of
  784. # the License, or (at your option) any later version.
  785. #
  786. # This program is distributed in the hope that it will be useful,
  787. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  788. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  789. # General Public License for more details.
  790. #
  791. # You should have received a copy of the GNU General Public License
  792. # along with this program; if not, write to the Free Software
  793. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  794. #
  795. # As a special exception, g10 Code GmbH gives unlimited permission to
  796. # copy, distribute and modify the C source files that are the output
  797. # of mkerrnos.awk. You need not follow the terms of the GNU General
  798. # Public License when using or distributing such scripts, even though
  799. # portions of the text of mkerrnos.awk appear in them. The GNU
  800. # General Public License (GPL) does govern all other use of the material
  801. # that constitutes the mkerrnos.awk program.
  802. #
  803. # Certain portions of the mkerrnos.awk source text are designed to be
  804. # copied (in certain cases, depending on the input) into the output of
  805. # mkerrnos.awk. We call these the "data" portions. The rest of the
  806. # mkerrnos.awk source text consists of comments plus executable code
  807. # that decides which of the data portions to output in any given case.
  808. # We call these comments and executable code the "non-data" portions.
  809. # mkerrnos.h never copies any of the non-data portions into its output.
  810. #
  811. # This special exception to the GPL applies to versions of mkerrnos.awk
  812. # released by g10 Code GmbH. When you make and distribute a modified version
  813. # of mkerrnos.awk, you may extend this special exception to the GPL to
  814. # apply to your modified version as well, *unless* your modified version
  815. # has the potential to copy into its output some of the text that was the
  816. # non-data portion of the version that you started with. (In other words,
  817. # unless your change moves or copies text from the non-data portions to the
  818. # data portions.) If your modification has such potential, you must delete
  819. # any notice of this special exception to the GPL from your modified version.
  820. # This script outputs a source file that does define the following
  821. # symbols:
  822. #
  823. # static const int err_code_to_errno[];
  824. # A mapping of gpg_err_code_t numbers to system errno. The index of an
  825. # error code in the table can be obtained after removing the system error
  826. # code indication bit.
  827. #
  828. # The input file is a list of possible system errors in the column errnoidx
  829. # (defaults to 2).
  830. #
  831. # Comments (starting with # and ending at the end of the line) are removed,
  832. # as is trailing whitespace.
  833. BEGIN {
  834. FS="[\t]+";
  835. header = 1;
  836. if (errnoidx == 0)
  837. errnoidx = 2;
  838. print "/* Output of mkerrnos.awk. DO NOT EDIT. */";
  839. print "";
  840. }
  841. /^#/ { next; }
  842. header {
  843. if ($1 ~ /^[0-9]/)
  844. {
  845. print "#include <errno.h>";
  846. print "#ifdef _WIN32";
  847. print "#include <winsock2.h>";
  848. print "#endif";
  849. print "";
  850. print "static const int err_code_to_errno [] = {";
  851. header = 0;
  852. }
  853. else
  854. print;
  855. }
  856. !header {
  857. - sub (/\#.+/, "");
  858. + sub (/#.+/, "");
  859. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  860. if (/^$/)
  861. next;
  862. print "#ifdef " $errnoidx;
  863. print " " $errnoidx ",";
  864. print "#else";
  865. print "#ifdef WSA" $errnoidx;
  866. print " WSA" $errnoidx ",";
  867. print "#else";
  868. print " 0,";
  869. print "#endif";
  870. print "#endif";
  871. }
  872. END {
  873. print "};";
  874. }
  875. diff --git a/src/mkstrtable.awk b/src/mkstrtable.awk
  876. index c9de9c1..285e45f 100644
  877. --- a/src/mkstrtable.awk
  878. +++ b/src/mkstrtable.awk
  879. @@ -1,189 +1,189 @@
  880. # mkstrtable.awk
  881. # Copyright (C) 2003, 2004, 2008 g10 Code GmbH
  882. #
  883. # This program is free software; you can redistribute it and/or
  884. # modify it under the terms of the GNU General Public License as
  885. # published by the Free Software Foundation; either version 2 of
  886. # the License, or (at your option) any later version.
  887. #
  888. # This program is distributed in the hope that it will be useful,
  889. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  890. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  891. # General Public License for more details.
  892. #
  893. # You should have received a copy of the GNU General Public License
  894. # along with this program; if not, write to the Free Software
  895. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  896. #
  897. # As a special exception, g10 Code GmbH gives unlimited permission to
  898. # copy, distribute and modify the C source files that are the output
  899. # of mkstrtable.awk. You need not follow the terms of the GNU General
  900. # Public License when using or distributing such scripts, even though
  901. # portions of the text of mkstrtable.awk appear in them. The GNU
  902. # General Public License (GPL) does govern all other use of the material
  903. # that constitutes the mkstrtable.awk program.
  904. #
  905. # Certain portions of the mkstrtable.awk source text are designed to be
  906. # copied (in certain cases, depending on the input) into the output of
  907. # mkstrtable.awk. We call these the "data" portions. The rest of the
  908. # mkstrtable.awk source text consists of comments plus executable code
  909. # that decides which of the data portions to output in any given case.
  910. # We call these comments and executable code the "non-data" portions.
  911. # mkstrtable.h never copies any of the non-data portions into its output.
  912. #
  913. # This special exception to the GPL applies to versions of mkstrtable.awk
  914. # released by g10 Code GmbH. When you make and distribute a modified version
  915. # of mkstrtable.awk, you may extend this special exception to the GPL to
  916. # apply to your modified version as well, *unless* your modified version
  917. # has the potential to copy into its output some of the text that was the
  918. # non-data portion of the version that you started with. (In other words,
  919. # unless your change moves or copies text from the non-data portions to the
  920. # data portions.) If your modification has such potential, you must delete
  921. # any notice of this special exception to the GPL from your modified version.
  922. # This script outputs a source file that does define the following
  923. # symbols:
  924. #
  925. # static const char msgstr[];
  926. # A string containing all messages in the list.
  927. #
  928. # static const int msgidx[];
  929. # A list of index numbers, one for each message, that points to the
  930. # beginning of the string in msgstr.
  931. #
  932. # msgidxof (code);
  933. # A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE
  934. # is provided (see below), its index will be returned for unknown codes.
  935. # Otherwise -1 is returned for codes that do not appear in the list.
  936. # You can lookup the message with code CODE with:
  937. # msgstr + msgidx[msgidxof (code)].
  938. #
  939. # The input file has the following format:
  940. # CODE1 ... MESSAGE1 (code nr, <tab>, something, <tab>, msg)
  941. # CODE2 ... MESSAGE2 (code nr, <tab>, something, <tab>, msg)
  942. # ...
  943. # CODEn ... MESSAGEn (code nr, <tab>, something, <tab>, msg)
  944. # ... DEFAULT-MESSAGE (<tab>, something, <tab>, fall-back msg)
  945. #
  946. # Comments (starting with # and ending at the end of the line) are removed,
  947. # as is trailing whitespace. The last line is optional; if no DEFAULT
  948. # MESSAGE is given, msgidxof will return the number -1 for unknown
  949. # index numbers.
  950. #
  951. # The field to be used is specified with the variable "textidx" on
  952. # the command line. It defaults to 2.
  953. #
  954. # The variable nogettext can be set to 1 to suppress gettext markers.
  955. #
  956. # The variable prefix can be used to prepend a string to each message.
  957. #
  958. -# The variable namespace can be used to prepend a string to each
  959. +# The variable pkg_namespace can be used to prepend a string to each
  960. # variable and macro name.
  961. BEGIN {
  962. FS = "[\t]+";
  963. # cpos holds the current position in the message string.
  964. cpos = 0;
  965. # msg holds the number of messages.
  966. msg = 0;
  967. print "/* Output of mkstrtable.awk. DO NOT EDIT. */";
  968. print "";
  969. header = 1;
  970. if (textidx == 0)
  971. textidx = 2;
  972. # nogettext can be set to 1 to suppress gettext noop markers.
  973. }
  974. /^#/ { next; }
  975. header {
  976. if ($1 ~ /^[0123456789]+$/)
  977. {
  978. print "/* The purpose of this complex string table is to produce";
  979. print " optimal code with a minimum of relocations. */";
  980. print "";
  981. - print "static const char " namespace "msgstr[] = ";
  982. + print "static const char " pkg_namespace "msgstr[] = ";
  983. header = 0;
  984. }
  985. else
  986. print;
  987. }
  988. !header {
  989. - sub (/\#.+/, "");
  990. + sub (/#.+/, "");
  991. sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
  992. if (/^$/)
  993. next;
  994. # Print the string msgstr line by line. We delay output by one line to be able
  995. # to treat the last line differently (see END).
  996. if (last_msgstr)
  997. {
  998. if (nogettext)
  999. print " \"" last_msgstr "\" \"\\0\"";
  1000. else
  1001. print " gettext_noop (\"" last_msgstr "\") \"\\0\"";
  1002. }
  1003. last_msgstr = prefix $textidx;
  1004. # Remember the error code and msgidx of each error message.
  1005. code[msg] = $1;
  1006. pos[msg] = cpos;
  1007. cpos += length (last_msgstr) + 1;
  1008. msg++;
  1009. if ($1 == "")
  1010. {
  1011. has_default = 1;
  1012. exit;
  1013. }
  1014. }
  1015. END {
  1016. if (has_default)
  1017. coded_msgs = msg - 1;
  1018. else
  1019. coded_msgs = msg;
  1020. if (nogettext)
  1021. print " \"" last_msgstr "\";";
  1022. else
  1023. print " gettext_noop (\"" last_msgstr "\");";
  1024. print "";
  1025. - print "static const int " namespace "msgidx[] =";
  1026. + print "static const int " pkg_namespace "msgidx[] =";
  1027. print " {";
  1028. for (i = 0; i < coded_msgs; i++)
  1029. print " " pos[i] ",";
  1030. print " " pos[coded_msgs];
  1031. print " };";
  1032. print "";
  1033. print "static GPG_ERR_INLINE int";
  1034. - print namespace "msgidxof (int code)";
  1035. + print pkg_namespace "msgidxof (int code)";
  1036. print "{";
  1037. print " return (0 ? 0";
  1038. # Gather the ranges.
  1039. skip = code[0];
  1040. start = code[0];
  1041. stop = code[0];
  1042. for (i = 1; i < coded_msgs; i++)
  1043. {
  1044. if (code[i] == stop + 1)
  1045. stop++;
  1046. else
  1047. {
  1048. print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
  1049. skip ")";
  1050. skip += code[i] - stop - 1;
  1051. start = code[i];
  1052. stop = code[i];
  1053. }
  1054. }
  1055. print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \
  1056. skip ")";
  1057. if (has_default)
  1058. print " : " stop + 1 " - " skip ");";
  1059. else
  1060. print " : -1);";
  1061. print "}";
  1062. }