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 ******************************************************************************/
27 #include "rewrite-int.h"
38 int in_quoted_field = 0, cnt = 0;
41 for ( p = buf; isspace( p[ 0 ] ); p++ );
43 if ( p[ 0 ] == '#' ) {
47 for ( begin = p; p[ 0 ] != '\0'; p++ ) {
48 if ( p[ 0 ] == '\\' ) {
50 } else if ( p[ 0 ] == '\'' || p[ 0 ] == '\"') {
51 if ( in_quoted_field && p[ 0 ] == quote ) {
52 in_quoted_field = 1 - in_quoted_field;
56 if ( ++cnt == maxargs ) {
60 for ( p++; isspace( p[ 0 ] ); p++ );
64 } else if ( !in_quoted_field ) {
69 in_quoted_field = 1 - in_quoted_field;
72 } else if ( isspace( p[ 0 ] ) && !in_quoted_field ) {
76 if ( ++cnt == maxargs ) {
81 for ( p++; isspace( p[ 0 ] ); p++ );
95 struct rewrite_info *info
103 * Empty rule at the beginning of the context
106 for ( lineno = 0; fgets( buf, sizeof( buf ), fin ); lineno++ ) {
107 switch ( parse_line( argv, &argc, sizeof( argv ) - 1, buf ) ) {
113 if ( strncasecmp( argv[ 0 ], "rewrite", 7 ) == 0 ) {
115 rc = rewrite_parse( info, "file", lineno,
117 if ( rc != REWRITE_SUCCESS ) {
125 return REWRITE_SUCCESS;