• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

POSIX.1 National Language Support API for MinGW


Commit MetaInfo

Revision2866fb9741f03685e092b7fbe7bd3506cc0eb753 (tree)
Zeit2007-07-17 04:59:42
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

* catclose.c (mc_close): Error out, if descriptor for message catalogue to be closed lies outside the valid range.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
1+2007-07-16 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ * catclose.c (mc_close): Error out, if descriptor for message
4+ catalogue to be closed lies outside the valid range.
5+
16 2007-06-18 Keith Marshall <keithmarshall@users.sourceforge.net>
27
38 Handle unicode input streams.
--- a/Makefile.in
+++ b/Makefile.in
@@ -6,10 +6,10 @@ VERSION = @PACKAGE_VERSION@
66
77 # $Id$
88 #
9-# Copyright (C) 2006, Keith Marshall
9+# Copyright (C) 2006, 2007, Keith Marshall
1010 #
1111 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
12-# Last modification: 30-Dec-2006
12+# Last modification: 20-Jun-2007
1313 #
1414 #
1515 # This is free software. It is provided AS IS, in the hope that it may
@@ -27,7 +27,7 @@ VERSION = @PACKAGE_VERSION@
2727 # MA 02110-1301, USA.
2828
2929 srcdir = @srcdir@
30-VPATH = ${srcdir}:${srcdir}/include:${srcdir}/repl
30+VPATH = ${srcdir}:${srcdir}/include:${srcdir}/repl:${srcdir}/man
3131
3232 prefix = @prefix@
3333 exec_prefix = @exec_prefix@
@@ -94,6 +94,36 @@ GENCAT_OBJECTS = @GENCAT_OBJECTS@
9494 OTHER_SOURCES = COPYING ChangeLog mkinstalldirs install-sh $(MISC_SOURCES)
9595 MISC_SOURCES = $(CONFIG_HEADERS) $(CONFIG_SOURCES) $(INSTALL_PROGS)
9696
97+MANPAGE_SOURCES = catopen.man catgets.man catclose.man gencat.man
98+
99+# MANSECTS specifies the set of *standard* man section identifiers, to
100+# which this collection of man pages will be distributed, or to which
101+# references are made in any man page in the collection.
102+#
103+MANSECTS = 1 2 3
104+
105+# The set of MAN<n>EXT macros allows us to define local aliases for each
106+# of the standard man section identifiers; these will be used instead of
107+# the standard identifiers, as extensions for the installed man page
108+# directories and file names.
109+#
110+MAN1EXT = 1
111+MAN2EXT = 2
112+MAN3EXT = 3
113+
114+# The following set of macros facilitate identification of the man
115+# section to which each generated `page.n' file belongs; this requires
116+# the `TH' record in each corresponding `page.man' source file to
117+# identify the appropriate section with a `@MAN<n>EXT@' tag.
118+#
119+mansect_lookup = '/^\.TH/{s/.*\(@MAN[0-9][^@]*EXT@\).*/\1/'
120+mansect_transform = $(foreach s,$(MANSECTS),-e s/@MAN$sEXT@/$(MAN$sEXT)/g)
121+mansect = -e $(mansect_lookup) $(mansect_transform) -e q -e \} -e d
122+manpage = ${mandir}/man$$section/$$pagename.$$section
123+
124+# Generic rule to create `page.n' from `page.man'...
125+#
126+%.n: %.man; sed $(mansect_transform) $< > $@
97127
98128 BUILD_PROGS = gencat$(EXEEXT)
99129 BUILD_LIBS = libcatgets.a
@@ -102,15 +132,17 @@ DLLVERSION = @DLLVERSION@
102132
103133 INSTALL_PROGS = gendefs.awk
104134
135+# Generic rule, replacing the built-in default, to create an object file
136+# from a C source file...
137+#
105138 %.$(OBJEXT): %.c
106139 $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFS) $(LDFLAGS) $<
107140
141+# Generic rule to create a local header from a template...
142+#
108143 %.h: %.h.in Makefile
109144 sed $(HEADER_TRANSFORM_SCRIPT) $< > $@
110145
111-%.h: repl/include/%.h
112- $(LN_S) $< $@
113-
114146 HEADER_TRANSFORM_SCRIPT = \
115147 -e 's,@HOST_PREFIX@,${canonical_prefix},g' \
116148 -e 's,@PATH_SEPARATOR_INTERNAL@,$(PATH_SEPARATOR_INTERNAL),g' \
@@ -118,9 +150,14 @@ HEADER_TRANSFORM_SCRIPT = \
118150
119151 AUTOGENERATED = Automatically generated from $<; do not edit!
120152
153+# Generic rule to make a replacement header available for use...
154+#
155+%.h: repl/include/%.h
156+ $(LN_S) $< $@
157+
121158 all-dll = @MAKE_DLL@
122159
123-all: all-libs $(all-dll) all-bin
160+all: all-libs $(all-dll) all-bin all-doc
124161
125162 all-bin: $(BUILD_PROGS)
126163
@@ -128,6 +165,15 @@ all-dll: $(BUILD_DLLS)
128165
129166 all-libs: $(BUILD_LIBS)
130167
168+all-doc: all-man all-info all-htmldoc all-pdf all-ps
169+
170+all-man: $(subst .man,.n,$(MANPAGE_SOURCES))
171+
172+all-info:
173+all-htmldoc:
174+all-pdf:
175+all-ps:
176+
131177 gencat$(EXEEXT): $(GENCAT_OBJECTS)
132178 $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBICONV) $(LIBS)
133179
@@ -184,7 +230,13 @@ install-headers: $(REPLACEMENT_HEADERS)
184230
185231 install-doc: install-man install-info install-htmldoc install-pdf install-ps
186232
187-install-man:
233+install-man: $(subst .man,.n,$(MANPAGE_SOURCES))
234+ for file in $^; do \
235+ pagename=`echo $$file | sed 's/\.n//'`; \
236+ section=`sed $(mansect) ${srcdir}/$$pagename.man`; \
237+ echo $(INSTALL_DATA) $$file $(manpage); \
238+ done
239+
188240 install-info:
189241 install-htmldoc:
190242 install-pdf:
@@ -198,7 +250,7 @@ install-ps:
198250 dist: srcdist bindist
199251 dist_srcdir = @abs_top_srcdir@
200252
201-DISTDIRS = include m4 repl repl/include
253+DISTDIRS = include m4 repl repl/include man
202254 DISTFILES = $(GENCAT_SOURCES) $(CATGETS_SOURCES) $(OTHER_SOURCES)
203255 DISTNAME = $(PACKAGE)-$(VERSION)
204256
@@ -233,9 +285,9 @@ bindist: all
233285
234286 clean:
235287 rm -f nlspath.h $(LOCAL_HEADERS) $(REPLACEMENT_HEADERS)
236- rm -f *.$(OBJEXT) *~ gencat$(EXEEXT)
288+ rm -f *.$(OBJEXT) *~ gencat$(EXEEXT) *.n *.a *.dll
237289
238290 distclean: clean
239291 rm -rf Makefile config.h config.[ls]* autom4te.cache
240292
241-# $RCSfile$Revision: 1.1.1.1 $: end of file
293+# $RCSfile$Revision: 1.2 $: end of file
--- a/catclose.c
+++ b/catclose.c
@@ -30,13 +30,33 @@
3030
3131 #include <stdarg.h>
3232 #include <mctab.h>
33+#include <errno.h>
3334
3435 static
3536 void *mc_close( struct mc_tab *cdt, va_list argv )
3637 {
3738 /* This call-back function provides the actual `catclose' implementation.
39+ * There is one entry in the `argv' vector, representing the descriptor
40+ * for the catalogue which is to be closed.
3841 */
39- return (void *)_mc_free_( cdt->tab + va_arg( argv, int ) );
42+ int catd = va_arg( argv, int );
43+ if( (catd < 0) || (catd >= cdt->curr_size) )
44+ {
45+ /* The catalogue descriptor is simply an integer index into an array
46+ * of pointers to the actual message catalogue data structures. There
47+ * are exactly cdt->curr_size elements in this descriptor array, with
48+ * index values ranging from 0 .. cdt->curr_size - 1; if here, then
49+ * the value of catd falls outside this range, we decline to accept
50+ * it, bailing out with errno = EBADF, as specified by POSIX.
51+ */
52+ errno = EBADF;
53+ return (void *)(-1);
54+ }
55+ /* If we get past this validity check, then we simply hand off the task
56+ * of closing the message catalogue, and freeing its resource allocation,
57+ * to the _mc_free_ function.
58+ */
59+ return (void *)_mc_free_( cdt->tab + catd );
4060 }
4161
4262 int catclose( nl_catd catd )
@@ -46,4 +66,4 @@ int catclose( nl_catd catd )
4666 return (int)_mctab_( mc_close, catd );
4767 }
4868
49-/* $RCSfile$Revision$: end of file */
69+/* $RCSfile$Revision: 1.1.1.1 $: end of file */