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