@@ -2075,6 +2075,7 @@ int main( int argc, char** argv )
2075
2075
ctmbstr cfgfil = NULL , errfil = NULL , htmlfil = NULL ;
2076
2076
TidyDoc tdoc = NULL ;
2077
2077
int status = 0 ;
2078
+ int configSpecified = 0 ;
2078
2079
2079
2080
uint contentErrors = 0 ;
2080
2081
uint contentWarnings = 0 ;
@@ -2104,44 +2105,6 @@ int main( int argc, char** argv )
2104
2105
SetConsoleOutputCP (CP_UTF8 );
2105
2106
#endif
2106
2107
2107
- /*
2108
- * Look for default configuration files using any of
2109
- * the following possibilities:
2110
- * - TIDY_CONFIG_FILE - from tidyplatform.h, typically /etc/tidy.conf
2111
- * - HTML_TIDY - environment variable
2112
- * - TIDY_USER_CONFIG_FILE - from tidyplatform.h, typically ~/tidy.conf
2113
- */
2114
-
2115
- #ifdef TIDY_CONFIG_FILE
2116
- if ( tidyFileExists ( tdoc , TIDY_CONFIG_FILE ) )
2117
- {
2118
- status = tidyLoadConfig ( tdoc , TIDY_CONFIG_FILE );
2119
- if ( status != 0 ) {
2120
- fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_CONFIG_FILE , status );
2121
- fprintf (errout , "\n" );
2122
- }
2123
- }
2124
- #endif /* TIDY_CONFIG_FILE */
2125
-
2126
- if ( (cfgfil = getenv ("HTML_TIDY" )) != NULL )
2127
- {
2128
- status = tidyLoadConfig ( tdoc , cfgfil );
2129
- if ( status != 0 ) {
2130
- fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), cfgfil , status );
2131
- fprintf (errout , "\n" );
2132
- }
2133
- }
2134
- #ifdef TIDY_USER_CONFIG_FILE
2135
- else if ( tidyFileExists ( tdoc , TIDY_USER_CONFIG_FILE ) )
2136
- {
2137
- status = tidyLoadConfig ( tdoc , TIDY_USER_CONFIG_FILE );
2138
- if ( status != 0 ) {
2139
- fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_USER_CONFIG_FILE , status );
2140
- fprintf (errout , "\n" );
2141
- }
2142
- }
2143
- #endif /* TIDY_USER_CONFIG_FILE */
2144
-
2145
2108
2146
2109
/*
2147
2110
* Read command line
@@ -2332,6 +2295,7 @@ int main( int argc, char** argv )
2332
2295
{
2333
2296
ctmbstr post ;
2334
2297
2298
+ configSpecified = 1 ;
2335
2299
tidyLoadConfig ( tdoc , argv [2 ] );
2336
2300
2337
2301
/* Set new error output stream if setting changed */
@@ -2347,6 +2311,11 @@ int main( int argc, char** argv )
2347
2311
}
2348
2312
}
2349
2313
2314
+ else if ( strcasecmp (arg , "no-config" ) == 0 )
2315
+ {
2316
+ configSpecified = 1 ;
2317
+ }
2318
+
2350
2319
else if ( strcasecmp (arg , "output" ) == 0 ||
2351
2320
strcasecmp (arg , "-output-file" ) == 0 ||
2352
2321
strcasecmp (arg , "o" ) == 0 )
@@ -2485,6 +2454,46 @@ int main( int argc, char** argv )
2485
2454
continue ;
2486
2455
}
2487
2456
2457
+ if ( ! configSpecified )
2458
+ {
2459
+ /*
2460
+ * Configuration file not specified on the command line so
2461
+ * look for a configuration file in the order of
2462
+ * - HTML_TIDY - environment variable
2463
+ * - TIDY_USER_CONFIG_FILE - from tidyplatform.h, default: ~/.tidyrc
2464
+ * - TIDY_CONFIG_FILE - from tidyplatform.h, default: /etc/tidy.conf
2465
+ */
2466
+
2467
+ if ( (cfgfil = getenv ("HTML_TIDY" )) != NULL )
2468
+ {
2469
+ status = tidyLoadConfig ( tdoc , cfgfil );
2470
+ if ( status != 0 ) {
2471
+ fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), cfgfil , status );
2472
+ fprintf (errout , "\n" );
2473
+ }
2474
+ }
2475
+ #ifdef TIDY_USER_CONFIG_FILE
2476
+ else if ( tidyFileExists ( tdoc , TIDY_USER_CONFIG_FILE ) )
2477
+ {
2478
+ status = tidyLoadConfig ( tdoc , TIDY_USER_CONFIG_FILE );
2479
+ if ( status != 0 ) {
2480
+ fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_USER_CONFIG_FILE , status );
2481
+ fprintf (errout , "\n" );
2482
+ }
2483
+ }
2484
+ #endif /* TIDY_USER_CONFIG_FILE */
2485
+ #ifdef TIDY_CONFIG_FILE
2486
+ else if ( tidyFileExists ( tdoc , TIDY_CONFIG_FILE ) )
2487
+ {
2488
+ status = tidyLoadConfig ( tdoc , TIDY_CONFIG_FILE );
2489
+ if ( status != 0 ) {
2490
+ fprintf (errout , tidyLocalizedString ( TC_MAIN_ERROR_LOAD_CONFIG ), TIDY_CONFIG_FILE , status );
2491
+ fprintf (errout , "\n" );
2492
+ }
2493
+ }
2494
+ #endif /* TIDY_CONFIG_FILE */
2495
+ } /* endif ( ! configSpecified ) */
2496
+
2488
2497
2489
2498
if ( argc > 1 )
2490
2499
{
0 commit comments