@@ -142,7 +142,7 @@ static void config_free_regex (void);
142142 * do not follow the pattern above. This macro is for convenience
143143 * only.
144144 */
145- #define STDCONF (d , re , func ) [CD_ ## d] = { BEGIN "()" WS re END, func, NULL }
145+ #define STDCONF (d , re , func ) [CD_ ## d] = { BEGIN WS re END, func, NULL }
146146
147147/*
148148 * Holds the regular expression used to match the configuration directive,
@@ -534,19 +534,21 @@ set_int_arg (unsigned int *var, const char *line, regmatch_t * match)
534534 *
535535 ***********************************************************************/
536536
537+ #define MGROUP1 -1
538+
537539static HANDLE_FUNC (handle_logfile )
538540{
539- return set_string_arg (& conf -> logf_name , line , & match [2 ]);
541+ return set_string_arg (& conf -> logf_name , line , & match [MGROUP1 + 2 ]);
540542}
541543
542544static HANDLE_FUNC (handle_pidfile )
543545{
544- return set_string_arg (& conf -> pidpath , line , & match [2 ]);
546+ return set_string_arg (& conf -> pidpath , line , & match [MGROUP1 + 2 ]);
545547}
546548
547549static HANDLE_FUNC (handle_anonymous )
548550{
549- char * arg = get_string_arg (line , & match [2 ]);
551+ char * arg = get_string_arg (line , & match [MGROUP1 + 2 ]);
550552
551553 if (!arg )
552554 return -1 ;
@@ -562,7 +564,7 @@ static HANDLE_FUNC (handle_anonymous)
562564
563565static HANDLE_FUNC (handle_viaproxyname )
564566{
565- int r = set_string_arg (& conf -> via_proxy_name , line , & match [2 ]);
567+ int r = set_string_arg (& conf -> via_proxy_name , line , & match [MGROUP1 + 2 ]);
566568
567569 if (r )
568570 return r ;
@@ -574,7 +576,7 @@ static HANDLE_FUNC (handle_viaproxyname)
574576
575577static HANDLE_FUNC (handle_disableviaheader )
576578{
577- int r = set_bool_arg (& conf -> disable_viaheader , line , & match [2 ]);
579+ int r = set_bool_arg (& conf -> disable_viaheader , line , & match [MGROUP1 + 2 ]);
578580
579581 if (r ) {
580582 return r ;
@@ -587,17 +589,17 @@ static HANDLE_FUNC (handle_disableviaheader)
587589
588590static HANDLE_FUNC (handle_defaulterrorfile )
589591{
590- return set_string_arg (& conf -> errorpage_undef , line , & match [2 ]);
592+ return set_string_arg (& conf -> errorpage_undef , line , & match [MGROUP1 + 2 ]);
591593}
592594
593595static HANDLE_FUNC (handle_statfile )
594596{
595- return set_string_arg (& conf -> statpage , line , & match [2 ]);
597+ return set_string_arg (& conf -> statpage , line , & match [MGROUP1 + 2 ]);
596598}
597599
598600static HANDLE_FUNC (handle_stathost )
599601{
600- int r = set_string_arg (& conf -> stathost , line , & match [2 ]);
602+ int r = set_string_arg (& conf -> stathost , line , & match [MGROUP1 + 2 ]);
601603
602604 if (r )
603605 return r ;
@@ -608,7 +610,7 @@ static HANDLE_FUNC (handle_stathost)
608610static HANDLE_FUNC (handle_xtinyproxy )
609611{
610612#ifdef XTINYPROXY_ENABLE
611- return set_bool_arg (& conf -> add_xtinyproxy , line , & match [2 ]);
613+ return set_bool_arg (& conf -> add_xtinyproxy , line , & match [MGROUP1 + 2 ]);
612614#else
613615 fprintf (stderr ,
614616 "XTinyproxy NOT Enabled! Recompile with --enable-xtinyproxy\n" );
@@ -618,12 +620,12 @@ static HANDLE_FUNC (handle_xtinyproxy)
618620
619621static HANDLE_FUNC (handle_syslog )
620622{
621- return set_bool_arg (& conf -> syslog , line , & match [2 ]);
623+ return set_bool_arg (& conf -> syslog , line , & match [MGROUP1 + 2 ]);
622624}
623625
624626static HANDLE_FUNC (handle_bindsame )
625627{
626- int r = set_bool_arg (& conf -> bindsame , line , & match [2 ]);
628+ int r = set_bool_arg (& conf -> bindsame , line , & match [MGROUP1 + 2 ]);
627629
628630 if (r )
629631 return r ;
@@ -633,7 +635,7 @@ static HANDLE_FUNC (handle_bindsame)
633635
634636static HANDLE_FUNC (handle_port )
635637{
636- set_int_arg (& conf -> port , line , & match [2 ]);
638+ set_int_arg (& conf -> port , line , & match [MGROUP1 + 2 ]);
637639
638640 if (conf -> port > 65535 ) {
639641 fprintf (stderr , "Bad port number (%d) supplied for Port.\n" ,
@@ -646,7 +648,7 @@ static HANDLE_FUNC (handle_port)
646648
647649static HANDLE_FUNC (handle_maxclients )
648650{
649- set_int_arg (& conf -> maxclients , line , & match [2 ]);
651+ set_int_arg (& conf -> maxclients , line , & match [MGROUP1 + 2 ]);
650652 return 0 ;
651653}
652654
@@ -659,24 +661,24 @@ static HANDLE_FUNC (handle_obsolete)
659661
660662static HANDLE_FUNC (handle_timeout )
661663{
662- return set_int_arg (& conf -> idletimeout , line , & match [2 ]);
664+ return set_int_arg (& conf -> idletimeout , line , & match [MGROUP1 + 2 ]);
663665}
664666
665667static HANDLE_FUNC (handle_connectport )
666668{
667- add_connect_port_allowed (get_long_arg (line , & match [2 ]),
669+ add_connect_port_allowed (get_long_arg (line , & match [MGROUP1 + 2 ]),
668670 & conf -> connect_ports );
669671 return 0 ;
670672}
671673
672674static HANDLE_FUNC (handle_user )
673675{
674- return set_string_arg (& conf -> user , line , & match [2 ]);
676+ return set_string_arg (& conf -> user , line , & match [MGROUP1 + 2 ]);
675677}
676678
677679static HANDLE_FUNC (handle_group )
678680{
679- return set_string_arg (& conf -> group , line , & match [2 ]);
681+ return set_string_arg (& conf -> group , line , & match [MGROUP1 + 2 ]);
680682}
681683
682684static void warn_invalid_address (char * arg , unsigned long lineno ) {
@@ -685,7 +687,7 @@ static void warn_invalid_address(char *arg, unsigned long lineno) {
685687
686688static HANDLE_FUNC (handle_allow )
687689{
688- char * arg = get_string_arg (line , & match [2 ]);
690+ char * arg = get_string_arg (line , & match [MGROUP1 + 2 ]);
689691
690692 if (insert_acl (arg , ACL_ALLOW , & conf -> access_list ) < 0 )
691693 warn_invalid_address (arg , lineno );
@@ -695,7 +697,7 @@ static HANDLE_FUNC (handle_allow)
695697
696698static HANDLE_FUNC (handle_deny )
697699{
698- char * arg = get_string_arg (line , & match [2 ]);
700+ char * arg = get_string_arg (line , & match [MGROUP1 + 2 ]);
699701
700702 if (insert_acl (arg , ACL_DENY , & conf -> access_list ) < 0 )
701703 warn_invalid_address (arg , lineno );
@@ -705,7 +707,7 @@ static HANDLE_FUNC (handle_deny)
705707
706708static HANDLE_FUNC (handle_bind )
707709{
708- int r = set_string_arg (& conf -> bind_address , line , & match [2 ]);
710+ int r = set_string_arg (& conf -> bind_address , line , & match [MGROUP1 + 2 ]);
709711
710712 if (r )
711713 return r ;
@@ -716,7 +718,7 @@ static HANDLE_FUNC (handle_bind)
716718
717719static HANDLE_FUNC (handle_listen )
718720{
719- char * arg = get_string_arg (line , & match [2 ]);
721+ char * arg = get_string_arg (line , & match [MGROUP1 + 2 ]);
720722
721723 if (arg == NULL ) {
722724 return -1 ;
@@ -748,8 +750,8 @@ static HANDLE_FUNC (handle_errorfile)
748750 * present. This is why the "string" is located at
749751 * match[4] (rather than the more intuitive match[3].
750752 */
751- unsigned long int err = get_long_arg (line , & match [2 ]);
752- char * page = get_string_arg (line , & match [4 ]);
753+ unsigned long int err = get_long_arg (line , & match [MGROUP1 + 2 ]);
754+ char * page = get_string_arg (line , & match [MGROUP1 + 4 ]);
753755
754756 if (add_new_errorpage (conf , page , err ) < 0 ) {
755757 CP_WARN ("add_new_errorpage() failed: '%s'" , page );
@@ -760,8 +762,8 @@ static HANDLE_FUNC (handle_errorfile)
760762
761763static HANDLE_FUNC (handle_addheader )
762764{
763- char * name = get_string_arg (line , & match [2 ]);
764- char * value = get_string_arg (line , & match [3 ]);
765+ char * name = get_string_arg (line , & match [MGROUP1 + 2 ]);
766+ char * value = get_string_arg (line , & match [MGROUP1 + 3 ]);
765767 http_header_t header ;
766768
767769 if (!conf -> add_headers ) {
@@ -802,7 +804,7 @@ static HANDLE_FUNC (handle_loglevel)
802804 sizeof (log_levels ) / sizeof (log_levels [0 ]);
803805 unsigned int i ;
804806
805- char * arg = get_string_arg (line , & match [2 ]);
807+ char * arg = get_string_arg (line , & match [MGROUP1 + 2 ]);
806808
807809 for (i = 0 ; i != nlevels ; ++ i ) {
808810 if (!strcasecmp (arg , log_levels [i ].string )) {
@@ -819,10 +821,10 @@ static HANDLE_FUNC (handle_loglevel)
819821static HANDLE_FUNC (handle_basicauth )
820822{
821823 char * user , * pass ;
822- user = get_string_arg (line , & match [2 ]);
824+ user = get_string_arg (line , & match [MGROUP1 + 2 ]);
823825 if (!user )
824826 return -1 ;
825- pass = get_string_arg (line , & match [3 ]);
827+ pass = get_string_arg (line , & match [MGROUP1 + 3 ]);
826828 if (!pass ) {
827829 safefree (user );
828830 return -1 ;
@@ -840,48 +842,48 @@ static HANDLE_FUNC (handle_basicauth)
840842#ifdef FILTER_ENABLE
841843static HANDLE_FUNC (handle_filter )
842844{
843- return set_string_arg (& conf -> filter , line , & match [2 ]);
845+ return set_string_arg (& conf -> filter , line , & match [MGROUP1 + 2 ]);
844846}
845847
846848static HANDLE_FUNC (handle_filterurls )
847849{
848- return set_bool_arg (& conf -> filter_url , line , & match [2 ]);
850+ return set_bool_arg (& conf -> filter_url , line , & match [MGROUP1 + 2 ]);
849851}
850852
851853static HANDLE_FUNC (handle_filterextended )
852854{
853- return set_bool_arg (& conf -> filter_extended , line , & match [2 ]);
855+ return set_bool_arg (& conf -> filter_extended , line , & match [MGROUP1 + 2 ]);
854856}
855857
856858static HANDLE_FUNC (handle_filterdefaultdeny )
857859{
858- assert (match [2 ].rm_so != -1 );
860+ assert (match [MGROUP1 + 2 ].rm_so != -1 );
859861
860- if (get_bool_arg (line , & match [2 ]))
862+ if (get_bool_arg (line , & match [MGROUP1 + 2 ]))
861863 filter_set_default_policy (FILTER_DEFAULT_DENY );
862864 return 0 ;
863865}
864866
865867static HANDLE_FUNC (handle_filtercasesensitive )
866868{
867- return set_bool_arg (& conf -> filter_casesensitive , line , & match [2 ]);
869+ return set_bool_arg (& conf -> filter_casesensitive , line , & match [MGROUP1 + 2 ]);
868870}
869871#endif
870872
871873#ifdef REVERSE_SUPPORT
872874static HANDLE_FUNC (handle_reverseonly )
873875{
874- return set_bool_arg (& conf -> reverseonly , line , & match [2 ]);
876+ return set_bool_arg (& conf -> reverseonly , line , & match [MGROUP1 + 2 ]);
875877}
876878
877879static HANDLE_FUNC (handle_reversemagic )
878880{
879- return set_bool_arg (& conf -> reversemagic , line , & match [2 ]);
881+ return set_bool_arg (& conf -> reversemagic , line , & match [MGROUP1 + 2 ]);
880882}
881883
882884static HANDLE_FUNC (handle_reversebaseurl )
883885{
884- return set_string_arg (& conf -> reversebaseurl , line , & match [2 ]);
886+ return set_string_arg (& conf -> reversebaseurl , line , & match [MGROUP1 + 2 ]);
885887}
886888
887889static HANDLE_FUNC (handle_reversepath )
@@ -891,12 +893,12 @@ static HANDLE_FUNC (handle_reversepath)
891893 */
892894 char * arg1 , * arg2 ;
893895
894- arg1 = get_string_arg (line , & match [2 ]);
896+ arg1 = get_string_arg (line , & match [MGROUP1 + 2 ]);
895897 if (!arg1 )
896898 return -1 ;
897899
898- if (match [4 ].rm_so != -1 ) {
899- arg2 = get_string_arg (line , & match [4 ]);
900+ if (match [MGROUP1 + 4 ].rm_so != -1 ) {
901+ arg2 = get_string_arg (line , & match [MGROUP1 + 4 ]);
900902 if (!arg2 ) {
901903 safefree (arg1 );
902904 return -1 ;
@@ -937,12 +939,12 @@ static HANDLE_FUNC (handle_upstream)
937939 enum proxy_type pt ;
938940 enum upstream_build_error ube ;
939941
940- if (match [3 ].rm_so != -1 ) {
941- tmp = get_string_arg (line , & match [3 ]);
942+ if (match [MGROUP1 + 3 ].rm_so != -1 ) {
943+ tmp = get_string_arg (line , & match [MGROUP1 + 3 ]);
942944 if (!strcmp (tmp , "none" )) {
943945 safefree (tmp );
944- if (match [4 ].rm_so == -1 ) return -1 ;
945- domain = get_string_arg (line , & match [4 ]);
946+ if (match [MGROUP1 + 4 ].rm_so == -1 ) return -1 ;
947+ domain = get_string_arg (line , & match [MGROUP1 + 4 ]);
946948 if (!domain )
947949 return -1 ;
948950 ube = upstream_add (NULL , 0 , domain , 0 , 0 , PT_NONE , & conf -> upstream_list );
@@ -951,7 +953,7 @@ static HANDLE_FUNC (handle_upstream)
951953 }
952954 }
953955
954- mi = 6 ;
956+ mi = MGROUP1 + 6 ;
955957
956958 tmp = get_string_arg (line , & match [mi ]);
957959 pt = pt_from_string (tmp );
0 commit comments