This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Factorization of some code (updated version).
- To: egcs-patches at cygnus dot com
- Subject: PATCH: Factorization of some code (updated version).
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Date: Wed, 20 Jan 1999 13:14:43 +0100
OK, I think I've taken account of all the remarks I got so here is an
updated version.
This trivial patch just factorizes the code needed to decode options
with a trailing integer parameter (currently -ftemplate-depth-<n>
and -fmangling-version-<n>). The factorized code is in a new function
named read_integral_parameter. The code for decoding -Oxxx can also
benefit from this function with little work (This is a little less
trivial. I will do the work if this patch gets accepted and if no-one
finds objections to do so.).
ChangeLog
Fri Jan 8 17:45:23 1999 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
* toplev.h (read_integral_parameter): Declare.
* toplev.c (read_integral_parameter): New function.
cp/ChangeLog:
1999-01-08 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
* decl2.c (lang_decode_option): Use read_integral_parameter.
Index: gcc/toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.146
diff -c -3 -p -r1.146 toplev.c
*** toplev.c 1999/01/18 08:53:37 1.146
--- toplev.c 1999/01/19 19:32:59
*************** FILE *asm_out_file;
*** 1217,1222 ****
--- 1217,1249 ----
FILE *aux_info_file;
FILE *rtl_dump_file = NULL;
+ /* Decode the string P as an integral parameter.
+ If the string is indeed an integer return its numeric value else
+ issue an Invalid Option error for the option PNAME and return DEFVAL. */
+
+ int
+ read_integral_parameter (p, pname, defval)
+ char *p;
+ char *pname;
+ int defval;
+ {
+ char *endp = p;
+
+ while (*endp)
+ {
+ if (*endp >= '0' && *endp <= '9')
+ endp++;
+ else
+ {
+ error ("Invalid option `%s'", pname);
+ return defval;
+ }
+ }
+
+ return atoi (p);
+ }
+
+
/* Time accumulators, to count the total time spent in various passes. */
int parse_time;
Index: gcc/toplev.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.h,v
retrieving revision 1.15
diff -c -3 -p -r1.15 toplev.h
*** toplev.h 1999/01/18 08:53:38 1.15
--- toplev.h 1999/01/19 19:32:59
*************** union tree_node;
*** 26,31 ****
--- 26,32 ----
struct rtx_def;
#endif
+ extern int read_integral_parameter PROTO ((char *, char *, int));
extern int count_error PROTO ((int));
extern void strip_off_ending PROTO ((char *, int));
extern void print_time PROTO ((const char *, int));
Index: gcc/cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.173
diff -c -3 -p -r1.173 decl2.c
*** decl2.c 1999/01/19 11:14:54 1.173
--- decl2.c 1999/01/19 19:33:02
*************** lang_decode_option (argc, argv)
*** 606,640 ****
}
else if (!strncmp (p, "template-depth-", 15))
{
! char *endp = p + 15;
! while (*endp)
! {
! if (*endp >= '0' && *endp <= '9')
! endp++;
! else
! {
! error ("Invalid option `%s'", p - 2);
! goto template_depth_lose;
! }
! }
! max_tinst_depth = atoi (p + 15);
! template_depth_lose: ;
}
else if (!strncmp (p, "name-mangling-version-", 22))
{
! char *endp = p + 22;
! while (*endp)
! {
! if (*endp >= '0' && *endp <= '9')
! endp++;
! else
! {
! error ("Invalid option `%s'", p - 2);
! goto mangling_version_lose;
! }
! }
! name_mangling_version = atoi (p + 22);
! mangling_version_lose: ;
}
else for (j = 0;
!found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
--- 606,618 ----
}
else if (!strncmp (p, "template-depth-", 15))
{
! max_tinst_depth =
! read_integral_parameter (p + 15, p - 2, max_tinst_depth);
}
else if (!strncmp (p, "name-mangling-version-", 22))
{
! name_mangling_version =
! read_integral_parameter (p + 22, p - 2, name_mangling_version);
}
else for (j = 0;
!found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------