Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/**** rename-file.c --- Routines for parsing rename file.
61
/**** rename-file.c --- Routines for parsing rename file.
32
 *
62
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
63
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
64
 *
35
 **** Commentary:
65
 **** Commentary:
36
 *
66
 *
37
 * This file provides the routines that parse the rename file.  The rename
67
 * This file provides the routines that parse the rename file.  The rename
Line 100... Line 130...
100
} RenameTokenT, *RenameTokenP;
130
} RenameTokenT, *RenameTokenP;
101
 
131
 
102
/*--------------------------------------------------------------------------*/
132
/*--------------------------------------------------------------------------*/
103
 
133
 
104
static BoolT
134
static BoolT
105
rename_file_skip_white_space PROTO_N ((istream, c_ref))
135
rename_file_skip_white_space(IStreamP istream,				      char    *c_ref)
106
			     PROTO_T (IStreamP istream X
-
 
107
				      char    *c_ref)
-
 
108
{
136
{
109
    BoolT comment = FALSE;
137
    BoolT comment = FALSE;
110
 
138
 
111
    for (;;) {
139
    for (;;) {
112
	char c;
140
	char c;
113
 
141
 
114
      redo:
142
      redo:
115
	switch (c = ISTREAM_READ_CHAR (istream)) {
143
	switch (c = ISTREAM_READ_CHAR(istream)) {
116
	  case '\0':
144
	  case '\0':
117
	    ISTREAM_HANDLE_NULL (istream, redo, eof);
145
	    ISTREAM_HANDLE_NULL(istream, redo, eof);
118
	    break;
146
	    break;
119
	  case '\n':
147
	  case '\n':
120
	    istream_inc_line (istream);
148
	    istream_inc_line(istream);
121
	    comment = FALSE;
149
	    comment = FALSE;
122
	    break;
150
	    break;
123
	  case '#':
151
	  case '#':
124
	    comment = TRUE;
152
	    comment = TRUE;
125
	    break;
153
	    break;
126
	  default:
154
	  default:
127
	    if ((!comment) && (!syntax_is_white_space (c))) {
155
	    if ((!comment) && (!syntax_is_white_space(c))) {
128
		*c_ref = c;
156
		*c_ref = c;
129
		return (TRUE);
157
		return(TRUE);
130
	    }
158
	    }
131
	    break;
159
	    break;
132
	}
160
	}
133
    }
161
    }
134
  eof:
162
  eof:
135
    return (FALSE);
163
    return(FALSE);
136
}
164
}
137
 
165
 
138
static void
166
static void
139
rename_file_read_unique PROTO_N ((istream, token))
167
rename_file_read_unique(IStreamP     istream,				 RenameTokenP token)
140
			PROTO_T (IStreamP     istream X
-
 
141
				 RenameTokenP token)
-
 
142
{
168
{
143
    NameKeyP          name   = &(token->u.name);
169
    NameKeyP          name   = & (token->u.name);
144
    unsigned          length = 1;
170
    unsigned          length = 1;
145
    DStringT          dstring;
171
    DStringT          dstring;
146
    NStringT          nstring;
172
    NStringT          nstring;
147
    NStringListT      list;
173
    NStringListT      list;
148
    NStringListEntryP entry;
174
    NStringListEntryP entry;
149
    unsigned          i;
175
    unsigned          i;
150
 
176
 
151
    dstring_init (&dstring);
177
    dstring_init(&dstring);
152
    nstring_list_init (&list);
178
    nstring_list_init(&list);
153
    for (;;) {
179
    for (;;) {
154
	char c;
180
	char c;
155
 
181
 
156
      redo:
182
      redo:
157
	switch (c = ISTREAM_READ_CHAR (istream)) {
183
	switch (c = ISTREAM_READ_CHAR(istream)) {
158
	  case '\0':
184
	  case '\0':
159
	    ISTREAM_HANDLE_NULL (istream, redo, eof);
185
	    ISTREAM_HANDLE_NULL(istream, redo, eof);
160
	    dstring_append_char (&dstring, '\0');
186
	    dstring_append_char(&dstring, '\0');
161
	    break;
187
	    break;
162
	  case '\n':
188
	  case '\n':
163
	    istream_inc_line (istream);
189
	    istream_inc_line(istream);
164
	    E_rename_unexpected_newline (istream);
190
	    E_rename_unexpected_newline(istream);
165
	    break;
191
	    break;
166
	  case ']':
192
	  case ']':
167
	    dstring_to_nstring (&dstring, &nstring);
193
	    dstring_to_nstring(&dstring, &nstring);
168
	    nstring_list_append (&list, &nstring);
194
	    nstring_list_append(&list, &nstring);
169
	    dstring_destroy (&dstring);
195
	    dstring_destroy(&dstring);
170
	    name_key_init_unique (name, length);
196
	    name_key_init_unique(name, length);
171
 	    for (i = 0, entry = nstring_list_head (&list); entry;
197
 	    for (i = 0, entry = nstring_list_head(&list); entry;
172
		 i ++, entry = nstring_list_entry_deallocate (entry)) {
198
		 i++, entry = nstring_list_entry_deallocate(entry)) {
173
		NStringP component = nstring_list_entry_string (entry);
199
		NStringP component = nstring_list_entry_string(entry);
174
 
200
 
175
		name_key_set_component (name, i, component);
201
		name_key_set_component(name, i, component);
176
	    }
202
	    }
177
	    token->tag = RTOK_NAME;
203
	    token->tag = RTOK_NAME;
178
	    return;
204
	    return;
179
	  case '[':
205
	  case '[':
180
	    E_rename_illegal_char (istream, c);
206
	    E_rename_illegal_char(istream, c);
181
	    break;
207
	    break;
182
	  case '.':
208
	  case '.':
183
	    dstring_to_nstring (&dstring, &nstring);
209
	    dstring_to_nstring(&dstring, &nstring);
184
	    nstring_list_append (&list, &nstring);
210
	    nstring_list_append(&list, &nstring);
185
	    dstring_destroy (&dstring);
211
	    dstring_destroy(&dstring);
186
	    dstring_init (&dstring);
212
	    dstring_init(&dstring);
187
	    length ++;
213
	    length++;
188
	    break;
214
	    break;
189
	  case '\\':
215
	  case '\\':
190
	    switch (istream_read_escaped_char (istream, &c)) EXHAUSTIVE {
216
	    switch (istream_read_escaped_char(istream, &c))EXHAUSTIVE {
191
	      case ISTREAM_STAT_READ_CHAR:
217
	      case ISTREAM_STAT_READ_CHAR:
192
		dstring_append_char (&dstring, c);
218
		dstring_append_char(&dstring, c);
193
		break;
219
		break;
194
	      case ISTREAM_STAT_SYNTAX_ERROR:
220
	      case ISTREAM_STAT_SYNTAX_ERROR:
195
		E_rename_illegal_escape (istream);
221
		E_rename_illegal_escape(istream);
196
		break;
222
		break;
197
	      case ISTREAM_STAT_NO_CHAR:
223
	      case ISTREAM_STAT_NO_CHAR:
198
		/*NOTHING*/
224
		/*NOTHING*/
199
		break;
225
		break;
200
	    }
226
	    }
201
	    break;
227
	    break;
202
	  default:
228
	  default:
203
	    dstring_append_char (&dstring, c);
229
	    dstring_append_char(&dstring, c);
204
	    break;
230
	    break;
205
	}
231
	}
206
    }
232
    }
207
  eof:
233
  eof:
208
    E_rename_unexpected_eof (istream);
234
    E_rename_unexpected_eof(istream);
209
    dstring_destroy (&dstring);
235
    dstring_destroy(&dstring);
210
    for (entry = nstring_list_head (&list); entry;
236
    for (entry = nstring_list_head(&list); entry;
211
	 entry = nstring_list_entry_deallocate (entry)) {
237
	 entry = nstring_list_entry_deallocate(entry)) {
212
	nstring_destroy (nstring_list_entry_string (entry));
238
	nstring_destroy(nstring_list_entry_string(entry));
213
    }
239
    }
214
    token->tag = RTOK_EOF;
240
    token->tag = RTOK_EOF;
215
}
241
}
216
 
242
 
217
static void
243
static void
218
rename_file_read_shape PROTO_N ((istream, token))
244
rename_file_read_shape(IStreamP     istream,				RenameTokenP token)
219
		       PROTO_T (IStreamP     istream X
-
 
220
				RenameTokenP token)
-
 
221
{
245
{
222
    DStringT dstring;
246
    DStringT dstring;
223
 
247
 
224
    dstring_init (&dstring);
248
    dstring_init(&dstring);
225
    for (;;) {
249
    for (;;) {
226
	char c;
250
	char c;
227
 
251
 
228
      redo:
252
      redo:
229
	switch (c = ISTREAM_READ_CHAR (istream)) {
253
	switch (c = ISTREAM_READ_CHAR(istream)) {
230
	  case '\0':
254
	  case '\0':
231
	    ISTREAM_HANDLE_NULL (istream, redo, eof);
255
	    ISTREAM_HANDLE_NULL(istream, redo, eof);
232
	    dstring_append_char (&dstring, '\0');
256
	    dstring_append_char(&dstring, '\0');
233
	    break;
257
	    break;
234
	  case '\n':
258
	  case '\n':
235
	    istream_inc_line (istream);
259
	    istream_inc_line(istream);
236
	    E_rename_unexpected_newline (istream);
260
	    E_rename_unexpected_newline(istream);
237
	    break;
261
	    break;
238
	  case '\'':
262
	  case '\'':
239
	    dstring_to_nstring (&dstring, &(token->u.shape));
263
	    dstring_to_nstring(&dstring, & (token->u.shape));
240
	    dstring_destroy (&dstring);
264
	    dstring_destroy(&dstring);
241
	    token->tag = RTOK_SHAPE;
265
	    token->tag = RTOK_SHAPE;
242
	    return;
266
	    return;
243
	  case '\\':
267
	  case '\\':
244
	    switch (istream_read_escaped_char (istream, &c)) EXHAUSTIVE {
268
	    switch (istream_read_escaped_char(istream, &c))EXHAUSTIVE {
245
	      case ISTREAM_STAT_READ_CHAR:
269
	      case ISTREAM_STAT_READ_CHAR:
246
		dstring_append_char (&dstring, c);
270
		dstring_append_char(&dstring, c);
247
		break;
271
		break;
248
	      case ISTREAM_STAT_SYNTAX_ERROR:
272
	      case ISTREAM_STAT_SYNTAX_ERROR:
249
		E_rename_illegal_escape (istream);
273
		E_rename_illegal_escape(istream);
250
		break;
274
		break;
251
	      case ISTREAM_STAT_NO_CHAR:
275
	      case ISTREAM_STAT_NO_CHAR:
252
		/*NOTHING*/
276
		/*NOTHING*/
253
		break;
277
		break;
254
	    }
278
	    }
255
	    break;
279
	    break;
256
	  default:
280
	  default:
257
	    dstring_append_char (&dstring, c);
281
	    dstring_append_char(&dstring, c);
258
	    break;
282
	    break;
259
	}
283
	}
260
    }
284
    }
261
  eof:
285
  eof:
262
    E_rename_unexpected_eof (istream);
286
    E_rename_unexpected_eof(istream);
263
    dstring_destroy (&dstring);
287
    dstring_destroy(&dstring);
264
    token->tag = RTOK_EOF;
288
    token->tag = RTOK_EOF;
265
}
289
}
266
 
290
 
267
static void
291
static void
268
rename_file_read_string PROTO_N ((istream, token))
292
rename_file_read_string(IStreamP     istream,				 RenameTokenP token)
269
			PROTO_T (IStreamP     istream X
-
 
270
				 RenameTokenP token)
-
 
271
{
293
{
272
    DStringT dstring;
294
    DStringT dstring;
273
    NStringT nstring;
295
    NStringT nstring;
274
 
296
 
275
    dstring_init (&dstring);
297
    dstring_init(&dstring);
276
    for (;;) {
298
    for (;;) {
277
	char c;
299
	char c;
278
 
300
 
279
      redo:
301
      redo:
280
	switch (c = ISTREAM_READ_CHAR (istream)) {
302
	switch (c = ISTREAM_READ_CHAR(istream)) {
281
	  case '\0':
303
	  case '\0':
282
	    ISTREAM_HANDLE_NULL (istream, redo, eof);
304
	    ISTREAM_HANDLE_NULL(istream, redo, eof);
283
	    dstring_append_char (&dstring, '\0');
305
	    dstring_append_char(&dstring, '\0');
284
	    break;
306
	    break;
285
	  case '\n':
307
	  case '\n':
286
	    istream_inc_line (istream);
308
	    istream_inc_line(istream);
287
	    E_rename_unexpected_newline (istream);
309
	    E_rename_unexpected_newline(istream);
288
	    break;
310
	    break;
289
	  case '"':
311
	  case '"':
290
	    dstring_to_nstring (&dstring, &nstring);
312
	    dstring_to_nstring(&dstring, &nstring);
291
	    dstring_destroy (&dstring);
313
	    dstring_destroy(&dstring);
292
	    name_key_init_string (&(token->u.name), &nstring);
314
	    name_key_init_string(& (token->u.name), &nstring);
293
	    token->tag = RTOK_NAME;
315
	    token->tag = RTOK_NAME;
294
	    return;
316
	    return;
295
	  case '[': case ']': case '.':
317
	  case '[': case ']': case '.':
296
	    E_rename_illegal_char (istream, c);
318
	    E_rename_illegal_char(istream, c);
297
	    break;
319
	    break;
298
	  case '\\':
320
	  case '\\':
299
	    switch (istream_read_escaped_char (istream, &c)) EXHAUSTIVE {
321
	    switch (istream_read_escaped_char(istream, &c))EXHAUSTIVE {
300
	      case ISTREAM_STAT_READ_CHAR:
322
	      case ISTREAM_STAT_READ_CHAR:
301
		dstring_append_char (&dstring, c);
323
		dstring_append_char(&dstring, c);
302
		break;
324
		break;
303
	      case ISTREAM_STAT_SYNTAX_ERROR:
325
	      case ISTREAM_STAT_SYNTAX_ERROR:
304
		E_rename_illegal_escape (istream);
326
		E_rename_illegal_escape(istream);
305
		break;
327
		break;
306
	      case ISTREAM_STAT_NO_CHAR:
328
	      case ISTREAM_STAT_NO_CHAR:
307
		/*NOTHING*/
329
		/*NOTHING*/
308
		break;
330
		break;
309
	    }
331
	    }
310
	    break;
332
	    break;
311
	  default:
333
	  default:
312
	    dstring_append_char (&dstring, c);
334
	    dstring_append_char(&dstring, c);
313
	    break;
335
	    break;
314
	}
336
	}
315
    }
337
    }
316
  eof:
338
  eof:
317
    E_rename_unexpected_eof (istream);
339
    E_rename_unexpected_eof(istream);
318
    dstring_destroy (&dstring);
340
    dstring_destroy(&dstring);
319
    token->tag = RTOK_EOF;
341
    token->tag = RTOK_EOF;
320
}
342
}
321
 
343
 
322
static void
344
static void
323
rename_file_next_token PROTO_N ((istream, token))
345
rename_file_next_token(IStreamP     istream,				RenameTokenP token)
324
		       PROTO_T (IStreamP     istream X
-
 
325
				RenameTokenP token)
-
 
326
{
346
{
327
    char c;
347
    char c;
328
 
348
 
329
  again:
349
  again:
330
    if (rename_file_skip_white_space (istream, &c)) {
350
    if (rename_file_skip_white_space(istream, &c)) {
331
	switch (c) {
351
	switch (c) {
332
	  case '[':
352
	  case '[':
333
	    rename_file_read_unique (istream, token);
353
	    rename_file_read_unique(istream, token);
334
	    break;
354
	    break;
335
	  case '\'':
355
	  case '\'':
336
	     rename_file_read_shape (istream, token);
356
	     rename_file_read_shape(istream, token);
337
	    break;
357
	    break;
338
	  case '"':
358
	  case '"':
339
	    rename_file_read_string (istream, token);
359
	    rename_file_read_string(istream, token);
340
	    break;
360
	    break;
341
	  case ';':
361
	  case ';':
342
	    token->tag = RTOK_SEMI;
362
	    token->tag = RTOK_SEMI;
343
	    break;
363
	    break;
344
	  default:
364
	  default:
345
	    E_rename_illegal_char (istream, c);
365
	    E_rename_illegal_char(istream, c);
346
	    goto again;
366
	    goto again;
347
	}
367
	}
348
    } else {
368
    } else {
349
	token->tag = RTOK_EOF;
369
	token->tag = RTOK_EOF;
350
    }
370
    }
351
}
371
}
352
 
372
 
353
static void
373
static void
354
rename_file_parse_names PROTO_N ((istream, shape, arg_data, token))
374
rename_file_parse_names(IStreamP     istream,				 NStringP     shape ,
355
			PROTO_T (IStreamP     istream X
-
 
356
				 NStringP     shape X
-
 
357
				 ArgDataP     arg_data X
375
				 ArgDataP     arg_data ,
358
				 RenameTokenP token)
376
				 RenameTokenP token)
359
{
377
{
360
    rename_file_next_token (istream, token);
378
    rename_file_next_token(istream, token);
361
    while (token->tag == RTOK_NAME) {
379
    while (token->tag == RTOK_NAME) {
362
	NameKeyT name;
380
	NameKeyT name;
363
 
381
 
364
	name_key_assign (&name, &(token->u.name));
382
	name_key_assign(&name, & (token->u.name));
365
	rename_file_next_token (istream, token);
383
	rename_file_next_token(istream, token);
366
	if (token->tag != RTOK_NAME) {
384
	if (token->tag != RTOK_NAME) {
367
	    E_rename_expected_name (istream);
385
	    E_rename_expected_name(istream);
368
	    name_key_destroy (&name);
386
	    name_key_destroy(&name);
369
	    if (token->tag != RTOK_SEMI) {
387
	    if (token->tag != RTOK_SEMI) {
370
		return;
388
		return;
371
	    }
389
	    }
372
	    rename_file_next_token (istream, token);
390
	    rename_file_next_token(istream, token);
373
	} else {
391
	} else {
374
	    NameKeyT to_name;
392
	    NameKeyT to_name;
375
 
393
 
376
	    name_key_assign (&to_name, &(token->u.name));
394
	    name_key_assign(&to_name, & (token->u.name));
377
	    arg_data_add_rename (arg_data, shape, &name, &to_name);
395
	    arg_data_add_rename(arg_data, shape, &name, &to_name);
378
	    rename_file_next_token (istream, token);
396
	    rename_file_next_token(istream, token);
379
	    if (token->tag != RTOK_SEMI) {
397
	    if (token->tag != RTOK_SEMI) {
380
		E_rename_expected_semi (istream);
398
		E_rename_expected_semi(istream);
381
	    } else {
399
	    } else {
382
		rename_file_next_token (istream, token);
400
		rename_file_next_token(istream, token);
383
	    }
401
	    }
384
	}
402
	}
385
    }
403
    }
386
}
404
}
387
 
405
 
388
static void
406
static void
389
rename_file_parse_1 PROTO_N ((istream, arg_data))
407
rename_file_parse_1(IStreamP istream,			     ArgDataP arg_data)
390
		    PROTO_T (IStreamP istream X
-
 
391
			     ArgDataP arg_data)
-
 
392
{
408
{
393
    BoolT        need_error = TRUE;
409
    BoolT        need_error = TRUE;
394
    RenameTokenT token;
410
    RenameTokenT token;
395
    NStringT     shape;
411
    NStringT     shape;
396
 
412
 
397
    rename_file_next_token (istream, &token);
413
    rename_file_next_token(istream, &token);
398
    while (token.tag != RTOK_EOF) {
414
    while (token.tag != RTOK_EOF) {
399
	switch (token.tag) {
415
	switch (token.tag) {
400
	  case RTOK_SHAPE:
416
	  case RTOK_SHAPE:
401
	    nstring_assign (&shape, &(token.u.shape));
417
	    nstring_assign(&shape, & (token.u.shape));
402
	    rename_file_parse_names (istream, &shape, arg_data, &token);
418
	    rename_file_parse_names(istream, &shape, arg_data, &token);
403
	    nstring_destroy (&shape);
419
	    nstring_destroy(&shape);
404
	    need_error = TRUE;
420
	    need_error = TRUE;
405
	    break;
421
	    break;
406
	  case RTOK_NAME:
422
	  case RTOK_NAME:
407
	    name_key_destroy (&(token.u.name));
423
	    name_key_destroy(& (token.u.name));
408
	    FALL_THROUGH;
424
	    FALL_THROUGH;
409
	  default:
425
	  default:
410
	    if (need_error) {
426
	    if (need_error) {
411
		E_rename_expected_shape (istream);
427
		E_rename_expected_shape(istream);
412
		need_error = FALSE;
428
		need_error = FALSE;
413
	    }
429
	    }
414
	    rename_file_next_token (istream, &token);
430
	    rename_file_next_token(istream, &token);
415
	    break;
431
	    break;
416
	}
432
	}
417
    }
433
    }
418
}
434
}
419
 
435
 
420
/*--------------------------------------------------------------------------*/
436
/*--------------------------------------------------------------------------*/
421
 
437
 
422
void
438
void
423
rename_file_parse PROTO_N ((name, arg_data))
439
rename_file_parse(CStringP name,			   ArgDataP arg_data)
424
		  PROTO_T (CStringP name X
-
 
425
			   ArgDataP arg_data)
-
 
426
{
440
{
427
    IStreamT istream;
441
    IStreamT istream;
428
 
442
 
429
    if (istream_open (&istream, name)) {
443
    if (istream_open(&istream, name)) {
430
	rename_file_parse_1 (&istream, arg_data);
444
	rename_file_parse_1(&istream, arg_data);
431
	istream_close (&istream);
445
	istream_close(&istream);
432
    } else {
446
    } else {
433
	E_cannot_open_rename_file (name);
447
	E_cannot_open_rename_file(name);
434
    }
448
    }
435
    if (error_max_reported_severity () >= ERROR_SEVERITY_ERROR) {
449
    if (error_max_reported_severity() >= ERROR_SEVERITY_ERROR) {
436
	exit (EXIT_FAILURE);
450
	exit(EXIT_FAILURE);
437
	UNREACHED;
451
	UNREACHED;
438
    }
452
    }
439
}
453
}
440

454

441
/*
455
/*