1 /******************************************************************************
3 * Copyright (C) 2000 Pierangelo Masarati, <ando@sys-net.it>
6 * Permission is granted to anyone to use this software for any purpose
7 * on any computer system, and to alter it and redistribute it, subject
8 * to the following restrictions:
10 * 1. The author is not responsible for the consequences of use of this
11 * software, no matter how awful, even if they arise from flaws in it.
13 * 2. The origin of this software must not be misrepresented, either by
14 * explicit claim or by omission. Since few users ever read sources,
15 * credits should appear in the documentation.
17 * 3. Altered versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software. Since few users
19 * ever read sources, credits should appear in the documentation.
21 * 4. This notice may not be removed or altered.
23 ******************************************************************************/
29 #include "rewrite-int.h"
40 int in_quoted_field = 0, cnt = 0;
43 for ( p = buf; isspace( (unsigned char) p[ 0 ] ); p++ );
45 if ( p[ 0 ] == '#' ) {
49 for ( begin = p; p[ 0 ] != '\0'; p++ ) {
50 if ( p[ 0 ] == '\\' && p[ 1 ] != '\0' ) {
52 } else if ( p[ 0 ] == '\'' || p[ 0 ] == '\"') {
53 if ( in_quoted_field && p[ 0 ] == quote ) {
54 in_quoted_field = 1 - in_quoted_field;
58 if ( ++cnt == maxargs ) {
62 for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
66 } else if ( !in_quoted_field ) {
71 in_quoted_field = 1 - in_quoted_field;
74 } else if ( isspace( (unsigned char) p[ 0 ] ) && !in_quoted_field ) {
78 if ( ++cnt == maxargs ) {
83 for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
97 struct rewrite_info *info
105 * Empty rule at the beginning of the context
108 for ( lineno = 0; fgets( buf, sizeof( buf ), fin ); lineno++ ) {
109 switch ( parse_line( argv, &argc, sizeof( argv ) - 1, buf ) ) {
115 if ( strncasecmp( argv[ 0 ], "rewrite", 7 ) == 0 ) {
117 rc = rewrite_parse( info, "file", lineno,
119 if ( rc != REWRITE_SUCCESS ) {
127 return REWRITE_SUCCESS;