• 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

Revision7e0de601c7e088089c4622cabd4eba6933a47893 (tree)
Zeit2007-05-13 07:51:10
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Add support for delset' directive.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
11 2007-05-12 Keith Marshall <keithmarshall@users.sourceforge.net>
22
3+ Add support for `delset' directive.
4+
5+ * mcmerge.c (mc_delset): New static function...
6+ (mc_merge): Use it.
7+
8+ * include/gcmsgs.h (MSG_DEL_UNSUPPORTED): Redundant message
9+ definition; deleted.
10+
11+2007-05-12 Keith Marshall <keithmarshall@users.sourceforge.net>
12+
313 Add support for single message deletion.
414
515 * mcsource.c: More comment improvements.
--- a/include/gcmsgs.h
+++ b/include/gcmsgs.h
@@ -49,7 +49,6 @@
4949 #define MSG_MSGNUM_NOT_INCR 2, 6, "invalid message number: expecting > %d; got %d\n"
5050 #define MSG_REDEFINED 2, 7, "%s: %s:%u: redefinition of message %u in set %u\n"
5151 #define MSG_PREVIOUS_HERE 2, 8, "%s: %s:%u: previous definition was here\n"
52-#define MSG_DEL_UNSUPPORTED 3, 1, "%s: %s:%u: `delset' operation not yet supported\n"
5352 #define MSG_EOF_IN_QUOTES 3, 2, "%s:%u: unexpected EOF encountered before closing quote\n"
5453 #define MSG_TEXT_DISCARDED 3, 3, "%s:%u: incomplete message marked for deletion\n"
5554 #define MSG_MISSING_NEWLINE 3, 4, "%s:%u: missing newline at end of file\n"
@@ -57,4 +56,4 @@
5756 /* !
5857 * !$ end of file
5958 */
60-#endif /* !defined( GCMSGS_H ): $RCSfile$Revision: 1.1.1.1 $: end of file */
59+#endif /* !defined( GCMSGS_H ): $RCSfile$Revision: 1.2 $: end of file */
--- a/mcmerge.c
+++ b/mcmerge.c
@@ -40,6 +40,30 @@
4040 #include <gencat.h>
4141 #include <gcmsgs.h>
4242
43+static
44+struct msgdict *mc_delset( unsigned short setnum, struct msgdict *msgset )
45+{
46+ /* Helper function, called by `mc_merge', to unlink message references
47+ * in any set specified in a `delset' directive.
48+ */
49+ while( msgset && (msgset->set == setnum) )
50+ {
51+ /* Walk the message list, freeing the memory allocated to message
52+ * entries with matching set number.
53+ */
54+ struct msgdict *ref = msgset;
55+ msgset = msgset->link;
56+ free( ref );
57+ }
58+ /* When done, return the address of the first message in the set,
59+ * if any, following the one we just deleted; `mc_merge' will link
60+ * this to succeed the predecessor, if any, of the deleted set,
61+ * or otherwise, replacing the first set in the catalogue,
62+ * thus implicitly unlinking the deleted messages.
63+ */
64+ return msgset;
65+}
66+
4367 struct msgdict *mc_merge( struct msgdict *cat, struct msgdict *input )
4468 {
4569 struct msgdict *mark = cat;
@@ -233,10 +257,80 @@ struct msgdict *mc_merge( struct msgdict *cat, struct msgdict *input )
233257
234258 else if( input->set && (input->base == NULL) )
235259 {
236- /* This is a a `delset' operation...
237- * FIXME: we don't have support for this yet!
260+ /* This is a a `delset' operation; it will delete all messages
261+ * currently present in the catalogue, which are assigned to the
262+ * specified message set.
263+ *
264+ * Obviously, if the catalogue is currently empty, then this is
265+ * a no-op...
266+ */
267+ if( cat )
268+ {
269+ /* ...but when we do already have some content defined, then we
270+ * must locate and delete the specified set, if it exists.
271+ */
272+ if( cat->set == input->set )
273+ {
274+ /* The set to be deleted is the first in the catalogue...
275+ */
276+ if( mark->set == input->set )
277+ /*
278+ * ...and the current insertion point also lies within
279+ * this set, so *both* references must be adjusted.
280+ */
281+ mark = cat = mc_delset( input->set, cat );
282+
283+ else
284+ /* ...the current insertion point has already advanced
285+ * beyond the set to be deleted, so leave it unchanged,
286+ * and simply remove the entire initial message set.
287+ */
288+ cat = mc_delset( input->set, cat );
289+ }
290+ else
291+ {
292+ /* The set to be deleted is not the first in the catalogue,
293+ * so we must locate the last message entry in the set which
294+ * immediately precedes that to be deleted; this becomes the
295+ * reference point, from which deletion commences, and to
296+ * which any following message set must be relinked.
297+ */
298+ struct msgdict *delset, *ref = cat;
299+
300+ /* Our search for this reference entry begins at the start
301+ * of the catalogue; however, if the current insertion point
302+ * lies in a set which precedes that to be deleted, then we
303+ * may immediately jump ahead to this point.
304+ */
305+ if( mark->key < input->key )
306+ ref = mark;
307+
308+ /* We now walk the message list, until we either find the
309+ * required reference point, or our search overruns the end
310+ * of the list.
311+ */
312+ while( ((delset = ref->link) != NULL) && (delset->key < input->key) )
313+ ref = delset;
314+
315+ /* Now, we must check the current insertion point, to ensure
316+ * that * it does not refer to an entry we are about to delete;
317+ * if it points to a message with a set number matching that of
318+ * the set to be deleted, then we must adjust it.
319+ */
320+ if( mark->set == input->set )
321+ mark = ref;
322+
323+ /* Finally, if we found entries in the set to be deleted,
324+ * then we discard them.
325+ */
326+ if( delset->set == input->set )
327+ ref->link = mc_delset( input->set, delset );
328+ }
329+ }
330+ /* Whether or not we actually found and deleted the specified
331+ * message set, (if not, we silently ignore the `delset' request),
332+ * the current input record serves no further purpose.
238333 */
239- fprintf( errmsg( MSG_DEL_UNSUPPORTED ), progname, input->src, input->lineno );
240334 free( input );
241335 }
242336
@@ -272,4 +366,4 @@ struct msgdict *mc_merge( struct msgdict *cat, struct msgdict *input )
272366 return cat;
273367 }
274368
275-/* $RCSfile$Revision: 1.1.1.1 $: end of file */
369+/* $RCSfile$Revision: 1.2 $: end of file */